DEM - Sk-Generation of Delay Using Timer
DEM - Sk-Generation of Delay Using Timer
Simulate/ test on the microcontroller from 8051 family. Generate the delay of approximately 2
sec using Timer1 in mode 1. Perform the required calculations. Toggle the LEDS connected to
port 3 with the delay of 2 sec.
What is the maximum delay can be generated using timer 1 in mode 0
If delay of 500 ms is to be generated what value have to be loaded in the TH1 and TL1 and
how many iterations are to be set for loop to repeatedly call the timer delay function
( students can do only keil coding and testing, proteus simulation is optional)
Aim/objective
Apparatus/ Tools/ Equipment’s/ Resources used- PPT for explanation of practical, Keil
Theory-
Procedure:
1. prepare the framework for the system
2. List the components required.
3) prepare the schematic
4) Write he the code in C and prepare hex file.
5) Provide this hex file to microcontroller
5) Run simulation and test the system
Code :
#include <reg51.h>
void timerdelay();
void main (void)
{
unsigned int x;
P3=0X55;
while(1)
1
{
P3=~P3;
for(x=0; x<28; x++)
0 {
timerdelay();
}
}
}
void timerdelay(void)
{
TMOD=0x10;
TR1=0;
TL1=0x00;
TH1=0x00;
while(TF1==1);
}
Observation table:
Toggling of LEDs observed at port 3. Change in the delay with different values also observed.
Students to do the calculation for given problem statement
2
3