The watchdog timer is a an onboard timer which when it overflows will cause the processor to reset. The watchdog timer is configured as enabled or disabled in the properties of the PICMICRO. The Watch Dog Timer needs to be enabled because by default it is disabled. The PIC16C7X has two modes of operation with the Watchdog timer. It can cause a reset, or it can cause a wakeup from sleep. Unlike the PIC16C5X, the wakeup from sleep does not cause a reset rather when the processor wakes up and continues operation from the next instruction after the sleep instruction. In this tutorial, both modes of WatchDog timer are demonstrated. On the poweron reset the processor sets PORTB all high then falls asleep. After 18ms it wakes up and resumes at the next instruction which jumps to an infinite iteration loop incrementing PortB every millisecond. With the watchdog prescalar set to 2:1 it takes 36 milliseconds for the watchdog timer to timeout and reset the device starting restarting the loop.
| Filename | Version | Description |
| tut5.pjt | 1.0 | MPLAB Project |
| tut5.asm | 1.0 | Assembler code |
| tut5.hex | 1.0 | Precompiled HEX |
| tut5.lst | 1.0 | Precompiled LST |
| tut5.vbb | 1.0 | Virtual Breadboard simulation |
Open tut5.vbb and press RUN.
|
TRISB/PORTB | |
|
Watchdog Timer | |
|
Watchdog Timer Prescalar | |
|
Watchdog Timer reset on timeout | |
|
Watchdog Timer wakeup from sleep |
Components Used
|
LED8 |