NRF52 SDK14.0 sd_softdevice_enable() freezes if nrf_drv_clock_lfclk_request() was called before

mindaugast gravatar image

asked 2017-09-13 13:51:11 +0100

I am using NRF52 SDK14.0 and SoftDevice S132 v5.0.0. Application freezes somewhere in SoftDevice if sd_softdevice_enable() is called after nrf_drv_clock_lfclk_request() was called before. If using a debugger, you can pause while frozen and if you hit run again, the application continues flawlessly. It seems it is stuck in some strange loop inside SoftDevice. If you are not using nrf_drv_clock_lfclk_request() before starting SoftDevice, everything works just fine.

edit retag flag offensive close delete report spam

Comments

I am unable to recreate the behavior you describe on my end. Could you upload your source code (at least the parts you have before the softdevice is enabled) here so I could take a look at it?

Jørn ( 2017-09-14 08:52:53 +0100 )editconvert to answer

OK, I've tried to recreate that on ble_app_hrs_freertos example, but here it worked fine for me too. I can't upload my code, but it is complex code with multiple FreeRTOS tasks. It would be a great help if someone with access to softdevice's S132 v5.0.0 code and disassembly could give me a hint, what is happening than PC counter is at address 0xBA24. Just above it at 0xBA22 there is a WFE instruction, and it seems, that CPU waits for some sort of event here, that is never happening and it freezes there until I pause execution and run the program from that point again. After that, no more problems with application occurs.

Mindaugas Tinteris ( 2017-09-18 08:29:36 +0100 )editconvert to answer

I found a way to reproduce this behavior in ble_app_hrs_freertos example. In file main.c comment everything inside of clock_init(void) function:

static void clock_init(void)
{
    //ret_code_t err_code = nrf_drv_clock_init();
    //APP_ERROR_CHECK(err_code);
}

and then add following lines around line 1045:

// Activate deep sleep mode.
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
nrf_drv_clock_lfclk_request(NULL);
for (volatile uint32_t i=0; i<1000000; i++);
// Configure and initialize the BLE stack.
ble_stack_init();

Compile using GCC and you will see the exact behavior I am facing in my app.

Mindaugas Tinteris ( 2017-09-18 13:01:34 +0100 )editconvert to answer