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.

TM4C1294NCPDT: Finding out the ID of received Messages when caling CANMessageGet

Part Number: TM4C1294NCPDT

When using ID filtering in CAN message objects (that is, setting the MSG_OBJ_USE_ID_FILTER flag and **not** setting ui32MsgIDMask to all ones), how can I know which ID sent me the message?

I assumed that this information would be available in the ui32MsgID field of the tCANMsgObject object I provide when calling CANMessageGet(), but the Tivaware Documentation explicitly says otherwise. ("When using CANMessageGet(), all of the same fields of the structure are populated in the same way as when the CANMessageSet() function is used") Is this accurate? Is there any other way?

  • Hi Franco,

      I think the description could have been made more clear. I think what it tries to say is that the CANMessageGet() will return a structure with the same arrangement of fields as CANMessageSet(). I don't think it implies the contents will be the same between CANMessageGet and CANMessageSet. 

    Description:
    This function is used to read the contents of one of the 32 message objects in the CAN controller
    and return it to the caller. The data returned is stored in the fields of the caller-supplied
    structure pointed to by psMsgObject. The data consists of all of the parts of a CAN message,
    plus some control and status information.
    Normally, this function is used to read a message object that has received and stored a CAN
    message with a certain identifier. However, this function could also be used to read the contents
    of a message object in order to load the fields of the structure in case only part of the structure
    must be changed from a previous setting.
    When using CANMessageGet(), all of the same fields of the structure are populated in the
    same way as when the CANMessageSet() function is used, with the following exceptions:

    Also look at the datasheet description. 

    19.3.7 Receiving a Data Frame
    The message handler stores the message from the CAN controller receive shift register into the
    matching message object in the message RAM. The data bytes, all arbitration bits, and the DLC bits
    are all stored into the corresponding message object. In this manner, the data bytes are connected
    with the identifier even if arbitration masks are used. The NEWDAT bit of the CANIFnMCTL register
    is set to indicate that new data has been received. The CPU should clear this bit when it reads the
    message object to indicate to the controller that the message has been received, and the buffer is
    free to receive more messages. If the CAN controller receives a message and the NEWDAT bit is
    already set, the MSGLST bit in the CANIFnMCTL register is set to indicate that the previous data
    was lost. If the system requires an interrupt on successful reception of a frame, the RXIE bit of the
    CANIFnMCTL register should be set. In this case, the INTPND bit of the same register is set, causing
    the CANINT register to point to the message object that just received a message. The TXRQST bit
    of this message object should be cleared to prevent the transmission of a remote frame.


    19.3.11 Handling of Received Message Objects
    The CPU may read a received message any time via the CAN Interface registers because the data
    consistency is guaranteed by the message handler state machine.
    Typically, the CPU first writes 0x007F to the CANIFnCMSK register and then writes the number of
    the message object to the CANIFnCRQ register. That combination transfers the whole received
    message from the message RAM into the Message Buffer registers (CANIFnMSKn, CANIFnARBn,
    and CANIFnMCTL). Additionally, the NEWDAT and INTPND bits are cleared in the message RAM,
    acknowledging that the message has been read and clearing the pending interrupt generated by
    this message object.
    If the message object uses masks for acceptance filtering, the CANIFnARBn registers show the
    full, unmasked ID for the received message.