This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

nRF52840 802.15.4 De-init hangs in "while (nrf_clock_lf_is_running())" loop at LFCLK stop task.

I have a problem, like this fellow engineer here, but the solution is not applying for me.

 More specifically here our function calls from application is like this:

void nrf_802154_deinit(void) {
    nrf_802154_timer_sched_deinit();
    nrf_802154_timer_coord_uninit();
    nrf_802154_temperature_deinit();
    nrf_802154_rsch_uninit();
    nrf_802154_random_deinit();
    nrf_802154_lp_timer_deinit();
    nrf_802154_clock_deinit();
    nrf_802154_core_deinit();
}

void nrf_802154_clock_deinit(void) {
    nrf_drv_clock_uninit();
}

void nrf_drv_clock_uninit(void) {
    ASSERT(m_clock_cb.module_initialized);
    nrfx_clock_disable();
    nrfx_clock_uninit();
    m_clock_cb.module_initialized = false;
}

void nrfx_clock_uninit(void) {
    NRFX_ASSERT(m_clock_cb.module_initialized);
    nrfx_clock_lfclk_stop();
    nrfx_clock_hfclk_stop();
    m_clock_cb.module_initialized = false;
    NRFX_LOG_INFO("Uninitialized.");
}

void nrfx_clock_lfclk_stop(void) {
    NRFX_ASSERT(m_clock_cb.module_initialized);
    nrf_clock_task_trigger(NRF_CLOCK_TASK_LFCLKSTOP);
    while (nrf_clock_lf_is_running()) {}
}
 

Sure, the problem is Watchdog, Not stopping the LFCLK fix's the situation as below:

 Proposed fix is:

void nrfx_clock_uninit(void) {
    NRFX_ASSERT(m_clock_cb.module_initialized);
#if !NRFX_CHECK(NRFX_WDT_ENABLED)
    // Watchdog is still using the LFCLK,
    // and that's why the while loop will stuck if we call this function.
    nrfx_clock_lfclk_stop();
#endif
    nrfx_clock_hfclk_stop();
    m_clock_cb.module_initialized = false;
    NRFX_LOG_INFO("Uninitialized.");
}
 

I would be happy if Nordic engineers officially confirm my observation, and suggest a way if there is a reliable solution here or proposed fix is good without any side effects.

Parents
  • Hi 

    Is there any particular reason why you want to disable the LF clock? 
    Normally this clock will never be stopped, as it is used as a wakeup source from sleep and to keep track of time. 

    I talked to one of the developers regarding adding this to the nrfx_clock driver, but we have a strict policy not to mix peripherals in a single nrfx driver (nrfx_clock should only access the CLOCK peripheral, nrfx_uarte should only access UARTE and so forth), so this is not something they want to add at an nrfx level. 

    It would probably be better to add a check on the watchdog wherever you call the nrfx_clock_uninit() function. 

    Best regards
    Torbjørn

Reply
  • Hi 

    Is there any particular reason why you want to disable the LF clock? 
    Normally this clock will never be stopped, as it is used as a wakeup source from sleep and to keep track of time. 

    I talked to one of the developers regarding adding this to the nrfx_clock driver, but we have a strict policy not to mix peripherals in a single nrfx driver (nrfx_clock should only access the CLOCK peripheral, nrfx_uarte should only access UARTE and so forth), so this is not something they want to add at an nrfx level. 

    It would probably be better to add a check on the watchdog wherever you call the nrfx_clock_uninit() function. 

    Best regards
    Torbjørn

Children
No Data
Related