Searching \ for 'Wachdog timer' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/timers.htm?key=time
Search entire site for: 'Wachdog timer'.

Truncated match.
PICList Thread
'Wachdog timer'
1997\03\20@072352 by Corne Smith

flavicon
face
Hi dudes

I've got a basic question that I still don't understand.

What is the wachdog timer used for ?
I know it is used to reset the PIC,but why ?

Cheers

Corne

1997\03\20@073827 by ags

flavicon
face
Corne Smith said:
> I've got a basic question that I still don't understand.
>
> What is the wachdog timer used for ?
> I know it is used to reset the PIC,but why ?
In case your code goes in the weeds, then the watchdog timer pulls it back
in.
This could be due to noise or perhaps even a bug in your program.  It is a
"safety" precaution.
The theory is that if the watchdog doesn't get reset, then the processor
isn't executing the right code.

Hope this helps,

Alan G. Smith
+---------------------------------------------------------
| Alan G. Smith
| spam_OUTagsTakeThisOuTspampoboxes.com
| http://www.innovatus.com/ags

1997\03\20@075438 by efoc

flavicon
face
Corne Smith wrote:
>
> Hi dudes
>
> I've got a basic question that I still don't understand.
>
> What is the wachdog timer used for ?
> I know it is used to reset the PIC,but why ?
>
> Cheers
>
> Corne


Just in case your code goes pear shaped. if it dont get a "nudge" every
so often then there is a good chance that your appplication has hung or
is running out of control. Under these situations then the WD timer can
be used to reset the CPU to a known state to enable your system to
recover.


--

Cheers Peter ..........

==================================
New Ideas come from those who
didn't know it wasn't possible
==================================

1997\03\20@093004 by mike

flavicon
picon face
In message  <.....s331460e.003KILLspamspam@spam@wpsmtp.avitronics.co.za> PICLISTspamKILLspamMITVMA.MIT.EDU
writes:
> Hi dudes
>
> I've got a basic question that I still don't understand.
>
> What is the wachdog timer used for ?
> I know it is used to reset the PIC,but why ?
>
Corne,

Others have described its main use, but I have used it in the
past time time out serial communication so you are not stuck in
an endless loop.

For example, if another processor is clocking serial data to
a PIC in a manner similar to I2C, you might have code that
looks a bit like:

 movlw .8
 movwf  bitctr

q btfss  porta, 0    ; wait for a high then read the data in
 goto   $-1

 read the databit into a register

 btfsc porta, 0     ; wait for a low before continuing
 goto  $-1


 decfsz bitctr
 goto   q


If, for whatever reason, the other processor sends less than 8
bits, the code would be stuck in an endless loop never leaving this
section of code.

However, if the watchdog is enabled, it will reset the after 18ms
(more with the pre-scaler) and as the PIC allows you to differentiate
between a POR reset and a watchdog reset, you can take appropriate
action.

I hope this helps.

Regards,


Mike Watson

1997\03\20@120747 by Harold Hallikainen

picon face
On Thu, 20 Mar 1997 14:11:39 +0200 Corne Smith
<.....csmithKILLspamspam.....WPSMTP.AVITRONICS.CO.ZA> writes:
>Hi dudes
>
>I've got a basic question that I still don't understand.
>
>What is the wachdog timer used for ?
>I know it is used to reset the PIC,but why ?
>
>Cheers
>
>Corne
>


       I think it's because ALL computers will crash, it's just a
question of how long it will be until they crash.  The watchdog timer
detects the crash and resets the system.  This compares favorably to a
system I put in Kansas ten years or so ago where I had to drive over 100
miles to press the reset at a remote FM transmitter site.  Now,
EVERYHTING I do includes a watchdog!
       Another post asked why the watchdog kept resetting his PIC even
though he had CLRWDT in his code.  It IS important that the CLRWDT be
executed BEFORE the WDT times out.  It's pretty common to put a CLRWDT at
ONE PLACE in the main program loop so if the processor doesn't make it
around to there at least every so often, we assume the thing crashed and
reset it.  If the main loop has a smaller loop inside it that keeps the
main loop from being completed in time, you can get a WDT timeout.  I had
this happen because of loops I put in to allow for A/D settling time.
       Finally, CLRWDT should NOT be put in an interrupt service routine
since sometimes the main program can crash, but interrupts keep running
fine.


Harold

1997\03\20@205344 by John Payson
picon face
>         Finally, CLRWDT should NOT be put in an interrupt service routine
> since sometimes the main program can crash, but interrupts keep running
> fine.

Putting a CLRWDT in an ISR is not necessarily bad, provided that it does
some checking to ensure that the main loop is in fact alive.  For example:

MainLoop:
       bsf     ImOkFlag
       bcf     NotOkFlag

       ...
       goto    MainLoop

Interrupt:
       btfsc   ImOkFlag
        btfss  NotOkFlag
        goto   NoDoggie
       clrwdt
NoDoggie:
       bcf     ImOkFlag
       bsf     NotOkFlag
       ...
       retfie

The two flags may be set in different parts of the code; your interrupt
handler may also do some "faster" watchdogging of its own.  For example, if
your inner loop should run at least once every interrupt, you could do:

Interrupt:
       btfss   ImOkFlag
        goto   Oops
       ...
Oops:
       movlw   0
       option          ; Set minimum watchdog time
       goto    $       ; Wait for watchdog

In this case, you could use a fairly slow timeout on your outer loop and still
tell quickly if your inner loop failed.  Alternatively, you could do something
like:

MainLoop:
       clrf    OopsTime
       ...
       goto    MainLoop

Interrupt:
       ...
       clrwdt
       decfsz  OopsTime
        retfie
       movlw   0
       option
       goto    $

In this case, your interrupt would keep the watchdog happy as long as the
interrupt was running happily, but if the main loop died for 256 interrupt
times the system would restart.

More... (looser matching)
- Last day of these posts
- In 1997 , 1998 only
- Today
- New search...