Since it takes 8 instructions to reload the timer, the actual number would be 30540 for 70ms.
But,... the TimerReload is an External Constant so you can't just give it a value like it's a variable.
You could change the ...
TimerReload CON EXT
-- to --
TimerReload CON 30540
But, if you want it to be easily changable, you might want to change the original code to this.Then you can just change the Interval and Prescaler numbers to anything you wanted, without having to recalculate the Reload value.Code:;--- Change these to match the desired interrupt frequency ------------------- ;--- See http://DarrelTaylor.com/DT_INTS-14/TimerTemplate.html for more Info. @Interval = 70 ; Interval of Interrupts in ms @Prescaler = 2 ; Timers Prescaler setting T1CON = $10 ; $10 = Prescaler 1:2, TMR1 OFF ; $00=1:1, $10=1:2, $20=1:4, $30=1:8 -- Must match @Prescaler value ;---[TMR1 reload - interrupt handler]----------------------------------------- ASM ; Calculate Timer Reload Constant ReloadInst = 8 ; # of Intructions used to reload timer if ((Prescaler == 1)||(Prescaler == 2)||(Prescaler == 4)||(Prescaler == 8)) MaxCount = 65536 + (ReloadInst / Prescaler) TimerReload = MaxCount - ((((OSC*1000000/4)/Prescaler)*Interval)/1000) if ((TimerReload < 0) || (TimerReload > (65535-ReloadInst))) error Invalid Timer Values - check "OSC", "Interval" and "Prescaler" endif else error Invalid Prescaler endif ENDASM
hth,




Bookmarks