hi, i m facing one peculiar problem in timer 1 interrupt in Atmel 89c52. Using interrupt, I am generating a pulse at regular intervals. If I watch the pulses continuously in oscilloscope,sometimes pulse width is varying. Can anyone help me in this regards. I attached the code here. main() { /* Assume proper time settings here */ ---- ---- while(1) { P0=0; overflow_count=0; while(overflow_count <=4000); P0=1; overflow_count=0; while(overflow_count <=4000); } } void timer1 interrupt 3 { overflow_count++; } Assume no syntax error or logical errors in the code. regards, sara
Sure, it is due latency - you should move a toggle command into ISR. But the best way for generate 1/2 duty cycle pulse is usage Timer2 in in Clock-out Mode. By this way, the pulse width has never been varyed - neither by latency nor by software. Good days!