Hi All,
I encountered an issue while trying to use both Bluetooth and ESB in the same application.
To clarify upfront: I am not using these protocols in parallel. Also, I’m working with NCS version 3.0.1.
In my application, I primarily use ESB as the main protocol, and only occasionally switch to BLE—mainly for FOTA over BLE.
I found an example on DevZone demonstrating how to integrate both protocols. However, after adapting it to my application, I continuously receive assertion faults from the nrfx_timer module.
Eventually, I discovered that the part of the code responsible for disabling the ESB module doesn't work as I expected.
The function used to disable ESB is:
void esb_disable(void) { esb_ppi_disable_all(); esb_fem_reset(); sys_timer_deinit(); esb_ppi_deinit(); /* Radio ramp-up time to default mode */ nrf_radio_fast_ramp_up_enable_set(NRF_RADIO, false); esb_state = ESB_STATE_IDLE; errata216_off(); esb_initialized = false; reset_fifos(); memset(rx_pipe_info, 0, sizeof(rx_pipe_info)); memset(pids, 0, sizeof(pids)); esb_irq_disable(); }
I believe the esb_irq_disable() function should be called first within this function. Additionally, it seems reasonable to add a folowwing line:
on_radio_disabled = NULL;
If the radio interrupt occurs, while esb_disable is being processed, the timer might be already deinitialized, but the esb module might still attempt to reconfigure it, which leads to an assertion fail. This is exactly what happens in my application.
void esb_disable(void) { on_radio_disabled = NULL; esb_irq_disable(); esb_ppi_disable_all(); esb_fem_reset(); sys_timer_deinit(); esb_ppi_deinit(); /* Radio ramp-up time to default mode */ nrf_radio_fast_ramp_up_enable_set(NRF_RADIO, false); esb_state = ESB_STATE_IDLE; errata216_off(); esb_initialized = false; reset_fifos(); memset(rx_pipe_info, 0, sizeof(rx_pipe_info)); memset(pids, 0, sizeof(pids)); }
What do you think? Are there any other reasons why this function has irq disable at the end?