Best way to dynamically switch channels with an ESB

I am trying to communicate with multiple devices simultaneously using NCS2.8.0 and ESB.
For this reason, I need to switch communication channels quickly.

I understand that in a normal ESB network, channel switching is meaningless.
I have chosen a tricky configuration to avoid packet collisions on the air with multiple hosts.

The nRF52 series cannot change the frequency unless esb_state is switched to ESB_STATE_IDLE once.

esb_stop_rx();
esb_set_rf_channel(0);
esb_start_rx();

Currently I use esb_stop_rx() to switch the ESB to ESB_STATE_IDLE.
This step takes about 180us, which isn't too bad.
But it doesn't seem optimal. Is there a better solution?

Parents
  • Hi Hiroyuki-san

    But it doesn't seem optimal. Is there a better solution?

    Let us look at the code of esb_stop_rx()

    int esb_stop_rx(void)
    {
    	if ((esb_state != ESB_STATE_PRX) && (esb_state != ESB_STATE_PRX_SEND_ACK)) {
    		return -EINVAL;
    	}
    
    	esb_ppi_for_txrx_clear(true, false, fast_switching);
    	esb_fem_reset();
    
    	nrf_radio_shorts_disable(NRF_RADIO, 0xFFFFFFFF);
    	nrf_radio_int_disable(NRF_RADIO, 0xFFFFFFFF);
    
    	on_radio_disabled = NULL;
    
    	nrf_radio_event_clear(NRF_RADIO, NRF_RADIO_EVENT_DISABLED);
    	nrf_radio_task_trigger(NRF_RADIO, NRF_RADIO_TASK_DISABLE);
    
    	while (!nrf_radio_event_check(NRF_RADIO, NRF_RADIO_EVENT_DISABLED)) {
    		/* wait for register to settle */
    	}
    
    	nrf_radio_event_clear(NRF_RADIO, NRF_RADIO_EVENT_DISABLED);
    
    	esb_state = ESB_STATE_IDLE;
    
    	return 0;
    }

    In this the most time consuming things I see are the NRF_RADIO_TASK_DISABLE and esb_fem_reset. 

    I am a bit confused why the FEM calls here are not fenced with a config to see if you have a FEM in your product or not. Are you having FEM in your product? If not, try to optimize the esb initialization and deinitalization to remove fem stuff.

    The other time consuming thing is NRF_RADIO_TASK_DISABLE and from the spec

    tTXDISABLE

    Time between DISABLE task and DISABLED event when the radio was in TX and mode is set to 1Msps

    ..

    6

    us

    So it seems like the 180us only on esb_stop_rx does not add up unless the FEM processing is taking significant of this time.

  • Thank you for your comment.
    As you say, the actual elapsed time was shorter, significantly shorter than 180us.
    Perhaps the measurement method was inappropriate and other processing times were included.

    However, while trying to switch channels, a new question arose.

    First of all, it seems that there are multiple functions that disable ESB.

    esb_suspend()
    esb_stop_rx()
    esb_disable()

    esb_disable() seems inappropriate, but please tell me the difference between these functions and their uses.

  • Those functions are disabling different parts of ESB as ESB start have started many different things, ESB stop needs to stop all those things start in the start. The documentation of these functions can be found here which will explain you the difference between these functions

    esb_suspend()
    esb_stop_rx()
    esb_disable()


Reply Children
No Data
Related