Exceptions and Interrupts Control
108
SPRUHE8E – October 2012 – Revised November 2019
Copyright © 2012–2019, Texas Instruments Incorporated
System Control and Interrupts
There are three steps that should be followed when clearing bits within the PIEIFR and the PIEIER
registers:
Rule 1:
Never clear a PIEIFR bit by software
An incoming interrupt may be lost while a write or a read-modify-write operation to the PIEIFR register
takes place. To clear a PIEIFR bit, the pending interrupt must be serviced. If you want to clear the PIEIFR
bit without executing the normal service routine, then use the following procedure:
1. Set the EALLOW bit to allow modification to the PIE vector table.
2. Modify the PIE vector table so that the vector for the peripheral's service routine points to a temporary
ISR. This temporary ISR will only perform a return from interrupt (IRET) operation.
3. Enable the interrupt so that the interrupt will be serviced by the temporary ISR.
4. After the temporary interrupt routine is serviced, the PIEIFR bit will be clear
5. Modify the PIE vector table to re-map the peripheral's service routine to the proper service routine.
6. Clear the EALLOW bit.
Rule 2:
Procedure for software-prioritizing interrupts
Use the method found in the device support examples in controlSUITE (literature number SPRCA85).
1. Use the CPU IER register as a global priority and the individual PIEIER registers for group priorities. In
this case the PIEIER register is only modified within an interrupt. In addition, only the PIEIER for the
same group as the interrupt being serviced is modified. This modification is done while the PIEACK bit
holds additional interrupts back from the CPU.
2. Never disable a PIEIER bit for a group when servicing an interrupt from an unrelated group.
Rule 3:
Disabling interrupts using PIEIER
If the PIEIER registers are used to enable and then later disable an interrupt then the procedure described
in
must be followed.
1.5.4.3.2 Procedures for Enabling And Disabling Multiplexed Peripheral Interrupts
The proper procedure for enabling or disabling an interrupt is by using the peripheral interrupt
enable/disable flags. The primary purpose of the PIEIER and CPU IER registers is for software
prioritization of interrupts within the same PIE interrupt group. The software package
C280x C/C++
Header Files and Peripheral Examples in C
(literature number SPRC191) includes an example that
illustrates this method of software prioritizing interrupts. Should bits within the PIEIER registers need to be
cleared outside of this context, one of the following two procedures should be followed. The first method
preserves the associated PIE flag register so that interrupts are not lost. The second method clears the
associated PIE flag register.
Method 1:
Use the PIEIERx register to disable the interrupt and preserve the associated PIEIFRx flags.
To clear bits within a PIEIERx register while preserving the associated flags in the PIEIFRx register, the
following procedure should be followed:
1. Disable global interrupts (INTM = 1).
2. Clear the PIEIERx.y bit to disable the interrupt for a given peripheral. This can be done for one or more
peripherals within the same group.
3. Wait five cycles. This delay is required to be sure that any interrupt that was incoming to the CPU has
been flagged within the CPU IFR register.
4. Clear the CPU IFRx bit for the peripheral group. This is a safe operation on the CPU IFR register.
5. Clear the PIEACKx bit for the peripheral group.
6. Enable global interrupts (INTM = 0).
Method 2:
Use the PIEIERx register to disable the interrupt and clear the associated PIEIFRx flags.
To perform a software reset of a peripheral interrupt and clear the associated flag in the PIEIFRx register
and CPU IFR register, the following procedure should be followed:
1. Disable global interrupts (INTM = 1).
2. Set the EALLOW bit.