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

Hardfault at Enabled/Disabled Softdevice

I use SDK16 with softdevice. Some of its features require hard timings. But it causes hardfault sometimes. It happened at function of gcm_init. My source code is as follows. Does anyone know how to solve it? Please help me, thank you.

void ble_tt02_app_stop(void)
{
uint32_t err_code;
// Stop any impending connection parameters update.
err_code = ble_conn_params_stop();
APP_ERROR_CHECK(err_code);
}

void ble_stack_stop(void)
{
uint32_t err_code;
err_code = nrf_sdh_disable_request();
APP_ERROR_CHECK(err_code);
ASSERT(!nrf_sdh_is_enabled());
}

void ble_tt02_app_start(void)
{
gap_params_init();
gatt_init();
buffer_init();
conn_params_init();
db_discovery_init();
peer_manager_init(); // call it twice will case reset, because the function gcm_init will fail
services_init();
advertising_init();
adv_scan_start();
}


void scan_download(void)
{
...
if(ble_enable_flag == true)
{
ble_enable_flag = false;
ble_tt02_app_stop();
ble_stack_stop();
}
...
}


void resume_ble(void)
{
...
if(ble_enable_flag == false)
{
ble_enable_flag = true;
ble_stack_init();
ble_tt02_app_start();
}
...
}


int main(void)
{
...
nrf_mem_init();
ota_timer_init();
power_management_init();
ble_stack_init();
scheduler_init();
scan_init();
ble_tt02_app_start();
timers_start();
...
}

Parents Reply
  • Hi,

    Calling  ble_conn_state_init() before calling peer_manager_init(); It will solve the problem. But it has an app_fault issue at pds_init() when I enable/disable softdevice 6 times. Can I change my code to the following? But at the function of pm_init() also calling the sub-functions of pds_init(), pdb_init(), sm_init(), smd_init(), gcm_init() and gscm_init(). How to modified them? Do you have the example code of enable/disable softdevice? What is the correct method to enable/disable softdevice?

    ret_code_t pds_init()
    {
    ret_code_t ret;
    // Check for re-initialization if debugging.
    //NRF_PM_DEBUG_CHECK(!m_module_initialized);
    if(m_module_initialized)
    return;
    ret = fds_register(fds_evt_handler);
    if (ret != NRF_SUCCESS)
    {
    ...
    }
    }

Children
Related