radio irq handler is called several times when receiving a packet

Hi,Nordic,

(Device:nrf52840DK,SDK:nRF5_SDK_17.0.2)

I am now modifying the esb_prx code.In the original design,there is only one type of packet,but now i want to conbined the time sync project  to esb,so Rx needs "sync packet" containing counter and timer value.

Now,Tx is sending two types of packet (one is sync packet with header,counter_val and timer_val,and the other is data packet with header and data) and working fine.When Rx receive the packet,it first sees the header and indentifies its type.

In the figure below,Tx(left window) is sending each sync paket one time ,but Rx(right window) prints the same packet info in radio_irq_handler 4 times.I don't know what's happening,plz help,thanks a lot.

Best Regards,Hao.

here is my radio_irq_handler 

void RADIO_IRQHandler() {
  
    if (NRF_RADIO->EVENTS_READY && (NRF_RADIO->INTENSET & RADIO_INTENSET_READY_Msk)) {
      NRF_RADIO->EVENTS_READY = 0;
       //DEBUG_PIN_SET(DEBUGPIN1);
    }

    if (NRF_RADIO->EVENTS_END && (NRF_RADIO->INTENSET & RADIO_INTENSET_END_Msk)) {
       NRF_RADIO->EVENTS_END = 0;
       //DEBUG_PIN_SET(DEBUGPIN2);

      // Call the correct on_radio_end function, depending on the current protocol state
      if (on_radio_end) {
        on_radio_end();
      }
    }

    if (NRF_RADIO->EVENTS_DISABLED && (NRF_RADIO->INTENSET & RADIO_INTENSET_DISABLED_Msk)) {

      NRF_RADIO->EVENTS_DISABLED = 0;
      uint8_t message_id;
      message_id = m_rx_payload_buffer[2];
      switch (message_id){
      case SYNC_PKT:
            {
              bool adjustment_procedure_started;
              sync_pkt_t *p_pkt;
              p_pkt = (sync_pkt_t*)malloc(sizeof(sync_pkt_t));
              p_pkt = (sync_pkt_t*)&m_rx_payload_buffer[2];
              adjustment_procedure_started = sync_timer_offset_compensate(p_pkt);
              NRF_LOG_INFO("timer value %d, counter value %d",p_pkt->timer_val,p_pkt->counter_val);
              NRF_LOG_FLUSH();
              if (adjustment_procedure_started) 
              {
              p_pkt = tx_buf_get();
              }
              clear_events_restart_rx();
              free(p_pkt);
            }
            break;

      case URLLC_DATA_PKT:
            if (on_radio_disabled) 
            {
              on_radio_disabled();
            }
            
            break;
  
      }

    }

  }

here is relative setting

uint32_t nrf_esb_start_rx(void)
{
    VERIFY_TRUE(m_nrf_esb_mainstate == NRF_ESB_STATE_IDLE, NRF_ERROR_BUSY);

    NRF_RADIO->INTENCLR = 0xFFFFFFFF;
    NRF_RADIO->EVENTS_DISABLED = 0;
    on_radio_disabled = on_radio_disabled_rx;

    NRF_RADIO->SHORTS      = m_radio_shorts_common | RADIO_SHORTS_DISABLED_TXEN_Msk;
    NRF_RADIO->INTENSET    = RADIO_INTENSET_DISABLED_Msk;
    m_nrf_esb_mainstate    = NRF_ESB_STATE_PRX;

    NRF_RADIO->RXADDRESSES  = m_esb_addr.rx_pipes_enabled;
    NRF_RADIO->FREQUENCY    = m_esb_addr.rf_channel;
    NRF_RADIO->PACKETPTR    = (uint32_t)m_rx_payload_buffer;

    NVIC_ClearPendingIRQ(RADIO_IRQn);
    NVIC_EnableIRQ(RADIO_IRQn);

    NRF_RADIO->EVENTS_ADDRESS = 0;
    NRF_RADIO->EVENTS_PAYLOAD = 0;
    NRF_RADIO->EVENTS_DISABLED = 0;

    NRF_RADIO->TASKS_RXEN  = 1;

    ppi_radio_rx_configure();

    return NRF_SUCCESS;
}

Related