To create a square wave generation using Delay.
let us say we want to construct a 1khz square waveform
the processor instruction cycle of 8051 is 1.085microseconds
so for 1khz (1milli seconds =1/1khz), is 1ms/1.085microseconds = 921.6 (this value is set to the for loop)
#include <reg51.h>
void delay()
{
for(i=0;i<922;i++)
}
void main()
{
P0=0xff;
delay();
P0=0x00;
delay();
}
i want to create a 38khz asymmetric square wave using 8051. can u help me to write c language code????
ReplyDelete