Square Wave Generation using Delay

Delay Calculation
Crystal frequency = 11.059MHz.
1 machine cycle = 1 / (11.059/12) = 1.085μ s
For 1second delay1.085μ s * 921660 = 1 sec (approx)


#include <reg51.h>
main()
{
int i,j;
P0=0xff;
for(i=0;i<=1000;i++)
{
for(j=0;j<=490;j++);
}
P0=0x00;
for(i=0;i<=1000;i++)
{
for(j=0;j<=458;j++);
}
}

Comments

Popular Posts