This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

stuck in softdevice_handler_init

Hello,

I was working on a nRF51422 and made a project using the example ble_app_uart_c. It works fine on the DK, but now I want to make it work on a board that has one nRF51822. I can program it, but when it runs it get stuck on the function SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL); that is inside ble_stack_init().

Can anyone help me to debug it, or have any idea why it is stuck on that function?

Using SD130 v2, SDK11 and nRF51822.

Thanks, Jorge

EDIT1: Saw in on post of old SDK that the problem could be because I was initializing the UART before the BLE. Changed the order of the initialization but still gets stuck on the same function.

EDIT2: I got this on the call stack. I'm still stuck on there, the program doesn't get out from the SOFTDEVICE_HANDLER_INIT funtion. but now is not giving me the error that gave before...

Debug image

EDIT3: This are the two images I get, before and after the stop

before

before_stop

and after

after_stop

Parents Reply Children
  • Isn't the external LF crystal on the DK of 32MHz also (nrf51 RM - chpt 13 - page 52)? If I then change to the external HF crystal of 32MHz, present on my chip, what should I change? I didn't understand very well your answer. I tried to change the source of the clock to the Synth one doing this:

    nrf_clock_lf_cfg_t clock_lf_cfg =  { .source = NRF_CLOCK_LF_SRC_SYNTH,
                                                       .rc_ctiv = 0, 
                                                       .rc_temp_ctiv = 0, 
                                   };
    

    Don't know if I need to change the values of the rc_ctiv and rc_temp_ctiv.

  • The LF clock source can either be from an external 32.768 Khz crystal, the internal RC or synthesized from HFCLK. Recommend reading the answer from Stefan in this thread, but note that the enum is replaced with nrf_clock_lf_cfg_t structure in s13x v.2.0.0 API (see SD migration doc).

  • I have a 32MHz external crystal but is connected to the XC1 and XC2 pins and I can't change the pins. So from what I understand I can't use it by selecting the external clock ( nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;), but can use it by selecting the synthesized clock?

    The errors I got now are:

    • selecting the external clock my chip stays in the softdevice_handler_init waiting to get a signal from the crystal. (I guess I have this error because I don't have a crystal connected to the XL1 and XL2)

    • selecting the internal RC oscillator the chip passes the softdevice_handler_init but then resets when it gets to the err_code = softdevice_enable(&ble_enable_params);

    I don't know if it's easier if I convert this to a new question and Thanks for the help

  • XC1 and XC2 are connected to the high frequency crystal (16/32MHz) and is required when using the radio (requested automatically). The LF crystal is optional and can be connected to XL1 and XL2.

  • A new question would probably have made the thread more clear. In any case, the low power LF clock and HF clock are two separate clock sources, and both required to run any BLE example.

    It's only possible to configure the LF source in softdevice_handler_init(), and the internal RC oscillator is recommended if there is no LF crystal connected.

    The softdevice will be stuck in an endless loop (softdevice_handler_init) waiting for the ext. LF crystal to start if selected but not present.

    What's the error code returned from softdevice_enable()?

Related