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
  • Hi,

     

    Usually, CRC errors are quite normal. How many are you seeing?

     

    That being said: the RF address has a huge impact on the amount of "unwanted packets" you receive. Could you ensure that this does not start with 0x55/0xAA and does not contain longer periods of 0xFF/0x00 ?

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

    Note that CRCSTATUS=1 means CRC OK. Do you have a similar routine to test CRCSTATUS==0?

     

    Kind regards,

    Håkon

      

  • Hi ,

    1) Sometimes,the ratio of packet loss almost get at 10%. we can't accept the packet lost rate .

    2)The preambe of the packet is 0x55 or 0xAA,The BASE  address  is set by the DEVICEID,so there will be no longer periods of 0xFF/0x00.

    3)I get a mistake about the CRCSTATUS value,so i add some code to retest.the code like this:

        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->EVENTS_END))
    			{
    				nrf_gpio_pin_set(DATA_SENDING_P2);
    				nrf_gpio_pin_clear(DATA_SENDING_P2);
    				nrf_gpio_pin_set(DATA_SENDING_P2);
    				nrf_gpio_pin_clear(DATA_SENDING_P2);
    			}
    			if(NRF_RADIO->CRCSTATUS == 0)
    			{
    				nrf_gpio_pin_set(DATA_SENDING_P2);
    				nrf_gpio_pin_clear(DATA_SENDING_P2);
    			}
            }
            else

    when the packet loss occured,it runs into "if(!(NRF_RADIO->EVENTS_END))",so the reason of the packet loss is the EVENT_END not occured.

    4)Is there some way to resolve the EVENTS_DISABLED occured but the EVENTS_END not occured

    Best regards,

    Yellan

  • Hi,

    yellan said:
    1) Sometimes,the ratio of packet loss almost get at 10%. we can't accept the packet lost rate .

    This is high. At what range (1 meter, 10 meters?) are you seeing such a loss?

    yellan said:
    2)The preambe of the packet is 0x55 or 0xAA,The BASE  address  is set by the DEVICEID,so there will be no longer periods of 0xFF/0x00.

    Ok, good.

    yellan said:
    3)I get a mistake about the CRCSTATUS value,so i add some code to retest.the code like this:

    You should rather increment a variable that you print or read out every x seconds.  

      

    yellan said:
    4)Is there some way to resolve the EVENTS_DISABLED occured but the EVENTS_END not occured

    The difference is that the device did not finish the sequence (no ACK received for instance). What is your local configuration? Can you share both PRX and PTX setup?

     

    Kind regards,

    Håkon 

Reply
  • Hi,

    yellan said:
    1) Sometimes,the ratio of packet loss almost get at 10%. we can't accept the packet lost rate .

    This is high. At what range (1 meter, 10 meters?) are you seeing such a loss?

    yellan said:
    2)The preambe of the packet is 0x55 or 0xAA,The BASE  address  is set by the DEVICEID,so there will be no longer periods of 0xFF/0x00.

    Ok, good.

    yellan said:
    3)I get a mistake about the CRCSTATUS value,so i add some code to retest.the code like this:

    You should rather increment a variable that you print or read out every x seconds.  

      

    yellan said:
    4)Is there some way to resolve the EVENTS_DISABLED occured but the EVENTS_END not occured

    The difference is that the device did not finish the sequence (no ACK received for instance). What is your local configuration? Can you share both PRX and PTX setup?

     

    Kind regards,

    Håkon 

Children
No Data
Related