Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Write our own Watchdog function..?

Status
Not open for further replies.

MrNobody

New Member
Hi, if my understanding of Watchdog is correct, in normal operation mode, if WDT is not clear, it will reset the PIC. In sleep mode, if WDT is not cleared, it will wake up the PIC from sleep.

If that is the case, then if we use WDT to reset the PIC if it hang, we can't cause the PIC to sleep for a very long time (hours) because the WDT will time out very fast which will wakeup the PIC.

Just wondering, lets say I want the PIC to reset itself (if it hangs) but only wake up the PIC by using interrupt-on-change (not WDT time-out). Is it possible to write my own 'Watchdog' feature? What is the function that will reset the PIC..?
 
Hi,


You can still use the watchdog timer even though it may 'watchdog' time out much
sooner than you really want it to. The trick is to do a quick test to see if the chip
really needs to be 'woken up', and if not, simply go back to sleep.
If you calculate the duty cycle it will come out very very low anyway so you
will still save a huge amount of energy from say batteries.

For example, if the duty cycle comes out to 1 percent and the load when it
wakes up is 5ma, the average current draw is really only 50ua, so the batteries
will last quite a long time with that setup.

Another idea is to incorporate some kind of indicator during the wakeup time
so that the user knows the device is still functioning. A 10ma pulse though an
LED for a very short time period still works out to a very low duty cycle and
still a very light load on the batteries. A human can still see a quick flash so
it tells them it is still turned on and functioning properly.
 
Disable the watch dog timer prior to going to sleep and enable it when you wake.

3v0
For PIC12F615, WDTE (Watchdog Timer Enable) bit is located in CONFIG register. I think I read somewhere in the forum that says that after the code is programmed onto PIC, you can't change the CONFIG register while the PIC is running..? That means that I can't disable Watchdog on the fly right..? I may be wrong..
 
For PIC12F615, WDTE (Watchdog Timer Enable) bit is located in CONFIG register. I think I read somewhere in the forum that says that after the code is programmed onto PIC, you can't change the CONFIG register while the PIC is running..? That means that I can't disable Watchdog on the fly right..? I may be wrong..

Some pics have the ability to turn the WDT on and off in software.

Mike.
 
The WDT can be turned on and off in software if you have a SWDTEN bit but the 12F615 does not have one.

I expect that you will find this bit in processors where the WDT has a dedicated prescaler. Not sure.

The 12F683 and has one.

Yeah I had to look it up. :) I do not do much stuff with the little guys.

3v0
 
Ahh.. now i get it.. Thanks..
By the way, just out of curiosity, is it possible to RESET the PIC programmatically without using WDT..? In C or asm..?
 
Ahh.. now i get it.. Thanks..
By the way, just out of curiosity, is it possible to RESET the PIC programmatically without using WDT..? In C or asm..?

Not on a 16 series chip but you can on an 18 series.

You can of course jump to location zero but this doesn't reset all the registers.

Mike.
 
In general you need a reset instruction to do a reset from software and I do not see where the 12F615 has one. Another way would be to setup some processor condition that would trigger one. But on this chip the only internal way to do a reset is with the WDT.

3v0
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top