Here is the code example from the 877a data sheet:
Code:
--------
MOVWF W_TEMP ;Copy W to TEMP register
SWAPF STATUS,W ;Swap status to be saved into W
CLRF STATUS ;bank 0, regardless of current bank, Clears IRP,RP1,RP0
MOVWF STATUS_TEMP ;Save status to bank zero STATUS_TEMP register
MOVF PCLATH, W ;Only required if using pages 1, 2 and/or 3
MOVWF PCLATH_TEMP ;Save PCLATH into W
CLRF PCLATH ;Page zero, regardless of current page
:
:(ISR) ;(Insert user code here)
:
MOVF PCLATH_TEMP, W ;Restore PCLATH
MOVWF PCLATH ;Move W into PCLATH
SWAPF STATUS_TEMP,W ;Swap STATUS_TEMP register into W
;(sets bank to original state)
MOVWF STATUS ;Move W into STATUS register
SWAPF W_TEMP,F ;Swap W_TEMP
SWAPF W_TEMP,W ;Swap W_TEMP into W
--------
I guess my question is if I define the following variables at the begining of my PBP code:
Code:
w_temp var byte $20 system
w_temp1 var byte $a0 system ' If device has RAM in bank1
w_temp2 var byte $120 system ' If device has RAM in bank2
w_temp3 var byte $1a0 system ' If device has RAM in bank3
how do I tell if I am in bank 0,1,2,or 3 when the interrupt occurs, so I know what w_temp variable(0,1,2, or3) to save using the following assembly code?
Code:
MOVWF W_TEMP ;Copy W to TEMP register
SWAPF STATUS,W ;Swap status to be saved into W
Thanks again
Bookmarks