Page 1 of 1

Using both watchdog and timer0.

Posted: Fri Apr 16, 2010 11:17 am
by medelec35
There a few posts stating:
Benj wrote:Hello,

You cannot use timer0 and the watchdog timer in your program without switching one or the other off. You can use the timer 1 instead of timer 0 if you wish, this should work fine.
I am a bit confused about that since I’m using 16F737, it states on the data sheet:
15.17 Watchdog Timer (WDT)
For PIC16F7X7 devices, the WDT has been modified
from previous PIC16 devices. The new WDT is code
and functionally backward compatible with previous
PIC16 WDT modules and allows the user to have a
scaler value for the WDT and TMR0 at the same time.

In addition, the WDT time-out value can be extended to
268 seconds, using the prescaler with the postscaler
when the PSA bit is set to ā€˜1’.

15.17.1 WDT OSCILLATOR
The WDT derives its time base from the 31.25 kHz
INTRC; therefore, the accuracy of the 31.25 kHz will be
the same accuracy for the WDT time-out period
Does this mean
1) They both can be used at the same time?

And
2) 1/clockspeed/4/prescaler/256 no longer applies?

I would like to be able to use both, and set the WD timeout for a few seconds. I know it states on data sheet "the WDT has been modified
from previous PIC16 devices. So maybe what Ben says just applies all pic16 pre 16F737. So just checking both are possible.
Thank you. :)

Re: Using both watchdog and timer0.

Posted: Fri Apr 16, 2010 2:00 pm
by Steve
You seem to be right. I suppose the best way to find out is to actually try it...

Re: Using both watchdog and timer0.

Posted: Fri Apr 16, 2010 5:09 pm
by medelec35
Thanks Steve.
I have tried with both watchdog and timer0 before starting this thread. The only issue is I was getting is watchdog time outs every so often (hence reason for starting thread). So I will be configuring so time out is increased, to a few seconds.
Anyway it looks to me like we are both right, but depending on what target device is used

Re: Using both watchdog and timer0.

Posted: Sun Apr 18, 2010 2:03 pm
by medelec35
I am nearly there. The only thing you can't do is use prescaler for both WDT and Timer0. But 16F737 has a seperate WD timer osc, so prescaler is assigned to Timer0 So to increase the timeout I can only set the wdtcon to a maximum value of 0x11 = Prescale rate of 1:8192. This means the watchdog time out = 1/31250 * 8192 = 0.2 seconds. (This apears to be the case)
If I set wdtcon for maximum time out of 2.097 (wdtcon = 0x17;), then WDT seems to be disabled. This is odd since in both cases SWDTEN is set to 1.

Any ideas how I can increase WD time out form 0.2 to 2 seconds please?