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

SOFTDEVICE_HANDLER_INIT hangs with BLE400 S130 nrf51822

Trying to run S130 V2.0.0 with ble_app_proximity on a BLE400 motherboard. Im getting a hang at the call to SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_SYNTH_250_PPM, NULL);

Ive loaded s130 V2.0.0 with nrfgo and at the same time loaded and run blinky into offset memory space with KEIL ok (all 5 leds strobing after making custom_board.h file).

Ive now loaded the ble_app_proximity (s130 still in situ) and I can get it to run but it hangs (resets?) in the call to ble_stack_init() at the soft device handler.

Ive copied the led calls from blinky into the proximity app so I can turn one led on before the call to SOFTDEVICE_HANDLER_INIT() and another led on after. The second led only comes on if I comment out the SOFTDEVICE_HANDLER_INIT() Ive tried all the enums for the SOFTDEVICE_HANDLER_INIT() SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_RC_250_PPM_TEMP_4000MS_CALIBRATION, false); SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_SYNTH_250_PPM, NULL); SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, NULL); // origional

Ive set target options device to nrf51822_xxAC from 51422 Target IROM1 0x1B000, 0x25000 IRAM1 0x20001F00 0x6100 // size doesn’t seem to matter SDK11, Im using a custom board.h file ive made for the ble400 motherboard which works ok with blinky. in my BLE400.h file : #define NRF_CLOCK_LFCLKSRC NRF_CLOCK_LFCLKSRC_XTAL_20_PPM

Ive also tried adding a clock startup before the softdevice_handler but this still doesn't work.

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

// Wait for the low frequency clock to start
while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0) {}
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;

If I set my second led to turn on directly after the clock startup code it blinks which makes me think it adds a delay but the next call is causing a reset.

Im not a SW engineer (HW) and have come from a more bare metal background so might not understand some debugging complexities (turning leds on is old school I know) so please point me at manuals if required.

Parents
  • Yes, you do need to pass a pointer to a clock_lf_cfg to SOFTDEVICE_HANDLER_INIT. I just got a simple advertising app up on my BLE400, and the init looks like:

    include"boards.h"
    ...
    static void softdevice_init(void)
    {
      uint32_t err_code;
    
    nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;
    
    SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);
    
    // Enable BLE stack.
    ble_enable_params_t ble_enable_params;
    err_code = softdevice_enable_get_default_config(CENTRAL_LINK_COUNT,
                                                    PERIPHERAL_LINK_COUNT,
                                                    &ble_enable_params);
    APP_ERROR_CHECK(err_code);
    
    //Check the ram settings against the used number of links
    CHECK_RAM_START_ADDR(CENTRAL_LINK_COUNT,PERIPHERAL_LINK_COUNT);
    
    // Enable BLE stack.
    err_code = softdevice_enable(&ble_enable_params);
    APP_ERROR_CHECK(err_code);
    return;
    // Subscribe for BLE events.
    err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
    APP_ERROR_CHECK(err_code);
    

    NRF_CLOCK_LFCLKSRC is set in a custom_board.h which boards.h includes from the examples/bsp directory. It looks like:

    #define NRF_CLOCK_LFCLKSRC      {.source        = NRF_CLOCK_LF_SRC_XTAL,            \
                                 .rc_ctiv       = 0,                                \
                                 .rc_temp_ctiv  = 0,                                \
                                 .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_100_PPM}
    

    The other thing I had to deal with was the call to softdevice_enable failing because I didn't have enough RAM reserved. I had to set the linker file as follows to get it to work.

    MEMORY
    {
      FLASH (rx) : ORIGIN = 0x1b000, LENGTH = 0x25000
      RAM (rwx) :  ORIGIN = 0x20002000, LENGTH = 0x6000
    }
    
Reply
  • Yes, you do need to pass a pointer to a clock_lf_cfg to SOFTDEVICE_HANDLER_INIT. I just got a simple advertising app up on my BLE400, and the init looks like:

    include"boards.h"
    ...
    static void softdevice_init(void)
    {
      uint32_t err_code;
    
    nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;
    
    SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);
    
    // Enable BLE stack.
    ble_enable_params_t ble_enable_params;
    err_code = softdevice_enable_get_default_config(CENTRAL_LINK_COUNT,
                                                    PERIPHERAL_LINK_COUNT,
                                                    &ble_enable_params);
    APP_ERROR_CHECK(err_code);
    
    //Check the ram settings against the used number of links
    CHECK_RAM_START_ADDR(CENTRAL_LINK_COUNT,PERIPHERAL_LINK_COUNT);
    
    // Enable BLE stack.
    err_code = softdevice_enable(&ble_enable_params);
    APP_ERROR_CHECK(err_code);
    return;
    // Subscribe for BLE events.
    err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);
    APP_ERROR_CHECK(err_code);
    

    NRF_CLOCK_LFCLKSRC is set in a custom_board.h which boards.h includes from the examples/bsp directory. It looks like:

    #define NRF_CLOCK_LFCLKSRC      {.source        = NRF_CLOCK_LF_SRC_XTAL,            \
                                 .rc_ctiv       = 0,                                \
                                 .rc_temp_ctiv  = 0,                                \
                                 .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_100_PPM}
    

    The other thing I had to deal with was the call to softdevice_enable failing because I didn't have enough RAM reserved. I had to set the linker file as follows to get it to work.

    MEMORY
    {
      FLASH (rx) : ORIGIN = 0x1b000, LENGTH = 0x25000
      RAM (rwx) :  ORIGIN = 0x20002000, LENGTH = 0x6000
    }
    
Children
No Data
Related