|
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.
|
▷ |