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

2009-03-04 Thread Bob Paddock
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

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

2009-03-04 Thread Stu Bell
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

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

2009-03-04 Thread Weddington, Eric
-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

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

2009-03-04 Thread David VanHorn
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

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

2009-03-04 Thread Weddington, Eric
-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 David VanHorn Sent: Wednesday, March 04, 2009 11:46 AM To: AVR-GCC Subject: Re: [avr-gcc-list] Using delay

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

2009-03-04 Thread Joerg Wunsch
Bob Paddock graceindustr...@gmail.com wrote: 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? #undef F_CPU #define F_CPU new_value _delay_us(us); F_CPU is always evaluated

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

2009-03-04 Thread David VanHorn
F_CPU is always evaluated upon each invocation, so if you ever change it within one compilation unit, the next invocation of one of these macros will reflect this. That's compile-time, he's looking for execution-time changes in processor speed. He didn't explicitly say so, but I think he's

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

2009-03-04 Thread Dave N6NZ
David VanHorn wrote: F_CPU is always evaluated upon each invocation, so if you ever change it within one compilation unit, the next invocation of one of these macros will reflect this. That's compile-time, he's looking for execution-time changes in processor speed. He didn't explicitly say so,

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

2009-03-04 Thread David Kelly
On Wed, Mar 04, 2009 at 04:37:22PM -0500, David VanHorn wrote: F_CPU is always evaluated upon each invocation, so if you ever change it within one compilation unit, the next invocation of one of these macros will reflect this. That's compile-time, he's looking for execution-time changes

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

2009-03-04 Thread Weddington, Eric
] Using delay functions with variable F_CPU clock? On Wed, Mar 04, 2009 at 04:37:22PM -0500, David VanHorn wrote: F_CPU is always evaluated upon each invocation, so if you ever change it within one compilation unit, the next invocation of one of these macros will reflect