Discussion:
Using MOVFF Within Interrupt Code?
Rob
2018-04-06 02:18:34 UTC
Permalink
Hello List,


  I remember reading somewhere (I think) that it is not advisable to
use "MOVFF" within the interrupt handler code. I don't remember where I
saw that or what the underlying reason behind it was. So is that a valid
suggestion and possibly why if  true? Currently using an 18F47K40 and
assembly.


Thanks,

Rob
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.m
Anthony Nixon
2018-04-06 04:58:26 UTC
Permalink
From 18F47K40 manual - Interrupt section Page 205...
Important: Do not use the MOVFF instruction to modify any of the
interrupt control registers

while any interrupt is enabled. Doing so may cause erratic
microcontroller behaviour.

cheers

Tony
Hello List,
I remember reading somewhere (I think) that it is not advisable to
use "MOVFF" within the interrupt handler code. I don't remember where I
saw that or what the underlying reason behind it was. So is that a valid
suggestion and possibly why if true? Currently using an 18F47K40 and
assembly.
Thanks,
Rob
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
--
http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive
View/change your membership options at
http://mailman.mit.edu/mailman/listinfo/piclist
Christopher Head
2018-04-27 19:35:44 UTC
Permalink
Post by Rob
Hello List,
  I remember reading somewhere (I think) that it is not advisable to
use "MOVFF" within the interrupt handler code. I don't remember where I
saw that or what the underlying reason behind it was. So is that a valid
suggestion and possibly why if  true?
If an interrupt occurs during a two-cycle instruction 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.
--
Christopher Head
Loading...