GD32VF103 User Manual
439
according to the error condition. For detailed information about TECNT and RECNT
management, please refer to the CAN standard.
Both of them may be read by software to determine the stability of the network.
Furthermore, the CAN hardware provides detailed information on the current error status in
CAN_ERR register. By means of the CAN_INTEN register (ERRIE bit, etc.), the software can
configure the interrupt generation on error detection in a very flexible way.
Bus-Off recovery
The Bus-Off state is reached when TECNT is greater than 255. This state is indicated by
BOERR bit in CAN_ERR register. In Bus-Off state, the CAN is no longer able to transmit and
receive messages.
Depending on the ABOR bit in the CAN_CTL register, CAN will recover from Bus-Off
(becomes error active again) either automatically or on software request. But in both cases
the CAN has to wait at least for the recovery sequence specified in the CAN standard (128
occurrences of 11 consecutive recessive bits monitored on CAN RX).
If ABOR is set, the CAN will start the recovering sequence automatically after it has entered
Bus-Off state.
If ABOR is cleared, the software must initiate the recovering sequence by requesting CAN to
enter and to leave initialization mode.
Note:
If the Bus-off state cannot be recovery, the bus-off interrupt should be enabled and
reinit in it.
20.3.9.
CAN interrupts
Four interrupt vectors are dedicated to CAN. Each interrupt source can be independently
enabled or disabled by setting or resetting related bits in CAN_INTEN.
The interrupt sources can be classified into:
transmit interrupt
FIFO0 interrupt
FIFO1 interrupt
error and status change interrupt
Transmit interrupt
The transmit interrupt can be generated by any of the following conditions and TMEIE bit in
CAN_INTEN register will be set:
TX mailbox 0 transmit finished: MTF0 bit in the CAN_TSTAT register is set.
TX mailbox 1 transmit finished: MTF1 bit in the CAN_TSTAT register is set.
TX mailbox 2 transmit finished: MTF2 bit in the CAN_TSTAT register is set.