Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

dynamic switching ptx and prx base on ESB

I have two nrf51 development board. A is PRX, B is PTX.  now B can send payload to A , and A can receive and response it by ACK. But some times A want to send payload to B initiatively, so I want to switch PRX to PTX ,and switch PTX to PRX. How can I switch it dynamicly ?

Parents
  • Hi, my suggestion is that the PTX periodically send a packet, and that the PRX then can send an ACK or an ACK with payload. Then you avoid switching between PTX and PRX.

    The problem with switching is that you don't know if the PTX may still be transmitting waiting for an ACK, if the PRX change to PTX at the same time. 

  • thanks for your reply , I have implement a founction ,and it is works fine .but i'm not sure what side effect will be.

    uint32_t nrf_esb_switch_to_ptx(void)
    {
    if(m_config_local.mode == NRF_ESB_MODE_PTX) return NRF_SUCCESS;
    m_config_local.mode = NRF_ESB_MODE_PTX;
    printf("%s\n",__func__);
    nrf_esb_stop_rx();

    // Clear PPI
    NRF_PPI->CHENCLR = (1 << NRF_ESB_PPI_TIMER_START) |
    (1 << NRF_ESB_PPI_TIMER_STOP) |
    (1 << NRF_ESB_PPI_RX_TIMEOUT) |
    (1 << NRF_ESB_PPI_TX_START);

    m_nrf_esb_mainstate = NRF_ESB_STATE_IDLE;

    reset_fifos();

    memset(m_rx_pipe_info, 0, sizeof(m_rx_pipe_info));
    memset(m_pids, 0, sizeof(m_pids));
    NRF_RADIO->SHORTS = RADIO_SHORTS_READY_START_Enabled << RADIO_SHORTS_READY_START_Pos |
    RADIO_SHORTS_END_DISABLE_Enabled << RADIO_SHORTS_END_DISABLE_Pos;
    NRF_RADIO->TXADDRESS = 0;
    NRF_RADIO->RXADDRESSES = 0;
    NRF_RADIO->TASKS_RXEN = 0;

    return NRF_SUCCESS;
    }

Reply
  • thanks for your reply , I have implement a founction ,and it is works fine .but i'm not sure what side effect will be.

    uint32_t nrf_esb_switch_to_ptx(void)
    {
    if(m_config_local.mode == NRF_ESB_MODE_PTX) return NRF_SUCCESS;
    m_config_local.mode = NRF_ESB_MODE_PTX;
    printf("%s\n",__func__);
    nrf_esb_stop_rx();

    // Clear PPI
    NRF_PPI->CHENCLR = (1 << NRF_ESB_PPI_TIMER_START) |
    (1 << NRF_ESB_PPI_TIMER_STOP) |
    (1 << NRF_ESB_PPI_RX_TIMEOUT) |
    (1 << NRF_ESB_PPI_TX_START);

    m_nrf_esb_mainstate = NRF_ESB_STATE_IDLE;

    reset_fifos();

    memset(m_rx_pipe_info, 0, sizeof(m_rx_pipe_info));
    memset(m_pids, 0, sizeof(m_pids));
    NRF_RADIO->SHORTS = RADIO_SHORTS_READY_START_Enabled << RADIO_SHORTS_READY_START_Pos |
    RADIO_SHORTS_END_DISABLE_Enabled << RADIO_SHORTS_END_DISABLE_Pos;
    NRF_RADIO->TXADDRESS = 0;
    NRF_RADIO->RXADDRESSES = 0;
    NRF_RADIO->TASKS_RXEN = 0;

    return NRF_SUCCESS;
    }

Children
No Data
Related