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

Tumergix
Sun Apr 28 2024, 12:59 am
StevenDrulk
Sat Apr 27 2024, 08:47 pm
StephenHauct
Sat Apr 27 2024, 09:38 am
Adamsaf
Sat Apr 27 2024, 07:12 am
Robertphype
Sat Apr 27 2024, 12:23 am
ktaletrryp
Fri Apr 26 2024, 10:55 pm
Robertrip
Fri Apr 26 2024, 11:20 am
ArnoldDiant
Fri Apr 26 2024, 03:53 am