Download CodeVisionAVR User Manual
Transcript
CodeVisionAVR
5.19 Delay Functions
These functions are intended for generating delays in C programs.
The prototypes for these functions are placed in the file delay.h, located in the .\INC subdirectory. This
file must be #include -d before using the functions.
Before calling the functions the interrupts must be disabled, otherwise the delays will be much longer
then expected.
Also it is very important to specify the correct AVR chip clock frequency in the Project|Configure|C
Compiler|Code Generation menu.
The functions are:
void delay_us(unsigned int n)
generates a delay of n µseconds. n must be a constant expression.
void delay_ms(unsigned int n)
generates a delay of n milliseconds.
This function automatically resets the wtachdog timer every 1ms by generating the wdr instruction.
Example:
void main(void) {
/* disable interrupts */
#asm("cli")
/* 100µs delay */
delay_us(100);
/* ............. */
/* 10ms delay */
delay_ms(10);
/* enable interrupts */
#asm("sei")
/* ............. */
}
© 1998-2013 HP InfoTech S.R.L.
Page 318
Related documents
CodeVisionAVR User Manual
CodeVisionAVR User Manual - La documentation de Thierry
CodeVisionAVR User Manual
Xvhu#Pdqxdo# - book.isito.kg(0)
Dishwasher Lave-vaisselle
Resistive Touch Sensor based Graphics Plotter on an Embedded
Digital Solutions
LMT050DNCFWU 50DNCFWU-N NCN
JARDUINO MANUAL DE USUARIO v1.2 beta
Digole Serial:UART/I2C/SPI Character/Graphic LCD
LMT056DIDFWD-ABB - topwaydisplay.com
CodeVisionAVR User Manual