DelayMicroseconds() interrogation?

Hello everyone,

How does the delayMicroseconds() function works. From what I understood the prescaler of timer0 is set to 64. For a 16MHz clock gives a count every 4.0uS. I am a bit confused on the math to get to 1uS interval?

I already built a personal delay() function by having my prescaler set to 64 and TCNT0 register set to 6 which gives an overflow every 250 count... But I do not see how to have the micro seconds interval.

Thank you all

M.

Hawk_08:
I am a bit confused on the math to get to 1uS interval?

As far as the timer-based micros() function is concerned, there is none. The micros() function has a resolution of 4 µs -- it actually says so in the documentation.

The delayMicroseconds() function, on the other hand, isn't implemented with a timer. It uses a wait loop, simply wasting a suitable amount of clock cycles doing nothing. (It's defined in hardware/arduino/cores/robot/wiring.c. You can look it up there.)