This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How to acknowledge/clear active interrupt in Cortex-M4

Hi all,

I'm testing interrupt on a Cortex-M4 based platform. So far I have managed to get my interrupt handler called. It clears the interrupt source coming from the peripheral. But before the pin to NVIC is de-asserted, the handler is called again. At this point I can see that NVIC_ISPR0(interrupt pending register) is 0, but the corresponding bit in NVIC_IABR0(interrupt active register) is set. The handler is called a couple of times more, and after that the pin to NVIC is de-asserted and I can see NVIC_IABR0 is 0 now.

Do I have to manually clear NVIC_IABR0 inside my handler? I think it is a read-only register.

Is there any other way to "acknowledge" this interrupt and tell CPU that I have services it(like reading IACK reg in Cortex A-53)?

Thanks a lot for your help. Please excuse if the question sounds too trivial.

Parents
  • Hello deepakj,


    by the way, why do you use IABR?

    I think you had better use ISPR rather than IABR because Cortex-M0 and Cortex-M0+ don't include it.

    Regarding your confirmation, I think as the following.

    - ISR gets called when IABR bit is set by an incoming enabled interrupt.

    Yes.

    But I think that first of all ISPR or ICPR is set and the results will reflect to IABR.

    - On entry into ISR, ISPR is 0 and IABR bit is set.

    Yes.

    - In ISR, I clear the interrupt source in peripheral.

    Yes, of course.

    - Should I clear, ISPR after this? It is already 0 at this point.

    Probably ISPR is a typo of ICPR.

    If it is so, yes.

    But, If IABR is 0, you need not to write ICPR.

    However, you had better check IABR (or ISPR) before exiting the ISR.

    And then, IABR (or ISPR) is not 0, you should write ICPR.

    At this time, you had better clear interrupts because the effect of ICPR will be delayed.

    For example,

    while(ISPR !=0){

      clear the interrupt source (if it occurs periodically) and

      wrire ICPR.

    }

    If there is no possibility IABR or ISPR is not 0 at the exit point of the ISR, my suggestion can be ignored.

    Your original question is "But before the pin to NVIC is de-asserted, the handler is called again".

    Maybe my answer was misdirected.

    To solve the original question, it would be rather difficult.

    To do so, I think there is no way other than to write ICPR until the ISR will not be called.

    The basic background is the same as my answer above.

    Best regards,

    Yasuhiko Koumoto.

Reply
  • Hello deepakj,


    by the way, why do you use IABR?

    I think you had better use ISPR rather than IABR because Cortex-M0 and Cortex-M0+ don't include it.

    Regarding your confirmation, I think as the following.

    - ISR gets called when IABR bit is set by an incoming enabled interrupt.

    Yes.

    But I think that first of all ISPR or ICPR is set and the results will reflect to IABR.

    - On entry into ISR, ISPR is 0 and IABR bit is set.

    Yes.

    - In ISR, I clear the interrupt source in peripheral.

    Yes, of course.

    - Should I clear, ISPR after this? It is already 0 at this point.

    Probably ISPR is a typo of ICPR.

    If it is so, yes.

    But, If IABR is 0, you need not to write ICPR.

    However, you had better check IABR (or ISPR) before exiting the ISR.

    And then, IABR (or ISPR) is not 0, you should write ICPR.

    At this time, you had better clear interrupts because the effect of ICPR will be delayed.

    For example,

    while(ISPR !=0){

      clear the interrupt source (if it occurs periodically) and

      wrire ICPR.

    }

    If there is no possibility IABR or ISPR is not 0 at the exit point of the ISR, my suggestion can be ignored.

    Your original question is "But before the pin to NVIC is de-asserted, the handler is called again".

    Maybe my answer was misdirected.

    To solve the original question, it would be rather difficult.

    To do so, I think there is no way other than to write ICPR until the ISR will not be called.

    The basic background is the same as my answer above.

    Best regards,

    Yasuhiko Koumoto.

Children
  • Hello,

    this is an additional information according to my experiment of the real board.

    NVIC_IABR seems to hold the active interrupt bits during executing ISR even if  the interrupt source had been cleared in the ISR.

    And NVIC_IABR seems to be cleared the bits of which interrupt source had been already cleared at the exit point of the ISR.

    Best regards,

    Yasuhiko Koumoto.