This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

RTC stops running after soft reset with WDT enabled

I'm using nRF52840, PCA10056, and finding that if WDT is enabled (but not expired), after a soft reset (NVIC_SystemReset, or a debugger reset) the RTC no longer runs.

If the watchdog expires, or there is a hard reset, then RTC works again. Probably also works after system OFF/NFC wake, but I didn't try.

It looks the same as this ticket, but had no resolution:

https://devzone.nordicsemi.com/f/nordic-q-a/14321/wdt-halts-rtc-after-nvic_systemreset

The issue is reproducible with the nRF SDK WDT example (SDK 17.0, examples/peripheral/wdt):

Replace the wdt init and for() loop in main with the following (changes highlighted):

    //Configure WDT.
    nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG;
    config.reload_value = 10000;  // NEW
    err_code = nrf_drv_wdt_init(&config, wdt_event_handler);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_wdt_channel_alloc(&m_channel_id);
    APP_ERROR_CHECK(err_code);
    nrf_drv_wdt_enable();
    err_code = app_timer_create(&m_timer, APP_TIMER_MODE_REPEATED, timer_handler);
    APP_ERROR_CHECK(err_code);
    err_code = app_timer_start(m_timer, APP_TIMER_TICKS(200), NULL);
    APP_ERROR_CHECK(err_code);
    err_code = bsp_buttons_enable();
    APP_ERROR_CHECK(err_code);

    nrf_delay_ms(2000);
    NVIC_SystemReset();

and add the handler:

APP_TIMER_DEF(m_timer);
static void timer_handler(void * p_context)
{
    UNUSED_PARAMETER(p_context);
    static int count = 0;
    if (count < LEDS_NUMBER)
    {
        bsp_board_led_on(count);
        count++;
    }
}

That is, instead of a busy-wait to light the LEDs at boot, they are lit from an app_timer (using RTC).
So behavior should be:
- LEDS light up, 200msec apart
- 2 seconds later, device soft resets (LEDs off)
- Since WDT is preserved on soft reset, process should repeat about 5 times (10 seconds) before WDT expires
Instead, what happens is:
- (after a power cycle)
- LEDs light up
- 2 seconds later, LEDs turn off (from soft reset)
- LEDs stay off for ~8 seconds more, until watchdog expires, then the process starts again
 
That implies that the RTC is not running after soft-reset, but starts working again after watchdog timeout (or power cycle). With a debugger attached, the RTC counter does not show it incrementing (counter displayed in debugger never updates during HALT, but if it is running it will have a non-zero value at break, and it will change while single-stepping).
Disabling the WDT, the LEDs work as expected: turn on incrementally, off after 2 seconds, repeat.
Any ideas? Can Nordic reproduce this behavior?