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

Blocking BLE_STACK_HANDLER_INIT

Dear Support Team,

currently I'm working on a custom board which contains the NRF51822_QFAB_A0. I installed the softdevice (not the most recent version, but a version that worked on the development board NRF51822_QFAA).

Now every time I call BLE_STACK_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION, BLE_L2CAP_MTU_DEF, ble_evt_dispatch, true);

the device hangs. What can be the reason for this? (I also tried different other clock sources.)

Thank you and best, Peer.

  • This could happen if your 16MHz crystal is not able to spin up. Try spinning it up directly to check:

    NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_HFCLKSTART = 1;
    while(NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) 
    {
    }
    
    

    (turn on an LED after this code block or something)

  • Thank you! In fact the oscillator was not working well. (A soldering problem.) Thank you agin and best, Peer.

  • Thank you! In fact the oscillator was not working well. (A soldering problem.) Thank you agin and best, Peer.

  • Hi,

    I have a similar issue with a nRF58122 board from China (Xuntong PTR 9048-B). Not sure what to do next.

    I am using the ble_app_hrs sample code which seems to work fine on the Evaluation Kit but fails on this board. I debugged this and the code seems to get stuck. What's next?

    // Initialize the SoftDevice handler module.
    SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false);
    

    More info: the SoC hardware revision is QFAAC0 and I am using the 6.0.0 S110 soft device.

    I also ensured that I wait for both EVENTS_LFCLKSTARTED and EVENTS_LFCLKSTARTED to be set to 1 (BTW, maybe I am missing something but the code mentioned in the previous post starts the HF clock but tests for the LF clock?). This is the code I used:

    NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_HFCLKSTART = 1;
    NRF_CLOCK->TASKS_LFCLKSTART = 1;
    
    while(NRF_CLOCK->EVENTS_HFCLKSTARTED == 0)
    {
    }
    while(NRF_CLOCK->EVENTS_LFCLKSTARTED == 0)
    {
    }
    
  • Hi Adi, you're right that's a typo in the code fragment I had posted, it should have been EVENTS_HFCLKSTARTED as you noticed. From looking at the picture of your board here: http://www.aliexpress.com/store/product/Module-for-iBeacon-Bluetooth-Low-Energy-Wireless-module-NRF51822-32-bit-cortex-M0-256K-flash-Freeshipping/130096_1582777326.html it doesn't look like that board comes with the low frequency crystal, so you should use NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000M instead of NRF_CLOCK_LFCLKSRC_XTAL_20_PPM in the soft device init.

1 2