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.

TM4C129ENCPDT: CAN error handling

Part Number: TM4C129ENCPDT

Hi, I am new to CAN bus and trying to use it in our product.

I am able to use the sample code in Tivaware to set up two units and make them communicate using CAN bus, but I am not sure how to handle the error situation. There is no sample code for this.

For example, if unit A transmits a CAN message periodically to unit B, everything is find when B is online and waiting. If I remove unit B, unit A's CAN module immediately goes into a auto re-transmission state. Even if I stop the program in debug mode, the module still tries to re-transmit the message all the time.

Such scenario (a node on the CAN bus may not exist or go off-line ) should be common in our design, this leaves me a question - how to handle such scenario properly?

One thing I can think of is to turn off the auto-re transmission feature. But this will sacrifice the communication reliability.

The other way is to immediately abort the message transmission, and inhibit such message in the future. This requires the firmware to check the CAN peripheral to find out which message is currently stuck, but it seems there is no quick way of doing this.

Maybe I have missed something, and there is a common approach of handling such issue that I am not aware of?

Thanks,

Tianlei

  • Hi TianLei,

      The continuous retransmission is expected per CAN protocol. While retransmission is on going,  the TEC error counter will increase and makes the CAN transmitter node become error passive. Please refer to the below two links that talks about retransmission when there is only one node in the network. With that said, you should have two or more nodes in the network and not just one in order for the CAN network to operate correctly. Personally, I don't think you should turn off auto retransmission. You should just let the node become error passive and continue to retransmit. When another node is plugged in and the network starts to operate again, the error counter should start to decrement again. 

    https://www.kvaser.com/can-protocol-tutorial/. Go to the Q and A section for error due to ACK error. 

    https://stackoverflow.com/questions/23052216/can-network-with-single-node-can-protocol

    https://www.kvaser.com/lesson/can-error-handling/#:~:text=A%20node%20starts%20out%20in,Flags%20when%20it%20detects%20errors.

  • Thanks Charles, the links you posted is useful, but it does not address our issue:

    Our application is that we are trying to establish a simple network with CAN bus. The nodes on the bus may fail but the rest of the of the nodes should continue to work. There is a master device to manage all the nodes on the network. It initiate conversation individually with every other nodes.

    The node ID is embedded in the message ID, so only one node will respond to a particular message. If that node is missing, such message will not be acknowledged and the master will be stuck in the message re-transmission. What the master node needs to do is to abort this message and mark the other node off-line and continue work with the rest of the nodes.  

    Any suggestions on such usage? Am I using the CAN protocol inappropriately?

  • Hi Tianlei,

      That is a system level question you need to make for your application. You can read the CAN status register and if the reason that TEC becomes error passive  is due to ACK error then you can disable auto-retransmission. You may consider making the message object corresponding to the missing node invalid by clearing the MSGVAL bit. In any case, you need to come up with a error confinement scheme for your system. 

  • Hi Charles, understood. Your suggestion confirms my thought about what I have to do.

    Thank you!