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

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

RE: [avr-gcc-list] Using delay functions with variable F_CPU clock?


From: Weddington, Eric
Subject: RE: [avr-gcc-list] Using delay functions with variable F_CPU clock?
Date: Wed, 4 Mar 2009 11:16:26 -0700

 

> -----Original Message-----
> From: 
> address@hidden 
> [mailto:address@hidden
> 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.




reply via email to

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