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

nRF51802 goes to hardfault on "sd_softdevice_enable" call

Hello everyone!

I'm trying to bring up project based on nRF51802 at custom board. I know this IC is not supported but there is no options to change it. I have downloaded  nRF5 SDK v12.3.0 and going to use softdevice S130 v2.0.1.

Since SDK has no templates or examples for Segger Embedded Studio, I started project from scratch leaning on examples for IAR. The problem is that device goes to hardfault, actually to some unexpected address and stuck there. Last normally executed instruction lays in softdevice memory region at 0x6B4 address. This happens upon executing "sd_softdevice_enable" function called from "softdevice_handler_init" functione given by SDK API. See pictures below.

Here is some code:

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

//---------------------------------------------------------------------------

static void ble_stack_init(void)
{
    uint32_t err_code;

    nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;

    // Initialize the SoftDevice handler module.
    SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);

    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.
#if (NRF_SD_BLE_API_VERSION == 3)
    ble_enable_params.gatt_enable_params.att_mtu = NRF_BLE_MAX_MTU_SIZE;
#endif
    err_code = softdevice_enable(&ble_enable_params);
    APP_ERROR_CHECK(err_code);

    // 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 System events.
    err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch);
    APP_ERROR_CHECK(err_code);
}


//--------------------------------------------------------------------------------------------

void main(void) 
{
  int i;
  
  ble_stack_init();
  nrf_gpio_cfg_output( 2 );

  for (i = 0; i < 100; i++) {
    printf("Hello World %d!\n", i);
    nrf_gpio_pin_toggle( 2 );
  }
  do {
    i++;
  } while (1);
}

Also I was playing with differ from original clock settings, such as XTAL accuracy and even changed sourse to RC ocsillator. Device behaves in the same way.

Where did I go wrong? Any help will be apreciated.

 nordic-nrf51802.7z

Parents Reply Children
No Data
Related