Darrel,
While poking around and getting ideas, I got to looking at ver 1.2 of "Elapsed_INT-18.bas". I was particularly interested in the nice routine to calculate the timer reload constant:
Code:
' -------------- calc timer reload Constants -------------------------------
ASM
T1PS = 1 ; start with 1:1 postscaler
TimerConst = ((OSC*1000000)/4/100) ; how many timer ticks will it take
while TimerConst > 65400 ; if it's more than the timer can count
T1PS = T1PS * 2 ; double the postscaler
TimerConst = TimerConst / 2 ; halve the count
endw
TimerConst = 65536 - TimerConst + 8 ; final reload value
But, I think there is an error in the formula. The absolute time it takes to execute the 8 instruction cycles doesn’t change. But, the time in relation to the TMR1L will be proportional to the prescaler. So, that should be accounted for in the formula, as such:
Code:
TimerConst = 65536 - TimerConst + (8/T1PS) ; final reload value
Since it's not likely the prescaler will need to be above 1:8, the 8/T1PS shouldn’t get too low.
Thanks again for your great work and inspiring examples,
Steve
Bookmarks