English
Language : 

PIC18F2585_07 Datasheet, PDF (281/482 Pages) Microchip Technology – Enhanced Flash Microcontrollers with ECAN Technology, 10-Bit A/D and nanoWatt Technology
PIC18F2585/2680/4585/4680
EXAMPLE 23-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
© 2007 Microchip Technology Inc.
Preliminary
DS39625C-page 279