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.

TMS320F280049: How to get the data length of CAN receiving frame

Genius 3095 points
Part Number: TMS320F280049
Other Parts Discussed in Thread: C2000WARE

Dear team:

The data length of CAN frame sent by the sender is not fixed, when the CAN module of f280049 receives data, is there a register that can observe the length of the received data frame?

Best Regards

  • Secondly: after initializing the received frame length to 4 bytes, data exceeding 4 bytes can still be received. Is this initialization meaningless?

  • The data length of CAN frame sent by the sender is not fixed, when the CAN module of f280049 receives data, is there a register that can observe the length of the received data frame?

    DLC field in IF1MCTL register has this information. 

    after initializing the received frame length to 4 bytes, data exceeding 4 bytes can still be received. Is this initialization meaningless?

    DLC field of a Receive mailbox is a "don't care". Initializing that field is indeed meaningless.

  • Hi FF,

    The data length is defined by the transmitting node.  If you are using C2000Ware, the function CAN_setupMessageObject() for the transmitting node will define this.  The last argument of this function define the number of bytes to be transmitted, which is a maximum of 8.

    The register CAN_IFxMCTL also has a bit field called DLC which contains the data length information for the received frame at reception.  To poll this register, make  sure to note which IFx (1 or 2 is used by the rx node) and run the function CAN_transferMessage() to transfer the message object information including DLC to the IFxMCTL register.

    Regards,

    Joseph