Detect whether the app is starting after a WDT Reset

Dear Nordic Experts,

Is there any way to detect the the WDT has reset the system. I mean some WDT register from which you could read this information, and that would be valid only when the WDT is not running.

I made a hack to disable my WDT feederon demand, so I can cause the WDT reset to occur, and at the beginning of my app I have added this code : 

if ((NRF_WDT->EVENTS_TIMEOUT & WDT_EVENTS_TIMEOUT_EVENTS_TIMEOUT_Msk) == WDT_EVENTS_TIMEOUT_EVENTS_TIMEOUT_Generated) {
   // On a redémarré sur une échéance du chien
   NRF_LOG_ERROR("REDÉMARRE SUR ÉCHÉANCE CHIEN DE GARDE SYSTÈME !!");
}
NRF_LOG_WARNING("NRF_WDT->CRV = 0x%08X", NRF_WDT->CRV);
NRF_LOG_WARNING("NRF_WDT->RREN = 0x%08X", NRF_WDT->RREN);
NRF_LOG_WARNING("NRF_WDT->CONFIG = 0x%08X", NRF_WDT->CONFIG);

But then in the logger, after the WDT reset, I just get this: 

<info> blah blah blah
<warning> app: NRF_WDT->CRV = 0xFFFFFFFF
<warning> app: NRF_WDT->RREN = 0x00000001
<warning> app: NRF_WDT->CONFIG = 0x00000001
<info> blah blah blah

which is exactly the same as on an usual start.

Using the WDT interrupt handler for setting some persistent register may lose some events, for instance if we have a bootloader that does not configure this interrupt, then we would miss the WDT reset occuring during the bootloader running phase.

Related