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/TMS570LS3137: DCAN module - DLC reading issue

Part Number: TMS570LS3137
Other Parts Discussed in Thread: HALCOGEN

Tool/software: Code Composer Studio

I've worked with CCS v.10.1.0.00010, HALCoGen v.04.07.01 and Hercules HDK tms570ls3137 development board. The board should receive messages in CAN1 module. After receiving the first identifier, dlc and data are retrieved as follows:

rx_identifier = can_get_ext_ID(channel, canMESSAGE_BOX1);
rx_dlc = can_get_dlc(channel, canMESSAGE_BOX1);
canGetData(channel, canMESSAGE_BOX1, rx_data);

Transmit can message from PC side

rx_identifier and rx_data are correct, but dlc is wrong and have default value as it was configured.

When next message read. dlc equals of dlc previous value.

This function that read dlc

Why do all incoming messages overwrite the previous ones before they are read, and in the case of DLC the value is read before a new one is written?

  • Nikita,

    Your get_dlc() routine has an issue.

    With IF2CMD = 0x20, you are still reading ID from CAN into IF2, IF2CMD bit-4 should be set (0x10) to read MCTL value.

    You probably have Bit_4 set in GetData() routine and is what you see in your next get_dlc(() - which still hold previous value!

    Better approach is to transfer all ID, dlc and data, all in one shot. You can avoid 2 additional calls each with 2 sets of handshake waits with the CAN controller.

    -Joe Josn

  • Hi Nikita,

    Joe is correct. You need write 1 to the control bit of IFxCMD to read the DLC from CAN message RAM.