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

ArktiTic
Sun May 05 2024, 07:06 pm
CesslasyNear
Sun May 05 2024, 02:58 pm
chimichmedic1204
Sun May 05 2024, 11:06 am
Jamiegob
Sun May 05 2024, 10:11 am
Gregoryjed
Sun May 05 2024, 10:02 am
Mariocax
Sun May 05 2024, 08:51 am
WilliamErync
Sun May 05 2024, 02:35 am
Danielnof
Sat May 04 2024, 11:12 pm