Hi O. O Life,
The examples/watchdog is actually setting up a task software watchdog timer. This timer is using the BSP tick timer (PIT0) to test whether the task watchdog has expired and not using the on-chip core watchdog module.
The on-chip core watchdog is partially setup in the init_bsp.c file.
Several things need to be added to make the core watchdog operate:
1) create a core watchdog ISR that can implement the software reset operation (RCR register bit 7).
2) initialize the ICR for core watchdog and clear the IMRL bit for the software watchdog (bit 8).
3) register/install the ISR (_int_install_isr())
Hassles:
- once core watchdog is running, system is hard to debug and the timer does not stop when debugger halts processor.
Read RSR register (in Reset Controller Module right after the RCR definition) to check what caused the reset. My code is not doing that.
I've attached my enhanced version of the example/watchdog source code file that sets everything up. I'm running from internal flash and you can monitor the serial port to see the value of "n" being printed. If you wait ~10 seconds the task handle_watchdog_expiry() function gets called.
If you halt in that function on the ___mqx_exit(1); function call, then the core watchdog will time out quickly and once you resume running the system will have reset.
Note that I lowered the core watchdog timeout value in init_bsp.c _bsp_setup_watchdog() as follows:
| MCF5225_SCM_CWCR_CWT(BSP_WATCHDOG_DELAY-2); //DES added -2 to speed testing
Otherwise you would have to halt the debugger and wait about a minute to get the core watchdog to timeout.
Regards,
David