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.

CCS/TMS570LC4357: isTxMessagePending not working

Part Number: TMS570LC4357

Tool/software: Code Composer Studio

I am using a can bus to communicate between three different boards. To test communication, I put two transmissions back to back on my Sender board. In this scenario, the second transmission should only occur when the receiver reads the message (i.e canGetData). However, both of these transmissions occur even if the receiver does nothing.

    while(canIsTxMessagePending(canREG1, canMESSAGE_BOX1));
    canTransmit(canREG1, canMESSAGE_BOX1, tx[mode]);

    while(canIsTxMessagePending(canREG1, canMESSAGE_BOX1));
    canTransmit(canREG1, canMESSAGE_BOX1, tx[mode]);


Another problem is, if I do many transmissions in a row, while running a receiving loop(controlled by canIsRxMessageReceived) on the receiving side... Not every message is even received. However if I place a small delay between transmissions

For example:

for(i = 0; i < 30000;i++);

the receiver gets every message and correctly. This doesn't make any sense, the sender should never transmit a message if a sender has not read the data... any idea what is going on here?

  • Hello,

    DCAN is based on a two-wire connection between nodes in the network, i.e., and all nodes are sharing the same physical communication bus. DCAN averts message collisions by using the message ID, i.e. the message with the highest priority (= lowest message ID) will gain access to the bus, while all other nodes (with lower priority message IDs) switch to a “listening” mode. So both nodes can send the message at the same time. The two messages should not use the same ID.

    At the end of the message there will be an acknowledgement (ACK) from the node which received the message correctly and a negative acknowledgement (NAK) from the node which received it incorrectly. If that NAK is present, the sender will re-try automatically if the retransmission is enabled. If the receiver gets the message correctly, but the CPU doesn't read the message from the CAN message RAM before the next message arrives, the previous message in the message RAM will be overwritten.

  • I understand the mechanic behind multiple nodes transmitting on the bus at once. The problem I am experiencing is that even in a system where there is one sender and one receiver, I still need a delay to avoid overwriting messages... even if I use canIsTxMessagePending. Again, I am only using 1 node for transmit currently.

  • Adding "canIsTxMessagePending" is to check if there is pending message before sending message. Actually this is checked within canTransmit(), you don't need check it twice.

    Checking "canIsTxMessagePending" does not avoid packet loss in receiver side. It depends on if your receiver has time to read the data out of the message RAM before it was overwritten. You need to evaluate how long (for example 50us) your receiver take to read the data out to free up the message box in message RAM for next coming data, then your transmitter should not send 2nd packet within 50us.