English
Language : 

PIC18F26K80-I Datasheet, PDF (397/622 Pages) Microchip Technology – 28/40/44/64-Pin, Enhanced Flash Microcontrollers with ECAN™ and nanoWatt XLP Technology
PIC18F66K80 FAMILY
EXAMPLE 27-2: WIN AND ICODE BITS USAGE IN INTERRUPT SERVICE ROUTINE TO ACCESS
TX/RX BUFFERS (CONTINUED)
ErrorInterrupt
BCF
PIR3, ERRIF
; Clear the interrupt flag
…
; Handle error.
RETFIE
TXB2Interrupt
BCF
PIR3, TXB2IF
; Clear the interrupt flag
GOTO AccessBuffer
TXB1Interrupt
BCF
PIR3, TXB1IF
; Clear the interrupt flag
GOTO AccessBuffer
TXB0Interrupt
BCF
PIR3, TXB0IF
; Clear the interrupt flag
GOTO AccessBuffer
RXB1Interrupt
BCF
PIR3, RXB1IF
; Clear the interrupt flag
GOTO Accessbuffer
RXB0Interrupt
BCF
PIR3, RXB0IF
; Clear the interrupt flag
GOTO AccessBuffer
AccessBuffer
; This is either TX or RX interrupt
; Copy CANSTAT.ICODE bits to CANCON.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
; Retrieve ICODE bits
ANDLW B’00001110’
; Use previously saved CANSTAT value
; to make sure same value.
IORWF TempCANCON
; Copy ICODE bits to WIN bits.
MOVFF TempCANCON, CANCON
; 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
; 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
 2010-2012 Microchip Technology Inc.
DS39977F-page 397