I have recently discovered a problem that I can't seem to rectify regarding the K61 hardware watchdog. I have enabled the watchdog when the firmware starts up and it seems to be working correctly. However, I am trying to disable the watchdog prior to doing a software initiated reset, the board is somehow resetting where RCM_SRS0 is set to WDOG.
If I disable the code that starts up the watchdog, then the RCM_SRS0 is set to 0 as expected. The main problem I am having with the WD causing the reset is that I have DDR segments that are set to NOCLEAR, but when a WD reset occurs, the DDR is cleared, which is undesirable.
How can I completely disable the watchdog so that it doesn't cause a reset reason of WD after doing a software reset?
Here is a brief snippet of the code that runs prior to the software initiated reset:
// Shutdown watchdog
__DI();
WDOG_UNLOCK = DEFAULT_FIRST_UNLOCK_CODE; //1st unlock code
WDOG_UNLOCK = DEFAULT_SECOND_UNLOCK_CODE; //2nd unlock code
//Disable watchdog
WDOG_STCTRLH &= ~(WDOG_STCTRLH_WDOGEN_MASK;
__EI();
// Perform reset
__DSB();
SCB->AIRCR = (uint32_t)((0x5FAUL << SCB_AIRCR_VECTKEY_Pos) |
(SCB->AIRCR & SCB_AIRCR_PRIGROUP_Msk) |
SCB_AIRCR_SYSRESETREQ_Msk );
__DSB();
for(;;) /* wait until reset */
{
__NOP();
}