watchdog timer

Status
Not open for further replies.

amindzo

Member
Hi, in my program i have some loops that the program should stock in these loops until something happens, sometimes we have some errors from sensors and the program stock in these loops for a long time. can i use the watchdog timer to reset the program after a certain time? i use picbasic pro and pic16f873a.
 
Just enable WDT in the config reg and then set a pre-scale to suit your application... remember, to put a "clear watchdog" in your program somewhere when its working good to stop it resetting when there is no error.
 
should i enable WDT in that loop and then clear it? because i have a main loop that the program should work in it for a long time. i have two other loops that the program should work in them for maximum two minutes and if it stock in it the program should reset.
 
The problem we have here is the WDT times out much quicker than two minutes even with the largest prescale.. What you'll have to do is set up a local varable and count cycles with each increase of the cycle, kick the dog if you had to kick the dog "X" number of times then a reset is needed... That way you can monitor all loops independently.
 
Yes! Timer 1 with interrupt routine... Just increment the cycle counter if interrupt TM1R fires set a loop return... Good idea.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…