2 can controller interrupt handling – Rainbow Electronics AT91CAP9S250A User Manual
Page 697

697
6264A–CAP–21-May-07
AT91CAP9S500A/AT91CAP9S250A
Figure 39-10. Possible Initialization Procedure
39.7.2
CAN Controller Interrupt Handling
There are two different types of interrupts. One type of interrupt is a message-object related
interrupt, the other is a system interrupt that handles errors or system-related interrupt
sources.
All interrupt sources can be masked by writing the corresponding field in the CAN_IDR regis-
ter. They can be unmasked by writing to the CAN_IER register. After a power-up reset, all
interrupt sources are disabled (masked). The current mask status can be checked by reading
the CAN_IMR register.
The CAN_SR register gives all interrupt source states.
The following events may initiate one of the two interrupts:
• Message object interrupt
– Data registers in the mailbox object are available to the application. In Receive
Mode, a new message was received. In Transmit Mode, a message was
transmitted successfully.
– A sent transmission was aborted.
• System interrupts
– Bus-off interrupt: The CAN module enters the bus-off state.
– Error-passive interrupt: The CAN module enters Error Passive Mode.
– Error-active Mode: The CAN module is neither in Error Passive Mode nor in Bus-
off mode.
Errors ?
No
Yes
(ABM == 1 and CANEN == 1)
CANEN = 1 (ABM == 0)
ABM = 0 and CANEN = 0
(CAN_SR or CAN_MSRx)
Change CAN_BR value
End of Initialization
Configure a Mailbox in Reception Mode
Enable CAN Controller Interrupt Line
Enable CAN Controller Clock
(AIC)
(PMC)