generating a square wave in 8051 port
Dear osoenbolsa ,
If you need to vary the frequency from the minimum to the maximum , The Tie should be varied from the maximum to minimum.
As VIPUL said you need to use the timer interrupt for the perfect waveform generation.
Try with the usage of interrupts , else if you find it as difficult try with the delay routines .
For 1 Khz Generation , the Time will be , 500us OFF and 500 us ON . Better you write a delay rutine for 250us , and call the delay routines that much frequencyyou need to generate in multiles of 250us.
for example , for 1Khz generation , Set 1^0 to 1 and call 250us delay twice , Clr 1^0 to 0 and call 250us delay twice. Do that continously .
But the Best way is to generate square wave with Interrupt routines.
regards,
Vikeee ..