Other Parts Discussed in Thread: HALCOGEN
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:
- An Undefined exception is taken just before an RTI Compare 2 interrupt flag (RTIINTFLAG.INT2) is raised.
- Since IRQs are masked, the Compare 2 interrupt remains pending.
- Before unmasking IRQs, RTIINTFLAG.INT2 is cleared with a write/read operation to ensure flag is properly cleared.
- After the RTI flag clearing operation, the corresponding pending interrupt bit in INTREQ[0] is automatically cleared so the IRQ pending is not taken when unmasking IRQs.
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:
- An SVC exception is taken just before an RTI Compare 2 interrupt flag (RTIINTFLAG.INT2) is raised.
- Since IRQs are masked, the Compare 2 interrupt remains pending.
- Before unmasking IRQs, RTIINTFLAG.INT2 is cleared with a write/read operation to ensure flag is properly cleared.
- After the RTI flag clearing operation, the corresponding pending interrupt bit in INTREQ[0] is not automatically cleared so the pending IRQ is taken when unmasking IRQs.
Case #3 - IRQs are masked following an IRQ:
- An IRQ is taken just before an RTI Compare 2 interrupt flag (RTIINTFLAG.INT2) is raised.
- Since IRQs are masked, the Compare 2 interrupt remains pending.
- Before unmasking IRQs, RTIINTFLAG.INT2 is cleared with a write/read operation to ensure flag is properly cleared.
- After the RTI flag clearing operation, the corresponding pending interrupt bit in INTREQ[0] is not automatically cleared so the pending IRQ is taken when unmasking IRQs.
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).