Hi Guys,
I finally figured out how the constant timer values are calculated for various oscillator speeds in DT’s Elapsed Timer.
For the 20MHz example where the constant is 03B7h, it's the reverse of this:Code:IF OSC == 4 ; Constants for 100hz interrupt from Timer1 TimerConst = 0D8F7h ; Executed at compile time only EndIF If OSC == 8 TimerConst = 0B1E7h EndIF If OSC == 10 TimerConst = 09E5Fh EndIF If OSC == 20 TimerConst = 03CB7h EndIF
FFFFh - 03B7h = C348h (49992 decimal),
49992 + 8 = 50000 (it must take eight instruction cycles to reload the timer)
50000 / 10000 = 5
5 x 4 = 20MHz
I was looking for this:
Code:If OSC == 16 TimerConst = 063C7h EndIF
Apologies if this info is already out there.
Cheers, Art.




Bookmarks