Hi, I have been trying to sort out this problem for the last 2 days, and have done nothing to successfully do so - hopefully you guys will be able to help me out. Basically, what I'm building is an alarm clock... simple. I figured I would use Timer 1 on an f877 to generate an interrupt every 500mS (couldn't do one second since 16 bits couldn't hold it, even with a prescaler). All the interrupt would be responsible for is incrementing the second register, and consequently the minute and hour bla bla ... the rest of the functionality would be done outside of the interrupt (As in outputting the values etc). Since it interrupts every 500ms, I need a flag to tell whether it's in the 0 - 0.5 second range, or 0.5 - 1 second so I can know when to increment the second register. I hope I'v explained this much well... so anyway, the check is very simple. If it is in the 0.5 - 1 second range (ie: back half of one second), I don't bother continuing in the interrupt since a whole second hasn't elapsed yet - I just called 'retfie'. If it's on the first half of the second, then and only then do I increment and so on... my problem (finally) is that the time between the first half interrupt and second half interrupt aren't even.. they vary by one instruction cycle... and this is because of the check for the flag. If I remove that check, it interrupts every 500mS as it should (I am checking all this with the stopwatch in MPSIM Btw). What doesn't make sense to me is that I set the timer running BEFORE I do the test, so regardless of the test, the time should already be running. It shouldn't matter if I return from the interrupt one instruction later, or 20! At least in my understanding... anyway, that's my long explanation, hopefully you guys can see my obvious flaw which I can't. My ISR is below: the main code of my program as of now is very simple, it's just looping endlessly. And I know I do'nt have any 'context saving' implemented yet in my ISR, but it's coming. I just wanted to get this working first... isr ;Stop the Timer and reload with value 0BDF (value I have calculated to work with 500mS) T1Stop ;Macro to stop the timer banksel TMR1H movlw 0x0B movwf TMR1H banksel TMR1L movlw 0xDF movwf TMR1L ;Clear the T1 Interrupt Flag so it doesn't interrupt again when we exit. T1IFClear ;Start Timer. T1Start ;Now that Timer 1 has started, we can work out other code. ;First test to see if Timer 1 is in the 0.5 - 1 sec range (_SECONDBIT will be set), or 0 - 0.5 sec. ;Toggle the bit first, and then continue if it is set (meaning it was previously cleared). ;This will be our mask to toggle the first bit. movlw b'10000000' banksel flagreg xorwf flagreg,f ;Test _SECONDBIT - skip if it's set, meaning it was clear before. btfss _SECONDBIT retfie ;Increment the seconds register since code is at first half of second. banksel seconds movlw 0x01 addwf seconds,f ;I will add the other registers in here etc... once I get this working retfie Thank you all again! ---------------------------------------- This mail sent through www.mywaterloo.ca -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads