Discussion in "AVR Discussion Forum" started by    vijay    Mar 14, 2013.
Thu Mar 14 2013, 06:44 pm
#1
How to convert hexadecimal to decimal???
i m using this equation ((((ADCH*256)+ADCL)*5)/1024) to get decimal value...but not giving...Is there any other equation?
Sat Mar 16 2013, 01:43 am
#2


How to convert hexadecimal to decimal???
i m using this equation ((((ADCH*256)+ADCL)*5)/1024) to get decimal value...but not giving...Is there any other equation?

vijay.parmar1992


There may be some confusion here.
The value in ADCH and ADCL is a binary representation of a number.

(ADCH*256)+ADCL will give the right value , assuming the result has not been shifted
by the ADC.
Left or right shifting of results is an option on PICs, I don't know about AVR.
Sat Mar 16 2013, 05:26 pm
#3
hex or decimal is just a representation. It doesnt make any sense to a variable. for example,

a = 0x10 is same as a = 16

for variable a it does not matter you are writing in hex/decimal. If you are displaying it on lcd/sending on uart etc, only then it becomes significant thing.

But if you are talking about BCD (binary coded decimal) that becomes different. for example
a = 0x10 becomes a = 0x16 in BCD
So these conversions depends on the use case of your program. Hope you get my idea now.

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

DavidInomy
Sun May 12 2024, 09:03 am
masagnik1226.ru_gpEn
Sun May 12 2024, 06:50 am
Martinorics
Sun May 12 2024, 02:03 am
Nigarcarm
Sat May 11 2024, 11:22 pm
JefferyBrazy
Sat May 11 2024, 02:33 pm
autogCar
Sat May 11 2024, 03:38 am
Dulcehet
Fri May 10 2024, 04:22 pm
ElvasKl
Fri May 10 2024, 04:54 am