3.3.15.1.2 Interrupting a REPEAT Loop
A REPEAT instruction loop can be interrupted at any time.
The state of the RA bit is preserved on the stack during exception processing to enable the user application to execute further REPEAT loops from within any number of nested interrupts. After the SR is stacked, the RA Status bit is cleared to restore normal execution flow within the ISR.
Note: If a
REPEAT
loop has been interrupted, and an
ISR is being processed, the user application must stack the Repeat Count register
(RCOUNT) before it executes another REPEAT
instruction within an ISR.
If a REPEAT
instruction is used within an ISR, the user application
must unstack the RCOUNT register before it executes the RETFIE
instruction.Returning into a REPEAT loop from an ISR using the RETFIE instruction requires no special handling. RETFIE pops the PC, and that becomes the address of the next instruction to be fetched in its F-stage. The RETFIE instruction is "padded" with FNOPs (2), so the target instruction of the RETFIE PFC can execute as normal.