You are on page 1of 4

Task statement:

Create a square wave of 50Hz on P2.3 by using Timer 0 as well as a square wave of 60Hz on P2.4 by
using Timer 1 simultaneously. Use interrupt service routines for both timers.

CODE:
#include <reg51.h>
sbit w50 =P2^3;
sbit w60 =P2^4;
void timer0() interrupt 1 {
w50 =~w50 ;
TH0=0xD8;
TL0=0xF0;
}
void timer1() interrupt 3 {
w60=~w60;
}
void main()
{
TMOD=00010001;
TH1=0xDF;
TL1=0x73;
IE=0x8A;
TR0=1;
TR1=1;
while (1);
}

OUTPUT:

You might also like