Hi, I am trying to write an ISR in assembly, but when simulating, I am having some errors in proteus. Can someone please have a look into this context saving part of my code and advise me if it is OK? I originally have it for 16f676, but trying to adapt it to 16F690. Thanks
Code:
' RAM Variables are declared here
wsave var byte $70 SYSTEM ' safe for W in all banks
ssave var byte BANK0 SYSTEM ' save STATUS
psave var byte BANK0 SYSTEM ' save PCLATH
fsave var byte BANK0 SYSTEM ' save FSR
ISR:
asm
movwf wsave ; Save WREG
swapf STATUS, W
clrf STATUS ; Point to bank 0
movwf ssave ; Save STATUS
movf FSR,w
movwf fsave ; save FSR
movf PCLATH, W ; Save PCLATH
movwf psave
; get ready to jump within the ISR page
movlw ((INTHAND) >> 8) ; Set PCLATH for jump
movwf PCLATH
.
.
.
.
isr routine
.
.
.
EndInt ; restore the machine state and return from interrupts
movf fsave,w
movwf FSR ; restore FSR
movf psave,w
movwf PCLATH ; restore PCH
swapf ssave,w
movwf STATUS ; restore Status
swapf wsave,f
swapf wsave,w ; restore WREG
retfie
endasm
Bookmarks