Datasheet

Table Of Contents
PIC18FXX8
DS41159E-page 204 © 2006 Microchip Technology Inc.
EXAMPLE 19-1: WIN AND ICODE BITS USAGE IN INTERRUPT SERVICE ROUTINE TO ACCESS
TX/RX BUFFERS (CONTINUED)
RXB0Interrupt
BCF PIR3, RXB0IF ; Clear the interrupt flag
GOTO AccessBuffer
AccessBuffer ; This is either TX or RX interrupt
; Copy CANCON.ICODE bits to CANSTAT.WIN bits
MOVF CANCON, W ; Clear CANCON.WIN bits before copying
; new ones.
ANDLW b’11110001’ ; Use previously saved CANCON value to
; make sure same value.
MOVWF CANCON ; Copy masked value back to TempCANCON
MOVF TempCANSTAT, W ; Retrieve ICODE bits
ANDLW b’00001110’ ; Use previously saved CANSTAT value
; to make sure same value.
IORWF CANCON ; Copy ICODE bits to WIN bits.
; Copy the result to actual CANCON
; Access current buffer…
; User code
; Restore CANCON.WIN bits
MOVF CANCON, W ; Preserve current non WIN bits
ANDLW b’11110001’
IORWF TempCANCON, W ; Restore original WIN bits
MOVWF CANCON
; Do not need to restore CANSTAT - it is read-only register.
; Return from interrupt or check for another module interrupt source