> -----Original Message----- > From: > avr-gcc-list-bounces+eweddington=cso.atmel....@nongnu.org > [mailto:avr-gcc-list-bounces+eweddington=cso.atmel....@nongnu. > org] On Behalf Of Bob Paddock > Sent: Wednesday, March 04, 2009 9:00 AM > To: AVR-GCC > Subject: [avr-gcc-list] Using delay functions with variable > F_CPU clock? > > 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.
The delay functions require a constant so the delay can be calculated at compile time. I would think that part of the problem is that you have to introduce more code to check the value of f_cpu and to calculate the delay. This pushes the delay calculation into run-time, plus it adds more code to check the condition, which has to be factored into the delay itself. _______________________________________________ AVR-GCC-list mailing list AVR-GCC-list@nongnu.org http://lists.nongnu.org/mailman/listinfo/avr-gcc-list