I am working on a project using the following components:
Board: nRF52833
PCA 10100
SDK: 16.0.0
SoftDevice: s140 7.0.1
When NVIC_SystemReset is called the device appears to go through multiple resets. This is apparent from logging output. There is no consistent point in the code where the reset occurs and no error handling function is triggered, as far as I can tell in the debugger (SES). After anywhere from 2 to 10 resets the device enters its normal operating mode and everything appears to work correctly.
Just prior to reset we call these functions:
sd_ble_gap_scan_stop();
sd_ble_gap_adv_stop(p_adv->adv_handle);
nrf_sdh_disable_request();
NVIC_SystemReset();
I have tried commenting out the setup code and slowly adding back parts until I see the problem again. The problem did not appear until I added back our setup code for ble and the softdevice.
I have found that if I add a 10 second nrf delay call right at the beginning of the main function the problem does not occur. Working further into the setup code I've found that there is a specific point in the code where I can add an 8 second delay call and the problem does occur. If I place the call just before that point the problem does not occur. I've commented on the places in the code where I tested the delay call.
Here is the function:
void clip_ble_stack_init(void)
{
ret_code_t err_code;
//nrf_delay_ms(8000); // Never had multiple resets in 10 tests.
err_code = nrf_sdh_enable_request();
APP_ERROR_CHECK(err_code);
//nrf_delay_ms(8000); // Never had multiple resets in 10+ tests.
// Configure the BLE stack using the default settings.
// Fetch the start address of the application RAM.
uint32_t ram_start = 0;
err_code = nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &ram_start);
APP_ERROR_CHECK(err_code);
//nrf_delay_ms(8000); // Had occasional multiple resets when delay called here.
// Enable BLE stack.
err_code = nrf_sdh_ble_enable(&ram_start);
APP_ERROR_CHECK(err_code);
//nrf_delay_ms(8000); // Had occasional multiple resets when delay called here.
// Register a handler for BLE events.
NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, clip_ble_evt_handler, NULL);
//nrf_delay_ms(8000); // Had occasional multiple resets when delay called here.
}
So the problem seems to occur when I wasn't waiting before nrf_sdh_ble_default_cfg_set() which is the first ble related function we call in setup.
This makes me think there is a problem with our ble configuration or perhaps something is not being shutdown correctly before the system reset call.
I hope there are enough clues here.
I specifically want to know how I can prevent multiple resets from occurring as it makes the restart process take longer.
Thanks!