Information

© 2009 Microchip Technology Inc. DS80478A-page 5
PIC18F2455/2550/4455/4550
4. Module: Interrupts
If an interrupt occurs during a two-cycle instruc-
tion that modifies the STATUS, BSR or WREG
register, the unmodified value of the register will
be saved to the corresponding Fast Return
(Shadow) register and upon a fast return from the
interrupt, the unmodified value will be restored to
the STATUS, BSR or WREG register.
For example, if a high-priority interrupt occurs
during the instruction, “MOVFF TEMP, WREG”,
the MOVFF instruction will be completed and
WREG will be loaded with the value of TEMP
before branching to ISR. However, the previous
value of WREG will be saved to the Fast Return
register during ISR branching. Upon return from
the interrupt with a fast return, the previous value
of WREG in the Fast Return register will be
written to WREG.
This results in WREG containing the value it had
before execution of “MOVFF TEMP, WREG“.
Affected instructions are:
Work around
Alternative work arounds are available for the
Assembly Language Programming and the C
Programming Language:
Assembly Language Programming
Either of two work arounds can be used:
If any two-cycle instruction is used to modify
the WREG, BSR or STATUS register, do not
use the RETFIE FAST instruction to return
from the interrupt. Instead, save/restore
WREG, BSR and STATUS via software per
Example 9-1 in the Device Data Sheet.
Alternatively, in the case of MOVFF, use the
MOVF instruction to write to WREG instead.
For example, use:
As another alternative, use the work around
shown in Example 1. This example overwrites
the Fast Return register by making a
dummy call to Foo with the fast option in the
high-priority service routine.
EXAMPLE 1: INTERRUPT WORK AROUND – ASSEMBLY
MOVFF Fs, Fd
Where Fd is WREG, BSR or STATUS
MOVSF Zs, Fd
Where Fd is WREG, BSR or STATUS
MOVSS [Zs], [Zd]
Where the destination is WREG, BSR or
STATUS
MOVF TEMP, W
MOVWF BSR
instead of: MOVFF TEMP, BSR.
ISR @ 0x0008
CALL Foo, FAST; store current value of WREG, BSR, STATUS for a second time
Foo:
POP ; clears return address of Foo call
: ; insert high priority ISR code here
:
RETFIEFAST