UM10208_2
© NXP B.V. 2007. All rights reserved.
User manual
Rev. 02 — 1 June 2007
124 of 362
NXP Semiconductors
UM10208
Chapter 9: LPC2800 Interrupt controller
3. Processing continues for a few cycles due to pipelining.
4. The interrupt occurs, and the interrupt service routine reads the INT_VECTOR
register from the interrupt controller.
A problem arises if the interrupt controller state changes during step 3. For example, the
interrupt that triggered the sequence starting with step 1) may be negated: perhaps the
interrupt was disabled in the code executed in step 3. In this case, the interrupt controller
cannot identify the interrupt that generated the interrupt request, and as a result the
interrupt controller returns zero in the INDEX field of the INT_VECTOR register.
Such situations can be handled in two ways:
1. As far as possible, application code should be written to prevent spurious interrupts
from occurring. This is not 100% possible: for example, glitches on level sensitive
interrupts can cause spurious interrupts.
2. The initial interrupt service routine should re-enable interrupts and dismiss the
interrupt if it reads zero in the INDEX field of the INT_VECTOR0 or INT_VECTOR1
register.
6.1 Case studies on spurious interrupts
If an interrupt is received by the core during execution of an instruction that disables
interrupts, the ARM7 family will still take the interrupt. This occurs for both IRQ and FIQ
interrupts.
For example, consider the following instruction sequence:
MRS r0, cpsr
ORR r0, r0, #I_Bit:OR:F_Bit ;disable IRQ and FIQ interrupts
MSR cpsr_c, r0
If an IRQ interrupt is received during execution of the MSR instruction, then the behavior
will be as follows:
•
The IRQ interrupt is latched.
•
The MSR cpsr, r0 executes to completion setting both the I bit and the F bit in the
CPSR.
•
The IRQ interrupt is taken because the core was committed to taking the interrupt
exception before the I bit was set in the CPSR.
•
The CPSR (with the I bit and F bit set) is moved to the SPSR_IRQ.
This means that the IRQ interrupt service routine is faced with the unusual phenomenon
that an IRQ interrupt has occurred with the I bit in the SPSR set. In the example above,
the F bit will also be set in both the CPSR and SPSR. This means that FIQs are also
disabled upon entry to the IRQ service routine, and will remain so until explicitly
re-enabled. Neither FIQs nor IRQs would be re-enabled automatically by the standard
IRQ return sequence.
Although the example shows both IRQ and FIQ interrupts being disabled, similar behavior
occurs when only one of the two interrupt types is being disabled. The fact that the
processor is interrupted after completion of the MSR instruction which disables IRQs does
not normally cause a problem, since an interrupt arriving just one cycle earlier would be
expected to be taken. When the interrupt routine returns with an instruction like: