Tool/software:
The procedure to recover from CAN Bus-Off
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Every CAN node (DCAN or MCAN) on the CAN bus has two error counters: transmit error counter (TEC), and receive error counter (REC). A CAN node enters the error passive state if the REC or TEC exceed 127, and enters the BUS Off state if the TEC exceeds 255. In CAN Bus Off state, the CAN node disconnects itself from the CAN bus and can no longer transmit data or raise error flags.
CAN bus errors can be caused by faulty cables, noise, incorrect termination, malfunctioning CAN nodes etc. In debug, the CAN Bus-Off can be quickly entered by shorting CANH and CANL.
For DCAN, after the node has entered Bus Off state, the CPU can start a Bus-Off-Recovery sequence by resetting CCCR.INIT bit, or the DCAN will automatically start the Bus-Off recovery sequence if the automatic Auto-Bus-On (ABO) is enabled. Once the CCCR.INIT bit has been reset, the DCAN node will wait for 129 occurrences of Bus Idle (equal to 129 × 11 consecutive recessive bits) before resuming normal operation. At the end of the Bus-Off recovery sequence, the error counters will be reset.
For MCAN which supports both classic CAN and CAN FD, the recovery from Bus-Off is not automatically managed by the MCAN controller and so the application software must perform this operation. To restart MCAN operation, the user needs to clear CCCR.INIT. After CCCR.INIT is cleared, the device will then wait for 129 occurrences of bus idle (129 * 11 consecutive recessive bits) before resuming normal operation.
Before resetting the CCCR.INIT bit, the application software needs to clear all the pending messages and CAN TX status (F280039 MCAN driver MCAL doesn’t include this step, the CAN Bus-Off is not recovered)
The CAN does not receive messages and doesn’t transmission while the Bus-off Recovery proceeds. When a transmission is requested while the Bus-Off Recovery proceeds, it will be started after the Recovery has completed.
When the Bus-Off Recovery has completed, PSR.BO, ECR.TEC, and ECR.REC are cleared, and PSR.ACT is set to Idle.