Ads Below The Title

Pulse Generator using 8051


Providing Delay using internal timers of AT89c51. We are generating a pulse wave having 250ms ON time and 250ms OFF time. microcontroller clock time is 1.085us.
                                             25ms / 1.085us = 23041 = A5FE in hex
                                             25ms x 10 = 250ms                                             

#include<reg51.h>
void T0delay(void);
// delay function
sbit Mybit=P2^0;
// output port
void main(void)
{
unsigned char x;
while(1)
{
Mybit= ~Mybit;
// inverter
for(x=0;x<10;x++)
T0delay();
}
}
void T0delay(void)
{
TMOD=0x01;
// selecting timer-0 mode-1
TL0=0xFE;  
// count starts at A5FE
TH0=0xA5;
TR0=1;       
// timer-0 run
while(TF0==0);
//wait until timer-0 flag overflow
TR0=0;
// then stop timer-0
TF0=0;
// reset the overflow flag
}





  


Result:     to see output
Pulse Generator using 8051 Pulse Generator using 8051 Reviewed by haru on May 13, 2013 Rating: 5

No comments

Ads Inter Below The Post
Image Link [https://lh3.googleusercontent.com/-wlvSkBWGUW0/AAAAAAAAAAI/AAAAAAAAAxU/6FpWSjn-h2o/s120-c/photo.jpg] Author Name [Sora Templates] Author Description [Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard] Facebook Username [#] Twitter Username [#] GPlus Username [#] Pinterest Username [#] Instagram Username [#]