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

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

Re: [avr-gcc-list] avr-libc _delay routines


From: Matthew MacClary
Subject: Re: [avr-gcc-list] avr-libc _delay routines
Date: Fri, 12 May 2006 09:45:42 -0700
User-agent: Mutt/1.4.1i

On Fri, May 12, 2006 at 09:11:20AM -0700, Micah Carrick wrote:

void delayms(uint16_t millis) {
 while ( millis ) {
   _delay_ms(1);
   millis--;
 }
}

> Is this function used because of the limitation of _delay_ms()?  I read 
> that it's max is "The maximal possible delay is 262.14 ms / F_CPU in 
> MHz." Does that mean that at 8 MHz, the max delay is 32 mS?

    Yes, people just need delays longer than a few milliseconds.

> Wouldn't the function above actually delay longer than millis mS
> since the while and declaration take up clock cycles?

    This is of course true. If your code can accommodate busy-waiting
for milliseconds at a time, then the extra few instructions in the
outer loop probably aren't a big deal.

-Matt




reply via email to

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