TIMERS AND COUNTERS:THE WATCHDOG TIMER

THE WATCHDOG TIMER

A Watchdog Timer is a timer that sets an interrupt that tells us that for some reason the program has hung up or otherwise gone awry. As such it is expected that in a prop- erly written and compiled program the Watchdog Timer will never set an interrupt. This is accomplished by resetting the Watchdog Timer every so often in the program. The compiler inserts these instructions automatically into the program if the Watchdog Timer option is selected. However, setting the option does not guarantee that a pro- gram cannot or will not hang up. Software errors and infinite loops that reset the timer within themselves can still cause hang ups.

The Watchdog Timer is scalable. It shares its scaler with Timer0 on an exclusive basis. Either it uses the scaler, or Timer0 uses it. They cannot both use it at the same time. See the discussion under Timer0 in the data sheet for more information (Chapter 5).

Since PICBASIC PRO assumes that the Watchdog Timer will be run with a 1:128 pre-scaler, unwanted Watchdog Timer resets could occur when you assign the pre-scaler to Timer0. If you change the pre-scaler setting in OPTION_REG, you should disable the Watchdog Timer when programming. The Watchdog Timer enable/disable option is found on the configuration screen of your (hardware) programmer’s software.

Leave a comment

Your email address will not be published. Required fields are marked *