ESB + BLE integration error

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?

  • Yes, it helps. When the radio is disabled, the esb deinitialization procedure works correctly.

  • Hi,

     

    Thank you for confirming and testing. This is highly appreciated. I believe you have found a bug in our library, which is exactly as you previously described:

    Rote said:
    As you can see, the error is thrown by Timer 2, which is used by the ESB module. This timer has a state of NRFX_DRV_STATE_UNINITIALIZED, which is not allowed and triggers the assertion.

    This state suggests that the timer was disabled by sys_timer_deinit, but before esb_irq_disable was called. The ESB interrupt handler then tries to use the timer, leading to the failure.
    Debugging this issue confirmed my suspicion.

    I will ofcourse follow up on this internally and ensure that the issue is handled for future versions of the SDK. Thank you so much for your cooperation and patience in this matter.

     

    Kind regards,

    Håkon

Related