8051 microcontroller project that generates a square wave on P1.0 using Timer0 Mode 1 in Keil µVision.
Write a 8051 c program to generate a square wave with frequency of 50khz
- Personal Computer
- Keil µVision Software
#include <reg51.h>
sbit sqWave = P1^0;
void main()
{
unsigned char TH0_val = 0xFF;
unsigned char TL0_val = 0xF6;
TMOD = 0x01;
while(1)
{
TH0 = TH0_val;
TL0 = TL0_val;
TR0 = 1;
while(TF0 == 0);
TR0 = 0;
TF0 = 0;
}
}
Thus the 8051 C program to generate a square wave with frequency of 50khz using keil was done and shown the output.
Write a 8051 program to generate a square wave with frequency of 50khz
- Personal Computer
- Keil µVision Software
CLR P1.0
MOV TMOD, #01H
AGAIN:
MOV TL0, #0F7H
MOV TH0, #0FFH
CPL P1.0
SETB TR0
WAIT:
JNB TF0, WAIT
CLR TR0
CLR TF0
SJMP AGAIN
END
Thus the 8051 prpgram to generate a square wave with the frequency of 50khz using 8051 KEIL was done and shown the output

