As an example:
Timer1 (16 Bit) is used and feed with:
I use an 4MHz resonator.
f_OSC/4 (this is the "normal" countrate für a PIC!)
Presacler: 1/8 (Set in T1CON or so)
Then I get 4.000.000 / 4 = 1.000.000
/ 8 = 125.000 counts per second
So, i can handle up to 0,5 seconds (62500 counts) in this 16-bit-timer.
I load the Timer1 with -62500 (=0BDCh), clear TMR1IF and start TIMER1.
When it reaches 0000, the TMR1IF is set, I will stop TIMER1, count down my WORD-variable in order to build the watchdog-timer, clear the TMR1IF and start TIMER1 again.
If you are using higher speeds, then the numbers must be changed.
It is quick-n-dirty !
PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2
Bookmarks