beautypg.com

Texas Instruments MSC1210 User Manual

Page 181

background image

Watchdog Timer

14-7

Additional MSC1210 Hardware

14.3.3 Resetting the Watchdog Timer

Your program, when operating properly, must reset the watchdog periodically.
You can reset the watchdog as frequently or infrequently as desired, as long
as it is reset more frequently than the watchdog countdown time described
previously.

Your program must reset the watchdog by writing a 1 and then a 0 to the RWDT
bit (WDTCON.5). This notifies the watchdog that your program is still operating
correctly and that the watchdog timer should be reset.

The following code will reset the watchdog timer and notify the MSC1210 that
your program is still executing correctly:

WDTCON |= 0x20; // Set RWDT, other bits unaffected

WDTCON &= ~0x20; // Clear RWDT—watchdog reset

Note:

It is generally a good idea to place the watchdog reset code in the main sec-
tion of your program that is within a rapidly-executing control loop. It is not
advisable to place the code within an interrupt, because the main program
might be stuck in an infinite loop, although the interrupts can still trigger prop-
erly. Placing the watchdog reset code in an interrupt, in these cases, would
tell the MSC1210 that the program is still executing correctly when, in fact,
it is stuck in an infinite loop.