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

NRF52840 + SDK 13.0.0 (S140): MULTI-ROLE NOT WORKING & IAR COMPILER OPTIMIZATION ISSUES

Hi, I’m using nRF52840 with softdevice s140 and nRF5 SDK v13.0.0 and I’m having some issues regarding the optimization set up for the IAR Compiler (IAR Embedded Workbench v7.70.1). The application that I’m developing works as follows:

Pressing the Button 1 of the nRF52480-Preview-DK the device will work as peripheral, and pressing the Button 2 the device will work as central. The ble_stack_init() function looks like:

void ble_stack_init(void)

{

ret_code_t sErrCode;

ble_cfg_t   sBleCfg;

uint32_t u32RamStart = 0;



nrf_clock_lf_cfg_t clock_lf_cfg = NRF_CLOCK_LFCLKSRC;



// Initialize the SoftDevice handler module.

SOFTDEVICE_HANDLER_INIT(&clock_lf_cfg, NULL);



// Fetch the start address of the application RAM.

sErrCode = softdevice_app_ram_start_get(&u32RamStart);

APP_ERROR_CHECK(sErrCode);



u32RamStart = 536880624;



memset(&sBleCfg, 0, sizeof(sBleCfg));

sBleCfg.gap_cfg.role_count_cfg.periph_role_count  = 1u;

sBleCfg.gap_cfg.role_count_cfg.central_role_count = 1u;

sBleCfg.gap_cfg.role_count_cfg.central_sec_count  = 0u;

sErrCode = sd_ble_cfg_set(BLE_GAP_CFG_ROLE_COUNT, &sBleCfg, u32RamStart);

APP_ERROR_CHECK(sErrCode);



sBleCfg.conn_cfg.params.gap_conn_cfg.conn_count     = 2;

sBleCfg.conn_cfg.params.gap_conn_cfg.event_length   = BLE_GAP_EVENT_LENGTH_DEFAULT;

sBleCfg.conn_cfg.conn_cfg_tag                       = APP_CONN_CFG_TAG;

sErrCode = sd_ble_cfg_set(BLE_CONN_CFG_GAP, &sBleCfg, u32RamStart);

APP_ERROR_CHECK(sErrCode);



// Enable BLE stack.

sErrCode = softdevice_enable(&u32RamStart);

APP_ERROR_CHECK(sErrCode);



// Subscribe for BLE events.

sErrCode = softdevice_ble_evt_handler_set(ble_fnBleEvtDispatch_vo);

APP_ERROR_CHECK(sErrCode);

}

My application is based on the experimental example of experimental_ble_app_blinky. The problem is that when the Optimization is set to HIGH, the program resets the SoC right after BLE advertising or scanning is started so it is impossible to trace back the origin of the error.

Furthermore, if the Optimization is set to NONE, the BLE advertising and scanning seems to work, but the program does not recognize the press of the buttons. It seems that there is a problem with the button library.

Has anyone faced the same kind of problem?

Thank you in advance.

Parents
  • First of all, thanks for your reply Sigurd. And yes, you were right indeed. I had just realized that the linker configuration was the root of the issue because the ram memory start address was not enough for my application configuration. Now buttons and advertising work correctly either with optimization high or none. However, the problem now is that the SoC keeps resetting (due to a "NRF_FAULT_ID_SD_ASSERT"') everytime it tries to start scanning. Any idea what could be happening???

Reply
  • First of all, thanks for your reply Sigurd. And yes, you were right indeed. I had just realized that the linker configuration was the root of the issue because the ram memory start address was not enough for my application configuration. Now buttons and advertising work correctly either with optimization high or none. However, the problem now is that the SoC keeps resetting (due to a "NRF_FAULT_ID_SD_ASSERT"') everytime it tries to start scanning. Any idea what could be happening???

Children
No Data
Related