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.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/** 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));
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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.