Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

How is ESB_EVT_IRQHandler started?

Hi

How is the ESB_EVT_IRQHandler started? NVIC_SetPendingIRQ(ESB_EVT_IRQ) ​​is registered with on_radio_disabled(), but I don't know how to be started this handler in the nrf_esb.c code.
I know that using ppi_init() to connect events and tasks between RADIO and NRF_ESB_SYS_TIMER (actually TIMER2). However the vector for ESB_EVT_IRQHandler is SWI0_IRQHandler(SWI0_EGU0_IRQHandler), so I don't find out how to start the ESB_EVT_IRQHandler. please tell me how TIMER2 is involved in starting ESB_EVT_IRQHandler.

Thanks in advance

Yas

  • Hi Yas

    If you search for "NVIC_SetPendingIRQ(ESB_EVT_IRQ);" inside nrf_esb.c you will find several places where this line of code is run. The ESB library will run this code every time an event should be forwarded to the application. 

    You shouldn't have to worry about this, though, the ESB library will forward the different events when needed. 

    Are you trying to make changes to the library?

    Best regards
    Torbjørn

  • Hi Torbjørn

    Thank you for your help every time.

    Are you trying to make changes to the library?

    Not actually.

    I'm just curious and want to understand deeply about the ESB_EVT_IRQHandler behavior.
    Looking at other interrupts in the Nordic library, I supposed that the Handler now works when NVIC_SetPendingIRQ (IRQnumber) is first pending and then NVIC_ClearPendingIRQ (IRQnumber) is issued, or when an external interrupt related to IRQnumber occurs. However, although ESB_EVT_IRQ is Pending as you mentioned, I could not understand how is the Handler actually starts triggered.

    The ESB library will run this code every time an event should be forwarded to the application. 

    I don't understand about that "event" you mentioned.
    Is it NRF_ESB_SYS_TIMER (actually TIMER2)'s event?
    Or, you mean after NVIC_SetPendingIRQ (ESB_EVT_IRQ), even when other ISR is happened, ESB_EVT_IRQHandler is waked up?

    Thanks again,

    Yas

  • Hi Yas

    Yas said:
    I'm just curious and want to understand deeply about the ESB_EVT_IRQHandler behavior.
    Looking at other interrupts in the Nordic library, I supposed that the Handler now works when NVIC_SetPendingIRQ (IRQnumber) is first pending and then NVIC_ClearPendingIRQ (IRQnumber) is issued, or when an external interrupt related to IRQnumber occurs. However, although ESB_EVT_IRQ is Pending as you mentioned, I could not understand how is the Handler actually starts triggered.

    Interrupt handlers are called by the interrupt subsystem in the Cortex M microcontroller, called NVIC (Nested Vector Interrupt Controller). 

    For more information about the NVIC you can refer to ARM's official documentation, or one of various guides online such as this one.

    Essentially interrupt handlers will be caused either by a hardware interrupt, connected to one of the hardware peripherals in the nRF device, or by setting the pending bit high manually in the software. 

    The SWI interrupts are not connected to any hardware peripherals, and can only be set by software. 

     When calling NVIC_SetPendingIRQ (IRQnumber) in the software the interrupt handler will be called as soon as any interrupt of the higher or same priority are finished. 

    If you call NVIC_SetPendingIRQ (IRQnumber) from the main context (not an ISR) the interrupt handler will be called immediately. 

    Yas said:
    I don't understand about that "event" you mentioned.
    Is it NRF_ESB_SYS_TIMER (actually TIMER2)'s event?
    Or, you mean after NVIC_SetPendingIRQ (ESB_EVT_IRQ), even when other ISR is happened, ESB_EVT_IRQHandler is waked up?

    Yes, after NVIC_SetPendingIRQ (ESB_EVT_IRQ) is called the ESB event will run. 

    When NVIC_SetPendingIRQ (ESB_EVT_IRQ) is called from inside the radio ISR then the ESB event handler will only be run after the radio interrupt is finished. 

    Best regards
    Torbjørn

  • Hi Torbjørn

    Thank you for your responce.

    Please tell me alittle more about the mechanism of the ESB_EVT_IRQ.

    When NVIC_SetPendingIRQ (ESB_EVT_IRQ) is called from inside the radio ISR then the ESB event handler will only be run after the radio interrupt is finished. 

    Is what you mentioned described in the Nordic documentation? 

    And what is the "inside the radio ISR" that calls ESB_EVT_IRQ? 

    I cannot find anything inside the RADIO_IRQHander (on_radio_disabled_XX) that is calling ESB_EVT_IRQ.

    Best regards,

    Yas

  • Hi Yas

    Yas said:
    Is what you mentioned described in the Nordic documentation? 

    No, we don't document the ARM Cortex architecture (including the NVIC) in the Nordic documentation. This is documented by ARM directly. 

    Yas said:

    And what is the "inside the radio ISR" that calls ESB_EVT_IRQ? 

    I cannot find anything inside the RADIO_IRQHander (on_radio_disabled_XX) that is calling ESB_EVT_IRQ.

    Are you sure you are looking in the right file?

    I think I can count 6 places in nrf_esb.c (from nRF5 SDK v17.1.0) where NVIC_SetPendingIRQ(ESB_EVT_IRQ); is called from one of the on_radio_disabled_xx functions. 

    It should look something like this:
    https://github.com/nrfconnect/sdk-nrf/blob/main/subsys/esb/esb.c#L746

    Best regards
    Torbjørn

Related