50.8.2 CAN Controller Interrupt Handling

Interrupts are of two types: message-object related interrupts and system interrupts that handle errors or system-related interrupt sources.

All interrupt sources can be masked by writing the corresponding field in the Interrupt Disable register (CAN_IDR). They can be unmasked by writing to the Interrupt Enable register (CAN_IER). After a power-up reset, all interrupt sources are disabled (masked). The current mask status can be checked by reading the Interrupt Mask register (CAN_IMR).

CAN_SR 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: the CAN module enters the Bus Off state.
    • Error Passive: the CAN module enters Error Passive mode.
    • Error Active mode: the CAN module is neither in Error Passive mode nor in Bus Off mode.
    • Warn Limit: the CAN module is in Error Active mode, but at least one of its error counter value exceeds 96.
    • Wake-up: this interrupt is generated after a wake-up and a bus synchronization.
    • Sleep: this interrupt is generated after a Low-power mode enable once all pending messages in transmission have been sent.
    • Internal Timer Counter Overflow: this interrupt is generInterrupt Disableated when the internal timer rolls over.
    • Timestamp: this interrupt is generated after the reception or the transmission of a start of frame or an end of frame. The value of the internal counter is copied in CAN_TIMESTP.

All interrupts are cleared by clearing the interrupt source except for the internal timer counter overflow interrupt and the timestamp interrupt. These interrupts are cleared by reading CAN_SR.