SPRUIE9D May 2017 – May 2024 DRA74P , DRA75P , DRA76P , DRA77P
The global interrupt enable (GIE) bit in the control status register (CSR) allows programmers to enable or disable all maskable interrupts by controlling the value of a single bit. On the ARP32 CPU, programs must directly manipulate the GIE bit in CSR to disable and enable interrupts:
For example, the following code sequence globally enables all maskable interrupts:
MVC CSR, R0 ; Get CSR into R0
SET 0, 0, R0, R0 ; Set R0[0]
MVC R0, CSR ; Copy R0 back to CSR (sets GIE)
Similarly, the following code sequence globally disables all maskable interrupts:
MVC CSR, R0 ; Get CSR into R0
CLR 0, 0, R0, R0 ; Clear R0[0]
MVC R0, CSR ; Copy R0 back to CSR (clears GIE)
As interrupt detection occurs in parallel with CPU execution, the CPU takes an interrupt in the cycle immediately following an MVC instruction that clears the GIE bit. However, CPU context save/restore behavior ensures that interrupts do not occur after subsequent instruction. Consider the following code example where the CPU takes an interrupt between instructions 1 and 2, between instructions 2 and 3, or between instructions 3 and 4. The CPU does not service an interrupt between instructions 4 and 5.
; assume GIE=1
MVC CSR, R0 ;(1) Get CSR
AND -2, R0, R0 ;(2) Get ready to clear GIE
MVC R0, CSR ;(3) Clear GIE
ADD R0, R2, R3 ;(4)
ADD R4, R4, R5 ;(5)
If the CPU services an interrupt between instructions 1 and 2 or between instructions 2 and 3, the SCSR[0]GIE bit holds the value 1 when arriving at the interrupt service routine. If the CPU services an interrupt between instructions 3 and 4, the SCSR[0]GIE bit holds the value 0. Thus, when the interrupt service routine resumes the interrupted code, it resumes with the GIE bit cleared (as a result of context restore of SCSR to CSR) as the interrupted code intended.