AVRTools
A Library for the AVR ATmega328 and ATmega2560 Microcontrollers
|
This file provides simple delay functions that do not involve timers or interrupts. These functions simply execute a series of nested loops with known and precise timing. More...
#include <stdint.h>
Go to the source code of this file.
Functions | |
void | delayQuartersOfMicroSeconds (uint16_t nbrOfQuartersOfMicroSeconds) |
Delay a given number of quarter microseconds. Due to function call overhead, at 16 MHz the smallest possible delay is just under 6 quarter microseconds (~1.5 microseconds). Delays of 7 quarter microseconds or greater are reasonably accurate. At 8 MHz the smallest possible delay is just under 12 quarter microseconds (~3 microseconds). Delays of 13 quarter microseconds or greater are reasonably accurate. More... | |
void | delayWholeMilliSeconds (uint8_t nbrOfMilliSeconds) |
Delay a given number of milliseconds. Despite function call overhead, this function is accurate within a few hundreds of microseconds. More... | |
void | delayTenthsOfSeconds (uint8_t nbrOfTenthsOfSeconds) |
Delay a given number of tenths of a seconds. Despite function call overhead, this function is accurate within a few hundreds of microseconds. More... | |
This file provides simple delay functions that do not involve timers or interrupts. These functions simply execute a series of nested loops with known and precise timing.
For precision, these functions are all implemented directly in assembler.
void delayQuartersOfMicroSeconds | ( | uint16_t | nbrOfQuartersOfMicroSeconds | ) |
Delay a given number of quarter microseconds. Due to function call overhead, at 16 MHz the smallest possible delay is just under 6 quarter microseconds (~1.5 microseconds). Delays of 7 quarter microseconds or greater are reasonably accurate. At 8 MHz the smallest possible delay is just under 12 quarter microseconds (~3 microseconds). Delays of 13 quarter microseconds or greater are reasonably accurate.
At 16 MHz delays of less than 7 quarter microseconds produce a delay of just under 6 quarter microseconds (~1.5 microseconds). At 8 MHz delays of less than 12 quarter microseconds produce a delay of just under 12 quarter microseconds (~3 microseconds).
The maximum delay is 65535 quarter microseconds (equal to 16,383.75 microseconds, or about 16.4 milliseconds).
nbrOfQuartersOfMicroSeconds
the number of quarter microseconds to delay. For 16 MHz clocks, arguments less than 7 quarter microseconds for 16 MHz clocks all produce delays of just under 6 quarter microseconds. For 8 MHz clocks, arguments less than 13 quarter microseconds all produce delays of about 12 quarter microseconds.For precision, this function is implemented directly in assembler.
void delayTenthsOfSeconds | ( | uint8_t | nbrOfTenthsOfSeconds | ) |
Delay a given number of tenths of a seconds. Despite function call overhead, this function is accurate within a few hundreds of microseconds.
nbrOfTenthsOfSeconds
the number of tenths of seconds to delay. The maximum delay is 256 tenths of a second or 25.6 seconds (pass 0 for a delay of 256 tenths of a second).For precision, this function is implemented directly in assembler.
void delayWholeMilliSeconds | ( | uint8_t | nbrOfMilliSeconds | ) |
Delay a given number of milliseconds. Despite function call overhead, this function is accurate within a few hundreds of microseconds.
nbrOfMilliSeconds
the number of milliseconds to delay. The maximum delay is 256 milliseconds (pass 0 for a delay of 256 milliseconds).For precision, this function is implemented directly in assembler.