Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

FreeRTOS+WDT+SDK17 problem

I have added WDT to the blinky_freertos sample.

/** add **/
static nrf_drv_wdt_channel_id m_channel_id;

static void wdt_event_handler(void)
{
}
/**********/

int main(void)
{
    ret_code_t err_code;

    /* Initialize clock driver for better time accuracy in FREERTOS */
    err_code = nrf_drv_clock_init();
    APP_ERROR_CHECK(err_code);

    /* Configure LED-pins as outputs */
    bsp_board_init(BSP_INIT_LEDS);

    /* Create task for LED0 blinking with priority set to 2 */
    UNUSED_VARIABLE(xTaskCreate(led_toggle_task_function, "LED0", configMINIMAL_STACK_SIZE + 200, NULL, 2, &led_toggle_task_handle));

    /* Start timer for LED1 blinking */
    led_toggle_timer_handle = xTimerCreate( "LED1", TIMER_PERIOD, pdTRUE, NULL, led_toggle_timer_callback);
    UNUSED_VARIABLE(xTimerStart(led_toggle_timer_handle, 0));

    /* Activate deep sleep mode */
    SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;

/** add **/
    nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG;
    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();
/*********/

	/* Start FreeRTOS scheduler. */
    vTaskStartScheduler();

    while (true)
    {
        /* FreeRTOS should not be here... FreeRTOS goes back to the start of stack
         * in vTaskStartScheduler function. */
    }
}

And I am debugging with SEGGER ozone.

building with SDK17:

If you reset the software in the debugger and start it, the application freezes.
t stops in the following loop.
And RTC1 is not counting up.

*********************************************************************
port_cmsis_systick.c

     /* No SD -  we would just block interrupts globally.
      * BASEPRI cannot be used for that because it would prevent WFE from wake up.
     */
      do{
         __WFE();
      } while (0 == (NVIC->ISPR[0] | NVIC->ISPR[1]));

**********************************************************************
However, after WDT reset, blinky works normally.

I have built the same application with SDK15.
It was perfectly fine.

SDK17 seems to have a problem.

I found a difference with SDK15.

SDK17 nrf_drv_clock.c
*****************************************
nrf_drv_clock_init()
...
    if (nrf_wdt_started())
    {
        m_clock_cb.lfclk_on = true;
    }
*****************************************
If a software reset occurs after WDT is activated, WDT remains activated after the reset. However, LFCLK is stopped.
As a result, the above process does not start LFCLK, so even if RTC1 is started, it will not be counted up.

Parents Reply Children
Related