Tool/software:
Hello. I was playing around with the watchdog settings and found out it was not working at all. I've looked through other topics and my watchdog configuration seems to be correct:
Watchdog_init(); Watchdog_Params_init(&wdgParams); wdgParams.callbackFxn = (Watchdog_Callback) wdgCallback; wdgParams.resetMode = Watchdog_RESET_ON; wdgParams.debugStallMode = Watchdog_DEBUG_STALL_ON; wdgHandle = Watchdog_open(CONFIG_WATCHDOG_0, &wdgParams); if (!wdgHandle) { while (1) ; } uint32_t tickValue = Watchdog_convertMsToTicks(wdgHandle, 10000); Watchdog_setReload(wdgHandle, tickValue);
Void wdgCallback(UArg handle) { SysCtrlSystemReset(); }
As far as I understand from the documentation, the watchdog counts to zero on the first, the counter value is reloaded and, on the second countdown to zero, the MCU should restart. However, this seems to have no effect. I put a breakpoint inside the callback and checked the WDT registers using memory view. The registers for the watchdog seem to be correctly set: control register has value 0x07 (NMI, Reset Enabled, Interrupt Enabled), RIS is 0x01 (timeout event occurred) and MIS is 0x01 (timeout event occurred). Even so, the board reset and code restart I was expecting does not happen. If I'm debugging when this happens, I get an error that the debugger disconnects, but it appears to not be a real reset.
I've also read that it is unsafe to call OS APIs in an NMI context, so I tried two other things in the watchdog callback: a while(1) loop and writing to the reset register manually, as done in SysCtrlSystemReset ( HWREGBITW( AON_PMCTL_BASE + AON_PMCTL_O_RESETCTL, AON_PMCTL_RESETCTL_SYSRESET_BITN ) = 1; ). Neither of these work.
I have a two threaded program, one being the zigbee stack and the other being my own thread on which I do sensor measurements and keep an alive led. I can tell that the watchdog does not work because I have an LED that blinks a few times when starting the board and an alive led that blinks every 10 seconds. The boot up led never lights up. I never reset the watchdog, so I would expect the board to reset itself every 10 seconds as configured in the watchdog initialization procedure.
I tried the provided watchdog example and it works as expected, but that is a single threaded program. When activating watchdog0 from sys cfg, does the zigbee stack detect it and clear the watchdog by itself?
For the moment, I want to be able to force a board reset at fixed intervals, but it seems that not clearing the watchdog is not enough. Calling SysCtrlSystemReset using a util_timer also does not work.
How can I force a board reset under certain conditions?