Hi, I have just started working with PIC's. I wanted to get a 16F877 to generate a square wave on PORTD by toggling it periodically. I decided to use timer 0 to generate an interrupt periodically. At the end of the message I list the short program. The problem: When I run the program I do get a square wave ( oscilloscope ) but for some reason it isn't perfect. Every few interrupts I get some kind of a glitch which slightly reduces the pulse width as if the timer decided to interrupt the processor earlier. Things I checked: Made sure that WDT is off. I get a perfect square wave with a plain loop. So I assume my crystal is stable. Run out of ideas.... I would appreciate it if somebody could help me out. Thanks Ioannis-- list p=16f877 ; Include file, change directory if needed include "p16f877.inc" intcon equ 0x0b ; Start at the reset vector org 0x000 nop goto Start org 0x004 ;interupt service rutine goto isr Start banksel PORTD clrf PORTD ;Clear PORTD banksel OPTION_REG movlw B'10001000' ;prescaler assigned to WDT movwf OPTION_REG clrf TRISD ;PORTD all outputs banksel TMR0 movlw 0 movwf TMR0 banksel intcon bcf intcon,2 bsf intcon,7 bsf intcon,5 ;gloabal interupt enabled circle goto circle isr bcf intcon,2 ;clear TMR0 interupt flag comf PORTD,f RETFIE end