Code :-
#include<reg51.h>
sbit led=P2^0;
void delay()
{
TMOD = 0x01; // Timer0 mode1
TH0 = 0xFC; // Initial value for 1ms in TH0 and TL0
TL0 = 0x66;
TR0 = 1; // To Enable the Timer-0
while(TF0==0); // check overflow condition
TR0 = 0; // Timer-0 Disable
TF0 = 0; // Clear flag
}
void main()
{
while(1)
{
led = 1; // Led is ON for 1ms
delay(); // Delay function for 1ms
led = 0; // Led is OFF for 1ms
delay();
}
}
This is the simple code to generate clock pulse. If you execute this code you get this type of result see below. The below figure shows the clock pulse with 1ms ON and 1ms OFF.
Hardware Simulation:-
I run this code in Proteus software, the Hardware circuit is look like this
This clock pulse is play an important role in Embedded systems mainly in Digital circuits. Their is no need to extra circuit to generate clock pulse. They are so many application by applications by using clock pulse I will show in my next few posts.
For clear understanding you see the below video.
No comments:
Post a Comment