Difference between revisions of "Delay"
(→DELAY_sec) |
|||
Line 58: | Line 58: | ||
==user guide== | ==user guide== | ||
+ | /* Program to blink the LEDs using delay routines*/ | ||
+ | <syntaxhighlight> | ||
+ | #include<reg52.h> | ||
+ | #include "delay.h" //User defined library which contains the delay routines | ||
+ | |||
+ | |||
+ | |||
+ | int main() | ||
+ | { | ||
+ | |||
+ | |||
+ | while(1) | ||
+ | { | ||
+ | PO = 0xff; /* Turn ON the LEDs */ | ||
+ | DELAY_us(10); /* Generate the delay of 1sec+10ms+10us */ | ||
+ | DELAY_ms(10); | ||
+ | DELAY_sec(1); | ||
+ | |||
+ | P0 = 0x00; /* Turn OFF the LEDs */ | ||
+ | DELAY_us(10); /* Generate the delay of 1sec+10ms+10us */ | ||
+ | DELAY_ms(10); | ||
+ | DELAY_sec(1); | ||
+ | |||
+ | } | ||
+ | |||
+ | return 0; | ||
+ | } | ||
+ | </syntaxhighlight> |
Revision as of 17:32, 25 December 2014
DELAY
This library provides the functions to generate the required delays. Basically it does the looping for the specified count to generate the delay. If the compiler provides the inbuilt delay libraries(like AVR), then this library uses internally those functions.
DELAY_us
Defination | |
Input Arguments | |
Return Value | |
Description | |
Usage |
DELAY_ms
Defination | |
Input Arguments | |
Return Value | |
Description | |
Usage |
DELAY_sec
Defination | void DELAY_sec(uint16_t sec_count) |
Input Arguments | uint16_t. |
Return Value | none |
Description | This function is used generate delay in sec .It generates a delay of 1sec for each count,if 10 is passed as the argument then it generates delay of 10sec. |
Usage |
user guide
/* Program to blink the LEDs using delay routines*/
#include<reg52.h> #include "delay.h" //User defined library which contains the delay routines int main() { while(1) { PO = 0xff; /* Turn ON the LEDs */ DELAY_us(10); /* Generate the delay of 1sec+10ms+10us */ DELAY_ms(10); DELAY_sec(1); P0 = 0x00; /* Turn OFF the LEDs */ DELAY_us(10); /* Generate the delay of 1sec+10ms+10us */ DELAY_ms(10); DELAY_sec(1); } return 0; }