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.

TMS320F280049C: Receive all msgID's and where is datalength?

Part Number: TMS320F280049C

Hi,

When receiving CANbus communication, normally an Id and Datalength is given (by the hardware). According to can.h  -> CAN_setupMessageObject() an msgID must be given when receiving a CANmessage, why? I understand the "don't care" for the datalength, because of the asserts. I want to receive all CANmessages on the bus, thus not providing an msgID.

Is there / what is the relationship between objID and msgID?

When using "CAN_readMessageWithID()" where is the datalength? (how many databytes are received by the HW CANmodule)

Is there documentation for the functions can.c / can.h

BR Ruud

  • Hi Ruud,

    CAN_setupMessageObject() function works for both transmit and receive objects.  msgID is used during transmission of a message object as this is part of the CAN frame that gets sent to the CAN bus.  During message reception, msgID is used during acceptance filtering together with the mask bits for the CAN module to decide whether to accept the CAN frame or not.  In CAN, the module has the ability to receive all incoming message or filter them according to the mask bits (for instance, your application only wants to receive msgIDs in the range of 0x2F0 - 0x2FF and reject others then you have to provide msgID and mask bits accordingly to accomplish this).  Details of acceptance filtering is available in section 26.11.6 of the TRM.

    objID is used in conjunction with message RAM inside the CAN module.  The CAN module in F280049 device has 32 message objects in the message RAM.  User has flexibility to use these 32 message objects (or objID) as either for transmission or reception in order to facilitate CAN communication through DMA or through interrupts without CPU intervention.

    msgID, sometimes referred to as node ID, is what is transmitted with the CAN message frame.  This is the identity of the frame that is broadcast over a CAN bus so other nodes will recognize it.  No node shall have the same msgID in the CAN bus, otherwise this will create errors with arbitration.

    For reading data length or DLC, you can look at register register field CAN_IF2MCTL.FLC (bits 3-0) immediately after function CAN_readMessageWithID() function.

    You can take a look as application report http://www.ti.com/lit/sprace5. It has many tested examples and demonstrate basics of CAN frame and message IDs.  This is also covered in application report http://www.ti.com/lit/spracq3 and illustrates CAN frames in detail.

    The documentations for the functions are all provided as comments prior to function prototypes in file can.h

    Best regards,

    Joseph

  • Hi Joseph,

    I will look into this tomorrow and will mark it as resolved, if I have no further questions.

    Thank you for your quick reply!

    Best regards,

    Ruud

  • Hi Joseph,

    When receiving CANdata, can I assume that if Message ID Mask = 0, all messages are received in that mailbox, regardless of the value of msgID? But when providing a msgID will guarantee reception in this mailbox ?

    For data length I found CAN_O_IF2MCTL <3:0> for f28004x controller. (I still find it a little odd that it's not passed with the message, though)

    Thanks for pointing out the documentation! 

    Edit: When looking at the CAN_sendMessage(), it contains msgLen. But when setting up CAN_setupMessageObject() it also contains a msgLen.

    Is this for the RAM allocation?

    Best regards,

    Ruud

  • Hi Ruud,

    Probably better to illustrate the use of message id mask with an example. If you set the message id to 0x1111 and id mask to 0x1FFFFFFF then only messages with 0x1111 are accepted. If mask is set to 0x1FFFFFF0, then messages 0x1110 to 0x111F are accepted.

    msgLen is only significant in CAN_sendMessage() as it sends this information with the frame as DLC.  msgLen is only used as a flag in CAN_setupMessageObject() that is not used anywhere else.

    During transmit, CAN_sendMessage() writes msgLen to  CAN_O_IF2MCTL <3:0>.  During receive, the received frame goes to the message ram as soon as CAN detects a valid frame and function CAN_readMessage() initiates the transfer of message RAM information (data, msgID, control including DLC and other info) and this is where CAN_O_IF2MCTL <3:0> [DLC] gets updated.

    Hope this provides clarity to your questions.

    Regards,

    Joseph