nRF52832, SDK 14.0.0, SD132 v5
We do not touch the LFCLK, either through the raw IO map or via the nrf_drv_clock() module.
We enable SoftDevice, do a bunch of work, then disable it so we can write to UICR.
We observe SoftDevice hanging as it attempts to shut down LFCLK on its own.
nrf_drv_clock.c: 135
nrf_clock_task_trigger(NRF_CLOCK_TASK_LFCLKSTOP);
while (nrf_clock_lf_is_running())
{}
We observe the CPU never exiting the while loop. When we connect with the debugger, it sometimes continues. We wait for 10-15 seconds before connecting the debugger, so it's been in there for a long time.
Any ideas what would cause this to spin forever?
It turns out that we want to keep LFCLK enabled, so the workaround was to call nrf_drv_clock_lfclk_request() in our timer startup code, after SoftDevice has been fully enabled. That increments the LFCLK reference count, so SoftDevice doesn't try to disable LFCLK during SoftDevice disable.
We do want to understand the issue, though, in case something we're doing wrong or not doing will cause future lockups or unexpected behavior.