This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to avoid RF CRC Error with ESB protocal

Protocal:ESB

Devices: 1:central(PTX)  2:peripheral(PRX)

Description:

1、Central transmits data to Peripheral,and then Central receives respond data from Peripheral

2、CRC mode:NRF_ESB_CRC_16BIT

    tx_mode:NRF_ESB_TXMODE_MANUAL

    retransmit_count:0

   selective_auto_ack:false

   protocal:NRF_ESB_PROTOCOL_ESB_DPL

3、When central get the response of the peripheral,the crc error will occur,the code like this,

static void on_radio_disabled_tx_wait_for_ack()
{
    // This marks the completion of a TX_RX sequence (TX with ACK)
	nrf_gpio_pin_set(DATA_SENDING_P2);
	nrf_gpio_pin_clear(DATA_SENDING_P2);

    // Make sure the timer will not deactivate the radio if a packet is received
    NRF_PPI->CHENCLR = (1 << NRF_ESB_PPI_TIMER_START) |
                       (1 << NRF_ESB_PPI_RX_TIMEOUT)  |
                       (1 << NRF_ESB_PPI_TIMER_STOP);

    // If the radio has received a packet and the CRC status is OK
    if (NRF_RADIO->EVENTS_END && (NRF_RADIO->CRCSTATUS != 0))
    {
        NRF_ESB_SYS_TIMER->TASKS_SHUTDOWN = 1;
        NRF_PPI->CHENCLR = (1 << NRF_ESB_PPI_TX_START);
        m_interrupt_flags |= NRF_ESB_INT_TX_SUCCESS_MSK;
        m_last_tx_attempts = m_config_local.retransmit_count - m_retransmits_remaining + 1;

        (void) nrf_esb_skip_tx();

        if (m_config_local.protocol != NRF_ESB_PROTOCOL_ESB && m_rx_payload_buffer[0] > 0)
        {
            if (rx_fifo_push_rfbuf((uint8_t)NRF_RADIO->TXADDRESS, m_rx_payload_buffer[1] >> 1))
            {
                m_interrupt_flags |= NRF_ESB_INT_RX_DATA_RECEIVED_MSK;
            }
        }

        if ((m_tx_fifo.count == 0) || (m_config_local.tx_mode == NRF_ESB_TXMODE_MANUAL))
        {
            m_nrf_esb_mainstate = NRF_ESB_STATE_IDLE;
            NVIC_SetPendingIRQ(ESB_EVT_IRQ);		
        }
        else
        {
            NVIC_SetPendingIRQ(ESB_EVT_IRQ);
            start_tx_transaction();
        }
    }
    else
    {
        if (m_retransmits_remaining-- == 0)
        {
            NRF_ESB_SYS_TIMER->TASKS_SHUTDOWN = 1;
            NRF_PPI->CHENCLR = (1 << NRF_ESB_PPI_TX_START);
            // All retransmits are expended, and the TX operation is suspended
            m_last_tx_attempts = m_config_local.retransmit_count + 1;
            m_interrupt_flags |= NRF_ESB_INT_TX_FAILED_MSK;

            m_nrf_esb_mainstate = NRF_ESB_STATE_IDLE;
            NVIC_SetPendingIRQ(ESB_EVT_IRQ);

			if(NRF_RADIO->CRCSTATUS != 0)
			{
				nrf_gpio_pin_set(DATA_SENDING_P2);
				nrf_gpio_pin_clear(DATA_SENDING_P2);
			}
        }
        else
        {
            // There are still more retransmits left, TX mode should be
            // entered again as soon as the system timer reaches CC[1].
            NRF_RADIO->SHORTS = m_radio_shorts_common | RADIO_SHORTS_DISABLED_RXEN_Msk;
			
			
            update_rf_payload_format(mp_current_payload->length);
            NRF_RADIO->PACKETPTR = (uint32_t)m_tx_payload_buffer;
            on_radio_disabled = on_radio_disabled_tx;
            m_nrf_esb_mainstate = NRF_ESB_STATE_PTX_TX_ACK;
            NRF_ESB_SYS_TIMER->TASKS_START = 1;
            NRF_PPI->CHENSET = (1 << NRF_ESB_PPI_TX_START);
            if (NRF_ESB_SYS_TIMER->EVENTS_COMPARE[1])
            {
                NRF_RADIO->TASKS_TXEN = 1;
            }
        }
    }

}

when the crc error occur,the indication will be shown like this:

" if(NRF_RADIO->CRCSTATUS != 0)
{
nrf_gpio_pin_set(DATA_SENDING_P2);
nrf_gpio_pin_clear(DATA_SENDING_P2);
}" 

4、Is there some way to avoid the CRC error occurred?

Thanks

Parents Reply
  • Hi,

     

    I am not able to reproduce this issue with nrf_esb by setting .retransmit_count=0 and then counting the amount of packets received per second:

    <info> app: TX success 475952, failed 48, failed CRC 2
    

    I'm sending a payload every 500 us.

     

    What is the RF address that you are using?

    If that starts with 0x00/0xFF/0x55/0xAA, or have larger periods of bitwise '0' or '1'; you might get alot of noise-payloads (ie: demodulated noise gives address match).

     

    Kind regards,

    Håkon

Children
Related