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 Message Objects



I'm learning from the datasheet about the CAN message Objects and am a little confused as to the functionality of a message object. Is the message object the location in memory with the appropriate identifier? Can I receive and transmit from a given message object (location in CAN memory)? Its mostly the wording that confuses me, it seems there are 3-4 different "message objects". For more information, I am trying to get a CAN module set up with 3-4 different inputs that can be monitored via  a CAN bus. I am using the newest version of code composer and the TIVA4C123GH6PM.

Thanks in advance

  • Hello Joshua,

    A Message object is a entry in the internal memory of the CAN controller. A message object is assigned a Message ID based on the configuration of the CAN controller. When a Message is received and the ID matches the message object gets the payload of the message.

    Regards
    Amit
  • Thank you for your succinct response. Could you explain the ID mask register's uses in a more succinct manner as well? Does it allow me to look at certain bits of data in a given location or does it filter which locations I can change?

    Thanks again,

    Josh

  • Hello Joshua,

    The Mask register is to set up to match Object ID's of a particular type. The Incoming Message ID is AND-ed with the Mask and if it matches then the data sent to the Message Object.

    Regards
    Amit
  • I think I understand but just to make sure. ( I'm using the CAN drivers from TIVAWare) does this code look right to set up a TX object?

        g_ui8TXMsgData = 0;
        g_sCAN0TxMessage.ui32MsgID = 3;
        g_sCAN0TxMessage.ui32MsgIDMask = 3;
        g_sCAN0TxMessage.ui32Flags = MSG_OBJ_TX_INT_ENABLE | MSG_OBJ_USE_ID_FILTER;
        g_sCAN0TxMessage.ui32MsgLen = sizeof(g_ui8TXMsgData);
        g_sCAN0TxMessage.pui8MsgData = (uint8_t *)&g_ui8TXMsgData;

        //
        // Now load the message object into the CAN peripheral.
        // Use message object FUEL_TXOBJECT
        //
        CANMessageSet(CAN0_BASE, 3, &g_sCAN0TxMessage, MSG_OBJ_TYPE_TX);

    Does that look right?

  • Hello Joshua,

    Depends on what you intend to do? It would mean to use the ID Mask with bits 0 and 1 set and match the value 0x3 in the message.

    Regards
    Amit
  • When you say value of that message do you mean the actual data or the arbitration field identifier number? Sorry I didn't explain things very well. I am trying to get 4 of the 32 messages memory locations set up (3 TX and one RX) and be able to filter incoming messages (remote) to change or request certain memory locations information. This is for an automation project where i have multiple sensors hooked up to one TIVA4C123GH6PM and need to communicate with each of the sensory via a CAN bus.
    g_ui8TXMsgData = 0;
    g_sCAN0TxMessage.ui32MsgID = 3;//---------------->I was thinking this is the ID number
    g_sCAN0TxMessage.ui32MsgIDMask = 3;//--------->This would be the Object number
    g_sCAN0TxMessage.ui32Flags = MSG_OBJ_TX_INT_ENABLE | MSG_OBJ_USE_ID_FILTER;
    g_sCAN0TxMessage.ui32MsgLen = sizeof(g_ui8TXMsgData);
    g_sCAN0TxMessage.pui8MsgData = (uint8_t *)&g_ui8TXMsgData;

    //
    // Now load the message object into the CAN peripheral.
    // Use message object FUEL_TXOBJECT
    //
    CANMessageSet(CAN0_BASE, 3, &g_sCAN0TxMessage, MSG_OBJ_TYPE_TX);-->and the second parameter would be the Object number as well.
    Thank you Amit for you help
    Josh
  • Hello Joshua

    The Message ID Number received on the bus will be AND-ed with g_sCAN0TxMessage.ui32MsgIDMask and if it matches g_sCAN0TxMessage.ui32MsgID then the message will be moved to the corresponding mailbox.

    Regards
    Amit
  • Hello Amit

    What is the MsgIDMask?

    For exemple:

    //=========== First case===============

    In TX:

    g_sCANMsgObject1.ui32MsgID = 0x2;
    g_sCANMsgObject1.ui32MsgIDMask = 0x5;

    The message going to send: 0x01 00 00 00

    In RX:

    g_sCANMsgObject1.ui32MsgID = 0x1;
    g_sCANMsgObject1.ui32MsgIDMask = 0x5;

    The message receive: 0x01 00 00 00

    //=========== Second case===============

    In TX:

    g_sCANMsgObject1.ui32MsgID = 0x2;
    g_sCANMsgObject1.ui32MsgIDMask = 0x10;

    The message going to send: 0x01 00 00 00

    In RX:

    g_sCANMsgObject1.ui32MsgID = 0x1;
    g_sCANMsgObject1.ui32MsgIDMask = 0x5;

    The message receive: 0x01 00 00 00

    //=========================

    Another case, I change the MsgIDMask, and I don't look difference???

    Can you explain me what is the MsgIDMask and how it work?

    Thank you.

  • Hello Huy,

    The Message ID is the value that will be inserted in the ID field of the CAN frame. The MsgIDMask is what is used to take the incoming ID in the frame, AND it with the Mask and then check if it matches one of the RX Message ID corresponding to the programmed RX Message Objects.

    Regards
    Amit
  • Hello Amit,

    Thanks for your reply.

    Look like I found something.

    "CanID_TX" will be AND with "CanMask_RX" then compare with "CanID_RX", any bit "0" in CanMask_RX will be ignore.

    For Example:

    CanID_RX = 0001 0001 1101 1101 (0x11DD)
    CanMask_RX = 0000 0000 0001 1011 (0x1B)
    //
    CanID_TX_1 = 0001 0000 0001 1001 (0x1019)
    CanID_TX_2 = 0001 0000 0001 1011 (0x101B)
    CanID_TX_3 = 0001 1111 0001 1001 (0x1F19)

    So, the interrupts only cause by CanID_TX_1 and CanID_TX_3, CanID_TX_2 doesn't cause anything.
  • Hello Huy,

    Yes, that is the correct interpretation of the Mask. You must now prove this by actually sending the same over CAN Bus using two devices.

    Regards
    Amit