
UM10413
All information provided in this document is subject to legal disclaimers.
© NXP B.V. 2011. All rights reserved.
User manual
Rev. 1 — 16 December 2011
31 of 268
NXP Semiconductors
UM10413
MPT612 User manual
entered due to an IRQ being received when executing the MSR instruction which disables
IRQs, then bit I is set in SPSR. The routine therefore assumes that it could not have been
entered via an IRQ.
Problem 2:
FIQs and IRQs are both disabled by the same write to the CPSR. In this case,
if an IRQ is received during the CPSR write, FIQs are disabled for the execution time of
the IRQ handler. This arrangement cannot be acceptable in a system where FIQs must
not be disabled for more than a few cycles.
9.6.2 Workaround
There are 3 suggested workarounds. The one which is most applicable depends upon the
requirements of the particular system.
9.6.3 Solution 1: Test for an IRQ received during a write to disable IRQs
Add code similar to the following at the start of the interrupt routine.
SUB lr, lr, #4 ; Adjust LR to point to return
STMFD sp!, {..., lr} ; Get some free legs
MRS lr, SPSR ; See if we got an interrupt while
TST lr, #I_Bit ; interrupts were disabled.
LDMNEFD sp!, {..., pc}^ ; If so, just return immediately.
; The interrupt remains pending since we have not
; acknowledged it and is reissued when interrupts
; are next enabled.
; Rest of interrupt routine
This code tests for the situation where the IRQ was received during a write to disable
IRQs. If so, the code returns immediately - resulting in the IRQ not being acknowledged
(cleared), and further IRQs being disabled.
In order to resolve the first issue, similar code can also be applied to the FIQ handler.
This method is the recommended workaround, as it overcomes both problems mentioned
previously. However, in the case of problem two, it does add several cycles to the
maximum length of time FIQs are disabled.
9.6.4 Solution 2: Disable IRQs and FIQs using separate writes to the CPSR
MRS r0, cpsr
ORR r0, r0, #I_Bit ;disable IRQs
MSR cpsr_c, r0
ORR r0, r0, #F_Bit ;disable FIQs
MSR cpsr_c, r0
This arrangement is the best workaround where the maximum time for which FIQs are
disabled is critical (it does not increase this time at all). However, it does not solve problem
one, and requires extra instructions at every point where IRQs and FIQs are disabled
together.
9.6.5 Solution 3: Re-enable FIQs at the beginning of the IRQ handler
As the required state of all bits in the CPSR c field are known, this solution is efficiently
achieved by writing an immediate value to CPSR_C, for example: