The tcDspWatchdog static class is used to manage the MityDSP watchdog timer. This timer may be used to raise an NMI and/or reset the MityDSP if it is allowed to expire. When NMI is enabled, this class installs a handler which calls an optional application-provided callback to perform clean-up, debugging, or other application specific activities.
The application must ensure that the reset() method is always called before the watchdog timer expires to avoid a RST or NMI.
This is a simple example of tcDspWatchdog usage:
{ // Register watchdog NMI callback tcDspWatchdog::register_callback(myWatchdogCallback); // Enable watchdog NMI and RST, with timeouts of 15 sec normally, // and 100 msec following NMI tcDspWatchdog::enable(true, true, 15000, 100); ... while (true) { ... // Application must be designed to reset the watchdog // timer before it expires! tcDspWatchdog::reset(); } } unsigned int nmi_count = 0; void tcMyClass::myWatchdogCallback(void) { // Do application-specific data collection // NOTE: Cannot use DSP/BIOS functions, or most MityDSP library calls // which in turn use DSP/BIOS calls. nmi_count++; tcDspFirmware::write_scratchpad(&nmi_count, 0, 1); return; }