You can improve the probability of the watchdog biting on a software error by using a technique like this: wdt_flags res 1 WDTF_ISRA = 0 WDTF_ISRB = 1 WDTF_MAINLOOP = 2 WDTF_OTHERPLACE = 3 WDTF_ALLMASK = B'00001111' ; mask of used bits ... at initialization ... clrf wdt_flags .... at the top of the main loop .... bcf wdt_flags, WDTF_MAINLOOP movf wdt_flags,F skpz goto dont_kick_dog movlw WDTF_ALLMASK movwf wdt_flags clrwdt dont_kick_dog: ... somewhere in ISR A ... bcf wdt_flags,WDTF_ISRA ... somewhere in ISR B ... bcf wdt_flags,WDTF_ISRB ... somewhere in some other place ... bcf wdt_flags,WDTF_OTHERPLACE This code ensures that several different code paths are being executed before it will clear the watchdog. Bob Ammerman RAm Systems ----- Original Message ----- From: "Peter L. Peres" To: Sent: Wednesday, April 23, 2003 4:40 AM Subject: [PIC]: WatchDog Timer Routines and Implemenations??? > In a normally programmed and operating cpu the instruction execution order > is well defined and known at all times, together with the time it takes > each segment of code to run. Should something go wrong (glitch etc) then > this order will be changed, and with it the timing. > > A watchdog circuit is a hardware timer that runs down continuously, > regardless of what the cpu is doing, with the exception of a clrwdt > instruction or resetting the watchdog prescaler. If the timer runs down > completely it causes a reset of the cpu and that should allow the cpu to > be reset to a valid state. The amount of time the watchdog takes to run > down is fixed (but settable by the user on a pic). > > So a watchdog timer reset (clrwdt) is best placed in the user's code in a > location where it is executed regularly, with a period just smaller than > the timeout of the watchdog, while the program is running correctly, but > not if its not. Since there is no way to know where the 'right' location > is beforehead, clrwdt should be put in a location that has a low > probability to execute if the code does not work right. This would be a > program segment that is crucial to the function of the code. It is > difficult to determine a general case, the best location depends on the > application. Sometimes more than one clrwdt is used, depending on > execution paths. In any case use as few as possible, this reduces the > likelihood of their being executed when the cpu is operating randomly. > > Peter > > -- > http://www.piclist.com hint: The list server can filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics > -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics