2000 Microchip Technology Inc.
Advanced Information
DS30475A-page 225
PIC18CXX8
17.13
CAN Interrupts
The module has several sources of interrupts. Each of
these interrupts can be individually enabled or dis-
abled. The CANINTF register contains interrupt flags.
The CANINTE register contains the enables for the 8
main interrupts. A special set of read only bits in the
CANSTAT register (ICODE bits) can be used in combi-
nation with a jump table for efficient handling of inter-
rupts.
All interrupts have one source, with the exception of the
Error Interrupt. Any of the Error Interrupt sources can
set the Error Interrupt Flag. The source of the Error
Interrupt can be determined by reading the Communi-
cation Status register COMSTAT.
The interrupts can be broken up into two categories:
receive and transmit interrupts.
The receive related interrupts are:
Receive Interrupts
Wake-up Interrupt
Receiver Overrun Interrupt
Receiver Warning Interrupt
Receiver Error Passive Interrupt
The Transmit related interrupts are
Transmit Interrupts
Transmitter Warning Interrupt
Transmitter Error Passive Interrupt
Bus Off Interrupt
17.13.1 INTERRUPT CODE BITS
The source of a pending interrupt is indicated in the
ICODE (interrupt code) bits. Interrupts are internally
prioritized, such that the lower the ICODE value, the
higher the interrupt priority. Once the highest priority
interrupt condition has been cleared, the code for the
next highest priority interrupt that is pending (if any),
Note that only those interrupt sources that have their
associated CANINTE enable bit set will be reflected in
the ICODE bits.
TABLE 17-3:
ICODE<2:0> DECODE
17.13.2 TRANSMIT INTERRUPT
When the Transmit Interrupt is enabled, an interrupt will
be generated when the associated transmit buffer
becomes empty and is ready to be loaded with a new
message. The TXBnIF bit will be set to indicate the
source of the interrupt. The interrupt is cleared by the
MCU resetting the TXBnIF bit to a ‘0’.
17.13.3 RECEIVE INTERRUPT
When the Receive Interrupt is enabled, an interrupt will
be generated when a message has been successfully
received and loaded into the associated receive buffer.
This interrupt is activated immediately after receiving the
EOF field. The RXBnIF bit will be set to indicate the
source of the interrupt. The interrupt is cleared by the
MCU resetting the RXBnIF bit to a ‘0’.
17.13.4 MESSAGE ERROR INTERRUPT
When an error occurs during transmission or reception
of a message, the message error flag IRXIF will be set
and, if the IRXIE bit is set, an interrupt will be gener-
ated. This is intended to be used to facilitate baud rate
determination when used in conjunction with Listen
Only mode.
17.13.5 BUS ACTIVITY WAKE-UP INTERRUPT
When the PIC18CXX8 is in SLEEP mode and the bus
activity wake-up interrupt is enabled, an interrupt will be
generated, and the WAKIF bit will be set, when activity
is detected on the CAN bus. This interrupt causes the
PIC18CXX8 to exit SLEEP mode. The interrupt is reset
by the MCU clearing the WAKIF bit.
ICODE<2:0>
Boolean Expression
000
ERRWAKTX0TX1TX2RX0RX1
001
ERR
010
ERRWAK
011
ERRWAKTX0
100
ERRWAKTX0TX1
101
ERRWAKTX0TX1TX2
110
ERRWAKTX0TX1TX2RX0
111
ERRWAKTX0TX1TX2RX0RX1