This part of library contains functions to generate delays in the program with software algorithms or with hardware timers. Delays do not block interrupts, therefore interrupts interfere with software delays. Delay functions are not pre-compiled to be compatible with different clock frequencies.
Software delay in milliseconds. Function expects the usage of some compiler optimization mode. Parameters:
Software delay in microseconds. Function expects the usage of some compiler optimization mode. Parameters:
Hardware timer based delay in milliseconds. Functions use ATmega128 8-bit timer 0. Depending of the clock frequency, up to several milliseconds delay error may occur. Parameters:
Demonstration of both types of delays.
#include <homelab/delay.h> int main(void) { // Software base delay of 100 ms. sw_delay_ms(100); // Hardware timer based delay of 100 ms. hw_delay_ms(100); }