English
Language : 

PIC18F258 Datasheet, PDF (204/384 Pages) Microchip Technology – High Performance, 28/40-Pin Enhanced FLASH Microcontrollers with CAN
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 TempCANCON, W
; Clear CANCON.WIN bits before copying
; new ones.
ANDLW b’11110001’
; Use previously saved CANCON value to
; make sure same value.
MOVWF TempCANCON
; 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 TempCANCON
MOVFF TempCANCON, 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
; Preserve current non WIN bits
; Restore original WIN bits
; Do not need to restore CANSTAT - it is read-only register.
; Return from interrupt or check for another module interrupt source
DS41159B-page 202
Preliminary
 2002 Microchip Technology Inc.