Many of the newer AVRs, Tiny88 for example, let you dynamically change
the CPU clock
frequency. However the AVR-LibC based delays always assume
a fixed frequency based on F_CPU.
I'll always know what frequency I'm at when I call a delay() function.
Is there a way of doing:
_delay_us( double __us, uint32_t f_cpu )
and still have the compiler generate code that does not
invoke floating point at run time?
I could make a delay function for each clock frequency,
but that seems less than optimal.
Current function for way of example from delay.h:
void
_delay_us(double __us)
{
uint8_t __ticks;
double __tmp = ((F_CPU) / 3e6) * __us;
if (__tmp < 1.0)
__ticks = 1;
else if (__tmp > 255)
{
_delay_ms(__us / 1000.0);
return;
}
else
__ticks = (uint8_t)__tmp;
_delay_loop_1(__ticks);
}
_______________________________________________
AVR-GCC-list mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/avr-gcc-list