Using both watchdog and timer0.

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Using both watchdog and timer0.

Post 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. :)
Martin

User avatar
Steve
Matrix Staff
Posts: 3434
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times

Re: Using both watchdog and timer0.

Post by Steve »

You seem to be right. I suppose the best way to find out is to actually try it...

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Using both watchdog and timer0.

Post 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
Martin

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Using both watchdog and timer0.

Post 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?
Martin

Post Reply