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.

LAUNCHXL-F28379D: CAN RX issue, how do I get ID of a receiving message?

Part Number: LAUNCHXL-F28379D

Using the F2837xD Peripheral Driver Library 1.02.00.00,
how do I get the msgID of a received message?

If I use msgID masking, and allow for more than one msgID to pass throw my receiving filter.
 - it would be quite nice to get the actual msgID of the message that was received.

ref user guide for "F2837xD Peripheral Driver Library 1.02.00.00" page 42

void CAN_setupMessageObject (uint32_t base, uint32_t objID, uint32_t msgID,CAN_MsgFrameType frame, CAN_MsgObjType msgType, uint32_t msgIDMask, uint32_tflags, uint16_t msgLen);

bool CAN_readMessage (uint32_t base, uint32_t objID, uint16_t msgData);
- this method only get the raw data from the message, not the ID.

one other question:

what happens if I receive a message on the same ObjID before the old one was processed, does it get overwritten/lost or is there some kind of fifo buffer going on?

regards

Simen

  • Hi Simen,

    Best way is to look at the register contents directly. In CCS, set a breakpoint inside function CAN_readMessage, towards the end. Open up the Expressions window and add the line CanaRegs.CAN_IF1ARB to the expressions window. Expand that and you should see the field 'ID' which is 29-bit length as it supports extended addressing (standard length is only 11 bits). Value in this field is the message ID, which does not include the masks.

    On the 2nd question, previous message gets overwritten if the same ObjID is used.

    Regards,
    Joseph
  • Hi.

    in this example the id is 0x1234, with STD message (11-bit) this is value is actually above 11 bit and will be masked down to 0x234 (bug)?

    I've tested your soulution with the can_ex1_loopback example. CanaRegs.CAN_IF1ARB holds a value of 0x8D00000 (id << 18)

    I do need this id in my application, not only for debug purposes.

    I could not find the definition for CanaRegs in any of the header files inside the "new driverlib" so I read out the value in the same way the can.c is doing.

        //
            // Read CAN message object 2 and check for new data
            //
            if (CAN_readMessage(CANA_BASE, 2, rxMsgData))
            {

               long id = HWREG(CANA_BASE + CAN_O_IF1ARB);
                id &= CAN_IF1ARB_STD_ID_M;
                id = id >> CAN_IF1ARB_STD_ID_S;

    is it safe to extract this id right after the CAN_readMessage is completed?
    I guess its not recommended to edit can.c as this will probably be updated width a new version some time in the future.

     

    one more thing, looking through the can.c file

    at the end of CAN_readMessage() the HWREG called with "CANA_BASE"(constant) insted of "base" (variable), is this a bug? 

     //
            // Now clear out the new data flag
            //
            // Transfer the message object to the message object specified by
            // objID.
            //
            HWREG_BP(CANA_BASE + CAN_O_IF2CMD) = CAN_IF2CMD_TXRQST |
                                                 (objID & CAN_IF2CMD_MSG_NUM_M);

            //
            // Wait for busy bit to clear
            //
            while((HWREGH(CANA_BASE + CAN_O_IF2CMD) & CAN_IF2CMD_BUSY) == CAN_IF2CMD_BUSY)
            {
            }