thannara123
Advanced Member level 5
making one milli second delay in 8051 using timer mode is the following programme is correct ?
crystal frequency is 20MHz
crystal frequency is 20MHz
Code:
#include <REGX51.H>void _ms_delay(unsigned int delay)
{
while(delay != 0) // mult delay
{ --delay;
TMOD = 0x01; // Timer1 mode0
TH0= 0xF9; //initial value for 1ms
TL0 = 0x7D;
TR0 = 1; // timer start
while (TF0 == 0); // check overflow condition
TR0 = 0; // Stop Timer
TF0 = 0; // Clear flag
} }
void main()
{
_ms_delay(2); // calling two milli second
}