This is an old revision of the document!


Table of Contents

Delay

This part of library contains functions to generate delays in program with software algorithms or with hardware timers. Delays do not block interrupts therefore software delays are interfered by them. 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 uses ATmega128 8-bit timer 0. Depending of the clock frequency, delay error up to several milliseconds 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.1269534894.txt.gz · Last modified: (external edit)
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