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.

CAN-bus unable to change data bytes

Other Parts Discussed in Thread: HALCOGEN

Hi,

I am struggling to send a simple message over CAN using a TMS570 launchpad. It's the first time that I need to use the CAN-bus and I just can't figure this out. 

I have the example_canCommunication.c working. I'm using a PEAK-CAN dongle and I see the message coming in with the right ID and data. 

However, when I change the data that is being sent during run time I don't see any changes in the message that I'm receiving on the other side. 

I'm just trying to sent a message: canTransmit(canREG1, canMESSAGE_BOX1, tx_data); then increment one of the data bytes and send the data again using the same CAN-bus and messagebox. 

I've been spending a lot of time reading up on CAN bus in general and checking out examples but I keep getting the same message over and over again. 

Any help is greatly appreciated!

  • Are you saying that the same data is observed on the bus when you try to send different data via the canTransmit() function? I am guessing that some flag is not get cleared when the first message is sent. It seems that the CAN mailbox RAM is not get updated fro some reason. If you share your test code, I can take a look.

    Thanks and regards,

    Zhaohong
  • Dear Zhaohong,

    Thanks for the quick response. The problem is indeed that the data on the bus doesn't change. The initial data is received ok but when the data changes it doesn't get sent. I simply changed the canCommunication.c example provided by TI so it will never reach the receive part but just keep on sending. I have attached the code.

    6558.sys_main.c

  • I would like to explain how the CAN module works.

    To send a CAN message, the user needs to first write the data and command to the interface registers. If there is no pending message in the CAN mailbox, the user can start a transfer to move data/command from the interface registers to the CAN mailbox. After the entire message in the mailbox, the CAN module will put the data on the bus if the bus is idle.

    If you take a look at the source code generated by Halcogen, you will see that canTransmit() function returns immediately after the transfer between the interface registers and CAN mailbox is started. To send message continuously, I suggest you to use the canIsTxMessagePending() and canIsMessageBoxValid() functions to make sure that the CAN mailbox is ready before calling the canTransmit() function to send the new message.

    I would also suggest you to put a breakpoint at "canTransmit(canREG1, canMESSAGE_BOX1, tx_data);" and check the tx_data array in the memory to see if it is actually updated by the the c-instruction  "tx_data[0]++;".

    Thanks and regards,

    Zhaohong

  • Dear Zhaohong,

    Thanks a lot for pointing me in the right direction. I have the CAN-bus working now.

    Regards,
    Rindert