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

NRF51822 sd_softdevice_enable freeze SDK 12.3 SD130 v2.0.1

My app runs the following code, that is supposed to init the SoftDevice:

nrf_clock_lf_cfg_t clock_lf_cfg = {
.source = NRF_CLOCK_LF_SRC_XTAL,
.xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM,
};

// Initialize the SoftDevice handler module.
SOFTDEVICE_HANDLER_INIT (&clock_lf_cfg, NULL);

Inside the last macro, the call to sd_softdevice_enable() freezes and never returns, nor jumps to the softdevice_fault_handler.

I have already tried executing the following code to successfully ensure that the lfck is running:

bool started = nrf_drv_clock_lfclk_is_running();

NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos);
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
NRF_CLOCK->TASKS_LFCLKSTART = 1;

while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0)
{
// Do nothing.
}
started = nrf_drv_clock_lfclk_is_running();

Yet, sd_softdevice_enable freezes.

Is there anything i can do to get the code up and running?

It only started to freeze on a new board, on another board it worked.

I do sadly not have any technical documentation about the current board, though...

Parents
  • Hi,

    Are you sure the new board supposed to have a 32 KHz LF crystal mounted? As you may have seen from other posts, the Softdevice enable function can get stuck in a loop and never return if you select the wrong clock source or have a bad clock circuit. 

    I suggest to try starting the clock manually like you did, but with the clock source set to xtal. Then see if you get the started event. 

    //NRF_CLOCK->LFCLKSRC = (CLOCK_LFCLKSRC_SRC_RC << CLOCK_LFCLKSRC_SRC_Pos);
    NRF_CLOCK->LFCLKSRC = 1; //XTAL
    NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_LFCLKSTART = 1;
    
    while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0)
    {
    // Do nothing.
    }

  • You are right, that is what i initially wanted to do, but failed through brainless copy-pasting.

    With the XTAL it gets stuck in the loop, indeed.

    I am using this board:

    although in reality it looks like this:

    Is it possible that the difference between the pictures is indeed the missing Crystal?

    Also, using app_timer and System on mode, are there any advantages to an external crystal?

  • Yes, it looks like it only has the footprint for a LF crystal unfortunately.  In that case you need to select the internal RC oscillator when you enable the Softdevice.

Reply Children
Related