This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
We observed different VIM behaviors when clearing pending peripheral IRQs (e.g. RTI Compare 2 interrupt) using the peripheral interrupt flag (e.g. RTIINTFLAG.INT2) while IRQs are masked.
In some cases, clearing the pending interrupt by writing 1 to its peripheral interrupt flag is enough to effectively clear the pending interrupt in the VIM (i.e. clear INTREQ). Namely, this was observed when IRQs become masked due to an Undefined exception:
Case #1 - IRQs are masked following an Undefined exception:
However, in other cases, the peripheral interrupt flag is cleared, but INTREQ is not updated and the pending IRQ is still taken. Two such cases were observed:
Case #2 - IRQs are masked following an SVC exception:
Case #3 - IRQs are masked following an IRQ:
Why does clearing the RTI Interrupt flag also clear the pending interrupt in the VIM in case #1, but not in cases #2 and #3?
Note that in all 3 cases, the RTI Compare 2 Interrupt remains enabled (RTISETINTENA/RTICLEARINTENA.COMP2 = 1).
Hi,
Is it possible that the compare interrupt condition happens again after the flag is "cleared" in cases 2 and 3? In general, it is highly recommended to only clear pending status flags for enabled interrupts from within their dedicated ISRs.
Hi Sunil,
Thank you for your reply. Where in the documentation can I find the recommendation to only clear pending status flags for enabled interrupts from within their dedicated ISRs? And by pending status flag, do you mean the peripheral interrupt flag (e.g. RTIINTFLAG.INT2), the pending interrupt bit in the VIM (e.g. ÎNTREQ0[4]), or both?
Thank you,
Antoine
Hi Antoine,
It is not mandatory to only clear interrupt flags in their own ISRs. Interrupt management is largely left to the application to implement as it wishes.
In cases 2 and 3 above, is it possible for the RTI compare match 2 event to occur between clearing it in the RTI and clearing it in the VIM?
Hi Sunil,
We understood why, in the case #1, the INTREQ register is automatically cleared whereas it is not for cases #2 and #3. To go back to your first reply, no the condition does not occur again. What we observed is that the pending interrupt bit in INTREQ is cleared only in cases where the peripheral interrupt flag (e.g. RTIINTFLAG) is cleared AFTER having read the IRQINDEX. Indeed, in case #1, our code was reading IRQINDEX before clearing the flag, but not in cases #2 and #3.
In our understanding, this is would be the same reason why simply clearing the peripheral interrupt flag is sufficient to clear INTREQ when we are inside the interrupt's handler: in that case the VIM has already read IRQINDEX in order to branch to the handler and so the clearing propagates to the INTREQ status bit.
However, all this behavior is infered from what we observe, there seems to be nothing in the TMS570LC4357 Reference Manual or Datasheet describing this behavior. Could I then ask you to confirm that our understanding reflects the actual behavior of pending interrupts in the VIM i.e. that clearing the peripheral interrupt flags (e.g. RTIINTFLAG) has no effect on pending interrupt status bits in INTREQ registers, unless IRQINDEX has been read prior to the clearing?
Thank you,
Antoine
Hi Antoine,
Yes, it is not sufficient to just clear the pending interrupt flag at the interrupt module source, more so if this clear is done outside of the assigned ISR. There are multiple ways to clear the pending interrupt condition in the VIM:
So if you want to clear an RTI compare match interrupt flag outside of the assigned ISR, you do need to clear it at the RTI plus use method 4 to clear the flag in the VIM.
Regards, Sunil