Application halts on softdevice initialize in ble_stack_handler

I have a custom board that uses the nrf51822. I have been using the sample application ble_app_uart with only one minor change, I use the internal clock (NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION) instead of an external 32.768kHz crystal.

This application works great on the dev kit from Nordic. I can connect it to my iPhone no problem. However if I try to run this on my custom hardware it does not work. I run a debug session on my hardware using keil and J-Link LITE CortexM and find that it appears to halt on the line:

// Initialise SoftDevice
    err_code = sd_softdevice_enable(clock_source, softdevice_assertion_handler);

In the file ble_stack_handler.c

So for some reason the softdevice is not initializing. I have tried this on a few modules, both ones of my design and some designed by others and available commercially. On all of them except the Nordic Dev kit I get this same issue. I am using softdevice: s110_nrf51822_6.0.0_softdevice.hex but have also tried the version that was 6.0.0 alpha as well as 5.2.1. All with the same results.

Does anyone know what it is that I am doing wrong?

Thanks Tanner

  • A solution was sent to me:

    I see you're using the 32Khz calibration clock method (NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION). This calibration method requires the 16MHz oscillator to be running and working.

    From the Ref Manual 2.0 sec 12.1.2 To use the RADIO and the calibration mechanism associated with the 32.768 kHz RC oscillator, the HFCLK must be generated from a HFCLK crystal oscillator.

    This method powers up the 16Mhz external xtal every 4000ms and calibrates the 32K RC osc. So actually you do need the: NRF_CLOCK->TASKS_HFCLKSTART = 1; code somewhere.