I have taken a look and 'instantly' it doesn't look so easy to understand, ...
It does look a bit confusing at first, but it couldn't be easier.
A complete understanding of how it works will come later after getting it to work.
This is really the only section you need to digest.
Set Freq to 2000, Prescaler to 1, and T1CON to 0. Fill in the Main program and T1handler that gets called on each interrupt.
Done deal.
Code:
;--- Change these to match the desired interrupt frequency -------------------
;--- See http://DarrelTaylor.com/DT_INTS-14/TimerTemplate.html for more Info.
@Freq = 2000 ; Frequency of Interrupts in Hz
@Prescaler = 1 ; Timers Prescaler setting
T1CON = $00 ; $00 = Prescaler 1:1, TMR1 OFF
; $00=1:1, $10=1:2, $20=1:4, $30=1:8 -- Must match @Prescaler value
@ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts
GOSUB StartTimer ; Start the Timer
;____Your Main Program goes here______________________________________________
Main:
; ---- Your Main Program goes here ----
GOTO Main
;____This routine is Called on each TMR1 Interrupt____________________________
T1handler:
; ---- Your interrupt routine goes here ----
@ INT_RETURN
Bookmarks