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

sd_softdevice_enable hangs, ends at SVC_Handler

Hello, I'm using the nRF51822_QFAA chip on a custom board, but the layout and parts are the same as on the nRF51822 USB dongle. I tried flashing the Board\pca10001\s110\ble_app_hrs program to my custom board, but the chip wasn't advertising, I tried scanning for devices on my Xperia Z2 tablet with the nRF Master Control Panel, but nothing showed up. I tried flashing the same program to the evaluation kit master board and also the dongle, still no advertising. So I started debugging the chip using Keil uVision 5.11.0.0 and a Segger J-Link Edu, setting a debug LED on when the code reached somewhere. Step-by-step I tracked that the code. The problems start in this function:

    static void ble_stack_init(void)
{
    uint32_t err_code;
    
    // Initialize the SoftDevice handler module.
    SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION, false);
//	  SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_250_PPM, false);
    // Register with the SoftDevice handler module for BLE events.
    err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
    APP_ERROR_CHECK(err_code);
    
    // Register with the SoftDevice handler module for BLE events.
    err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
    APP_ERROR_CHECK(err_code);
}

In ble_stack_init it calls

SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_4000MS_CALIBRATION, false);

Which leads to the file softdevice_handler.c to the method

uint32_t softdevice_handler_init(nrf_clock_lfclksrc_t           clock_source,
                                 void *                         p_evt_buffer,
                                 uint16_t                       evt_buffer_size,
                                 softdevice_evt_schedule_func_t evt_schedule_func)
{
...
    // Initialize SoftDevice.

    err_code = sd_softdevice_enable(clock_source, softdevice_assertion_handler);
...
}

I have also tried running

SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false);

as seen above in the ble_stack_init method and measured the external crystal to run perfectly at 32,7 kHz. Although, a funny thing here also, when I use the XTAL low frequency clock then the external 16 MHz crystal doesn't generate anything anymore, when i swap back to RC then the external 16 MHz crystal starts generating a perfect 15,999...16,000 MHz

Anyway, after it reaches

err_code = sd_softdevice_enable(clock_source, softdevice_assertion_handler);

it hangs in SVC_Handler. At the very beginning it got stuck at a HardFault, but somehow that problem went away and I don't even know how...

Parents
  • I have exactly the same problem, I'm new with this microcontroller, it is really hard difficult getting started in comparison with other MCUs.

    In addition, if I program softDevice with nRFgo Studio, I can't download code from Keil (it appears an error "Error: Flash Download Failed: Cortex-M0"), If I erase the chip and cownload firmware using keil, firmware hangs as described in sd_softdevice_enable function.

    Why Nordic has made the things so difficult for newbies with these MCUs?

    What must be done?

    Best regards

Reply
  • I have exactly the same problem, I'm new with this microcontroller, it is really hard difficult getting started in comparison with other MCUs.

    In addition, if I program softDevice with nRFgo Studio, I can't download code from Keil (it appears an error "Error: Flash Download Failed: Cortex-M0"), If I erase the chip and cownload firmware using keil, firmware hangs as described in sd_softdevice_enable function.

    Why Nordic has made the things so difficult for newbies with these MCUs?

    What must be done?

    Best regards

Children
Related