PIC Interrupt Context Save and Restore


/ Published in: Assembler
Save to your folder(s)

This code is used to save and restore the context registers of a PIC18F device before executing an interrupt service routine. FSR0 only needs to be saved


Copy this code and paste it in your HTML
  1. ISR:
  2. ; Save processor context
  3. movwf wSave, 0
  4. movff STATUS, statSave
  5. movff BSR, bsrSave
  6.  
  7. ; Save FSR0
  8. movff FSR0L, fsr0lSave
  9. movff FSR0H, fsr0hSave
  10.  
  11. ; Insert code here
  12.  
  13. End_Isr:
  14. ; Restore FSR0
  15. movff fsr0lSave, FSR0L
  16. movff fsr0hSave, FSR0H
  17.  
  18. ; Restore processor context and return
  19. movff bsrSave, BSR
  20. movf wSave, w, 0
  21. movff statSave, STATUS
  22. retfie 0

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.