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

Parents
  • 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 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

  • Hi Torbjørn

    Thank you for your continuous advice.
    I might be misunderstanding something fundamental regarding the mechanism in NVIC.

    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. 

    Sure, I know that 6 lines of the NVIC_SetPendingIRQ(ESB_EVT_IRQ) are placed in there.
    I am assuming this is just reserving the ESB_EVT_IRQ to wait for an interrupt because the name is "NVIC_SetPendingIRQ" and it is not "NVIC_ClearPendingIRQ" and not call the ESB_EVT_IRQHander directly, am I wrong?

    Best regards,

    Yas

  • Hi Yas

    Yas said:
    Sure, I know that 6 lines of the NVIC_SetPendingIRQ(ESB_EVT_IRQ) are placed in there.
    I am assuming this is just reserving the ESB_EVT_IRQ to wait for an interrupt because the name is "NVIC_SetPendingIRQ" and it is not "NVIC_ClearPendingIRQ" and not call the ESB_EVT_IRQHander directly, am I wrong?

    Setting the pending flag from software has the exact same effect as when a hardware peripheral triggers an interrupt. It will cause the ESB_EVT_IRQ handler to be called as soon as any higher priority interrupts have finished. 

    In other words these 6 lines will trigger the handler to be called, they are not just configuring the interrupt. 

    This is a software interrupt, which means there is no other way to fire the interrupt than to set the pending flag. 

    NVIC_ClearPendingIRQ is normally not used, since the interrupt handler will clear the pending flag automatically. 

    Best regards
    Torbjørn

  • Hi Torbjørn

    Thank you for your response.

    Setting the pending flag from software has the exact same effect as when a hardware peripheral triggers an interrupt. It will cause the ESB_EVT_IRQ handler to be called as soon as any higher priority interrupts have finished. 

    Thank to you, I'm cleared about that now.
    I can proceed forward. Thank you so much!

    Best regards

    Yas

Reply Children
Related