English
Language : 

PIC18FXX8 Datasheet, PDF (206/402 Pages) Microchip Technology – 28/40-Pin High-Performance, Enhanced Flash Microcontrollers with CAN Module
PIC18FXX8
EXAMPLE 19-1: WIN AND ICODE BITS USAGE IN INTERRUPT SERVICE ROUTINE TO ACCESS
TX/RX BUFFERS (CONTINUED)
RXB0Interrupt
BCF
PIR3, RXB0IF
GOTO AccessBuffer
; Clear the interrupt flag
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
ANDLW b’00001110’
; Retrieve ICODE bits
; 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
ANDLW b’11110001’
IORWF TempCANCON, W
; Preserve current non WIN bits
; 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
DS41159D-page 204
 2004 Microchip Technology Inc.