PIC18 cheatsheet

RETFIE

Detailed reference for the RETFIE instruction in PIC18 ISA.

Description

Return from interrupt and re‑enable interrupts.

  • Pops the return address from the stack and loads it into the program counter.
  • Restores the I bit in the STATUS register to 1, allowing further interrupts.
  • Should be used at the end of an interrupt service routine (ISR).
  • No operands are accepted.

Examples

; Basic return from an ISR
RETFIE   ; Pop PC from stack, set I=1
; Return from Timer0 ISR
RETFIE   ; Restore PC and enable interrupts again
; Return after deliberately disabling interrupts
RETFIE   ; I bit restored to 1, execution continues in main code