Timer1 should be re-loaded each time in the handler.
It should be the first thing done in the handler, and it should be added to the timer value instead of just loaded.
Adding the value helps to compensate for interrupt latencies, keeping the frequency nice and stable.
To make it easier to add, RD16 (T1CON.7) should be turned off.
Code:
Timer1 VAR WORD EXT
@Timer1 = TMR1L
T1CON = %00000001
TIMER = 64233
;... Main program here
SINE: ; interrupt handler
T1CON.0 = 0 ; stop Timer
Timer1 = Timer1 + TIMER
T1CON.0 = 1 ; restart Timer
;... rest of handler
@ INT_RETURN
Bookmarks