The C29x CPU supports an instruction
“ATOMIC.REG #u8” that loads an internal counter (ISTS.ATOMIC COUNTER)
with an 8-bit value. This counter decrements once for each instruction packet
executed. As long as this atomic counter is not zero, an interrupt (RTINT or INT)
cannot enter the CPU pipeline. Hence, this instruction allows the user code to block
interrupts for up to 256 instruction packets.
Restrictions on the use of ATOMIC
instruction:
- The ATOMIC instruction cannot be
in the delay slot of any discontinuity instruction or executed in parallel to a
branch instruction.
- The ATOMIC instruction cannot be
in parallel to any discontinuity instruction.
- Executing ATOMIC instructions
back to back cannot be used to block interrupts beyond the maximum count.
- Executing an ATOMIC instruction
when the ATOMIC count is not zero resets the ATOMIC counter.
- Protected calls and returns reset
the ATOMIC counter.
- The ATOMIC instruction or counter
CANNOT block NMI. Anytime the ISTS.NMIF flag is set (indicating that a NMI event
has been registered), the NMI is taken and the ATOMIC counter is reset.