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

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.

  • 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?

  • 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.

  • 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();

    and then add following lines around line 1045:

    // Activate deep sleep mode.
    for (volatile uint32_t i=0; i<1000000; i++);
    // Configure and initialize the BLE stack.

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