probably something like this....

#define REF_VOLTAGE 2.56

float voltage = 0.0;

voltage = ADC_VALUE * ( refVoltage / 2 ^ 10 );

double check that the compiler compiled the part in parentheses to a constant.


As others have said, you will want to do fixed point math or other unit scaling once you fill your code space, as adding code floating point is expensive in code space.

typical solution....

at a 2.56 volt reference you have 2.5 mV per bit. so do the math using integers, with this fact known.


Have fun


On Mar 4, 2009, at 6:18 PM, Rodney McCray wrote:

Does anyone have any working sample code that shows how to convert 10 bit
ADC outputs into floating points using GCC.
I need to work with floating points on an ATtiny25.

Best Regards,
Rodney




_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list



_______________________________________________
AVR-GCC-list mailing list
AVR-GCC-list@nongnu.org
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list

Reply via email to