Bluetooth and ESB switch

Hi  Q&A

Recently, the Bluetooth communication protocol (nrf52833) was added to the ESB, both can communicate normally, but there is a problem when switching between the two, the procedure is as follows:

static void ble_stack_init(void)
{
   ret_code_t err_code;

  err_code = nrf_sdh_enable_request();
  APP_ERROR_CHECK(err_code);
  ASSERT(nrf_sdh_is_enabled());
  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);
  err_code = nrf_sdh_ble_enable(&ram_start); //nrf_sdh_ble_enable
  APP_ERROR_CHECK(err_code);
  NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);
}

for (;;)
{
 if(running_mode != previous_mode){ 
    previous_mode = running_mode;
 if(running_mode == BLE_MODE) //Bluetooth mode
   {
    NRF_LOG_INFO("BLE mode");
    nrf_drv_clock_lfclk_release(); 
    err_code = nrf_esb_disable(); 
    APP_ERROR_CHECK(err_code);
    ble_stack_init(); 
    ble_hrs_app_start();
    app_sched_resume(); 
    advertising_start(false); 
}
else if(running_mode == PROPRIETARY_MODE) //2.4G mode
  {
    NRF_LOG_INFO("PROPRIETARY mode");
    my_ble_stop_advitising();
    ble_hrs_app_stop();
    ble_stack_stop(); 
    nrf_drv_clock_lfclk_request(NULL); 
    esb_initial(); 

   }
 }

}

When called [nrf_esb_write_payload(&tx_payload)] An error occurred when switching to Bluetooth after communication.

Without invoking it Bluetooth and ESB can be silky switched.

The trace found the error at this point in the nrf_sdh_disable_request() function.

Parents
  • After continuous tracking and debugging, the final findings are as follows:

    Both of these interrupts must close one of the programs for it to run properly, I don't know if this is a minor BUG.

  • The reason might be that your application is not waiting enough or giving enough time for the softdevice to cleanup and disable properly. Disabling radio and stopping the relevant clocks and other things can be time consuming sometimes and if you try to close the BLE (softdevice) and try to switch to ESB without checking if the softdevice is enabled (sd_softdevice_is_enabled) or not can be risky.

    The workaround you used seems to work as might be that the radio registers happened to be the once that were not still cleaned up by the softdevice when you were trying to switch to ESB.

Reply
  • The reason might be that your application is not waiting enough or giving enough time for the softdevice to cleanup and disable properly. Disabling radio and stopping the relevant clocks and other things can be time consuming sometimes and if you try to close the BLE (softdevice) and try to switch to ESB without checking if the softdevice is enabled (sd_softdevice_is_enabled) or not can be risky.

    The workaround you used seems to work as might be that the radio registers happened to be the once that were not still cleaned up by the softdevice when you were trying to switch to ESB.

Children
No Data
Related