written 5.9 years ago by
teamques10
★ 68k
|
•
modified 5.9 years ago
|
Crystal frequency= 11.0592 MHz
I/P clock = 11.0592 X 106 = 11.0592MHz
1/12x11.0592Mhz = 921.6 Khz
Tin = 1.085μ sec
For 2 kHz square wave
Fout = 2 KHz
Tout = 1/2 X 103
Tout = 500μ sec
Consider half of it = Tout = 250μ sec
N = Tout / Tin = 250/1.085= 230
65536-230= (65306p10 ) =FF1A
Program
#include<reg51.h>
void delay(void);
sbit p=P1^5;
void main (void)
{
while (1)
{
p=~p;
delay();
}
}
void delay()
{
TMOD=0X01; //set timer 0 in mode 1 i.e. 16 bit number
TL0=0X1AH; //load TL register with LSB of count
TH0=0XFFH ; //Load TH register with MSB of count
TR0 =1 //Start timer 0
While(TF0==0) //wait until timer rolls over
TR0=0; //Stop timer 0
TF0=0; //Clear timer flag 0
}