Table of Contents

Delay

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.

Functions

  • void sw_delay_ms(unsigned short count)

Software delay in milliseconds. Function expects the usage of some compiler optimization mode. Parameters:

  • count - Delay time in milliseconds. 0 to 65535 ms.
  • void sw_delay_us(unsigned short count)

Software delay in microseconds. Function expects the usage of some compiler optimization mode. Parameters:

  • count - Delay time in microseconds. 0 to 65535 μs.
  • void hw_delay_ms(unsigned short count) \\'

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:

  • count - Delay time in milliseconds. 0 to 65535 ms.

Examples

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);
}
en/software/homelab/library/delay.txt · Last modified: 2020/07/20 09:00 by 127.0.0.1
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0