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

RADIO_IRQHandler called twice in quick succession

While investigating my stack corruption issue, I noticed that the RADIO_IRQHandler is always called twice in quick succession:

But the NRF_RADIO->INTENSET register only has the DISABLED interrupt listed as activated., but only within the first call of the RADIO_IRQHandler the DISABLED event was detected. What else could trigger this behaviour?

Parents
  • Okay, I just noticed that this piece of code usually gets called in the first call to RADIO_IRQHandler:

        NRF_RADIO->SHORTS = m_radio_shorts_common;
        update_rf_payload_format(m_config_local.payload_length);
        NRF_RADIO->PACKETPTR = (uint32_t)m_rx_payload_buffer;
        NRF_RADIO->EVENTS_DISABLED = 0;
        NRF_RADIO->TASKS_DISABLE = 1;
    
        while (NRF_RADIO->EVENTS_DISABLED == 0);
    
        NRF_RADIO->EVENTS_DISABLED = 0;
        NRF_RADIO->SHORTS = m_radio_shorts_common | RADIO_SHORTS_DISABLED_TXEN_Msk;
    
        NRF_RADIO->TASKS_RXEN = 1;

    I assume this has to do with the double trigger?

    This code forces the radio to stop if no valid packet has been received, because the SHORTS-configuration would put the RADIO in TX state at this moment.

    So, I assume that the fact, that the radio is disabled again and the events register is cleared results in the Interrupt being pended and the handler being executed immediately after.

    I tried disabling the DISABLED interrupt during this operation and re-enabling it before starting the radio, but to no avail.

    Is there a way to achieve the same behaviour as outlined above (i.e. forcing the readio to stop) without the interrupt being pended?

Reply
  • Okay, I just noticed that this piece of code usually gets called in the first call to RADIO_IRQHandler:

        NRF_RADIO->SHORTS = m_radio_shorts_common;
        update_rf_payload_format(m_config_local.payload_length);
        NRF_RADIO->PACKETPTR = (uint32_t)m_rx_payload_buffer;
        NRF_RADIO->EVENTS_DISABLED = 0;
        NRF_RADIO->TASKS_DISABLE = 1;
    
        while (NRF_RADIO->EVENTS_DISABLED == 0);
    
        NRF_RADIO->EVENTS_DISABLED = 0;
        NRF_RADIO->SHORTS = m_radio_shorts_common | RADIO_SHORTS_DISABLED_TXEN_Msk;
    
        NRF_RADIO->TASKS_RXEN = 1;

    I assume this has to do with the double trigger?

    This code forces the radio to stop if no valid packet has been received, because the SHORTS-configuration would put the RADIO in TX state at this moment.

    So, I assume that the fact, that the radio is disabled again and the events register is cleared results in the Interrupt being pended and the handler being executed immediately after.

    I tried disabling the DISABLED interrupt during this operation and re-enabling it before starting the radio, but to no avail.

    Is there a way to achieve the same behaviour as outlined above (i.e. forcing the readio to stop) without the interrupt being pended?

Children
Related