Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Delay functions and "__builtin_avr_delay_cycles".

2011-07-04 by David Kelly

On Jul 4, 2011, at 2:55 PM, Cat C wrote:

> Hi there,
> Looking at the delay functions, I see that:	void _delay_us 
>          (
>          double 
>           __us )has a maximal possible delay is 768 us / F_CPU in MHz.
> But:If the avr-gcc toolchain has __builtin_avr_delay_cycles(unsigned long) 
> support, maximal possible delay is 4294967.295 us/ F_CPU in MHz.
> How do I know if the avr-gcc toolchain has __builtin_avr_delay_cycles(unsigned long) support?
> Thanks,
> Cat


"Use the source (sic) Luke".

Consult the avr-libc sources. I don't remember how much is shipped with WinAVR, or how much is shipped with AVR Studio 5.0. It doesn't really matter else I would go look because even if you go looking at the original source you need to build a test case and select "generate a disassembly listing" and have a look at exactly what code was generated. Else the original library sources you are looking at may not be the ones used for your CPU.

Burning CPU cycles in empty loops is usually a very amateurish and inaccurate means to an end.

--
David Kelly N4HHE, dkelly@HiWAAY.net
========================================================================
Whom computers would destroy, they must first drive mad.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.