avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Floating Point operations on tiny25


From: Steven Michalske
Subject: Re: [avr-gcc-list] Floating Point operations on tiny25
Date: Wed, 4 Mar 2009 12:25:12 -0800

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
address@hidden
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list





reply via email to

[Prev in Thread] Current Thread [Next in Thread]