I encountered an issue while debugging the CAN bus. After the MCU starts up, there is a probability that the CAN controller enters an error state. In this state, everything appears normal when no CAN frames are being received or transmitted. However, as soon as a CAN frame is received, errors start accumulating. The strange part is that the CAN0->PSR->BO (Bus Off) bit does not get set to 1, so the recovery mechanism cannot be triggered, causing the CAN bus to remain in an abnormal state continuously.
What could be the cause of this situation? Is there any specific register (similar to the PSR->BO bit) that can be used to identify this issue?
The following is the register information in this state:
MCAN Control Register (CCCR) Status [0x00000000]:
------------------------------------------------
INIT[0]: 0 - Normal operation
CCE[1]: 0 - Configuration registers locked
ASM[2]: 0 - Normal CAN operation
CSA[3]: 0 - Clocks running
CSR[4]: 0 - No clock stop request
MON[5]: 0 - Normal transceiver mode
DAR[6]: 0 - Automatic retransmission enabled
TEST[7]: 0 - Normal operation
FDOE[8]: 0 - CAN FD operation disabled
BRSE[9]: 0 - Bit rate switching disabled
PXHD[12]: 0 - Protocol exception handling enabled
EFBI[13]: 0 - Edge filtering disabled
TXP[14]: 0 - Transmit pause disabled
NISO[15]: 0 - Using ISO CAN FD spec
MCAN Protocol Status Register (PSR) [0x0000077C]:
------------------------------------------------
LEC[2:0]: 4 - Bit1 error: Dominant level when recessive expected during transmission
ACT[4:3]: 3 - Transmitter - Node operating as transmitter
EP[5]: 1 - Error passive state
EW[6]: 1 - At least one error counter >= 96
BO[7]: 0 - Bus-on state
[NOTICE] In Error Passive state! Communication may be affected
[NOTICE] At least one error counter reached warning limit (96)
MCAN Error Counter Register (ECR) [0x0000FF08]:
------------------------------------------------
TEC[7:0]: 8 - Transmit Error Count (0-255)
REC[14:8]: 127 - Receive Error Count (0-127)
RP[15]: 1 - Receive error level (>=128)
CEL[23:16]: 0 - CAN Error Log Count (0-255)
[WARNING] Receive error counter near/passive threshold (127)!
[NOTICE] In receive error passive state (RP=1)
Hello @yyyy1
Please check if the configuration of the CAN controller's clock, baud rate, and operating mode is correct. Also, check the CAN hardware connection.
I recommend that you first use the CAN demo in the SDK to see if it works well with your board.
BR
Alice