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 CANMessageSet problem

Hi 

I have some problems with configuring the can mailboxes properly. I am able to successfully receive CAN messages in general. Some configurations, however, do not seem to work properly.

E.g. if I want to allow all messages of standard ID type (11 bit identifier) - without considering the value of the identifier field.

Simplified example of how i try to configure mailbox 1 to receive ALL messages with a 11 bit identifier:

*********************************************************************************************
/* Init CAN */
ROM_CANInit( CAN0_BASE );

/* Set the bit rate */
ROM_CANBitRateSet( CAN0_BASE, ROM_SysCtlClockGet(), 250000 );

/* Enable CAN */
ROM_CANEnable( CAN0_BASE );

/* Configure a CAN mailbox */
tCANMsgObject canMsgObj;

/* Clear all flags */
canMsgObj.ui32Flags = MSG_OBJ_NO_FLAGS;

/* Enable RX interrupt */
canMsgObj.ui32Flags |= MSG_OBJ_RX_INT_ENABLE;

/* Configure mailbox */
ROM_CANMessageSet( CAN0_BASE, 1, &canMsgObj, MSG_OBJ_TYPE_RX );

*********************************************************************************************


With the above code no messages get through to mailbox 1. However, If I enable filtering:

canMsgObj.ui32Flags |= MSG_OBJ_USE_ID_FILTER;
canMsgObj.ui32MsgID = 0x1;
canMsgObj.ui32MsgIDMask = 0x1;

then it works perfectly fine, and I receive only 11bit messages with ID = 1;

Is it not allowed to configure a mailbox without filtering (without setting MSG_OBJ_USE_ID_FILTER)?

I have also tried to enabled filtering and setting the mask to mask out all bits, like this:

canMsgObj.ui32Flags |= MSG_OBJ_USE_ID_FILTER;
canMsgObj.ui32MsgID = 0x00;
canMsgObj.ui32MsgIDMask = 0x00;

this, however, enables ALL messages of both standard and extended type - which is not what I want.

I am using a TM4C1233D5PMI on a custom board. As you see, I am using the tivaware in ROM. I have, however, also tried the non-ROM versions from tivaware v. 2.1.0.12573. Additionally I am using CCS v6 with TI C compiler v5.1.6.

I will appreciate any help you can provide.

BR
Christian
  • Hello Christian

    From the data sheet for CAN Receive:

    A value of 0x00 enables all messages to pass through the acceptance filtering. Also note that in order for these bits to be used for acceptance filtering, they must be enabled by setting the UMASK bit in the CANIFnMCTL register.

    Regards
    Amit
  • Hi Amit,

    thanks for the prompt reply!

    Your information regarding the 0x00 in the mask is consistent with what I experience using tivaware - thanks for clarifying. 

    It still puzzles me why I have to enable filtering ( MSG_OBJ_USE_ID_FILTER with tivaware) in order to receive any messages. I would really like to be able to configure mailboxes to receive all 11bit messages OR all 29bit messages. For now, I have to implement the filtering in software - which is definitely not desirable on a busy can-bus.

    br

    Christian

  • Hello Christian

    If the intent is to receive all 11 bit OR all 29 bit message, then you would need to configure the Masks separately for XTD and non-XTD mailboxes.

    Regards
    Amit
  • Hello Amit,

    I just wanted to let you know that your information regarding the effect of setting the mask to 0x00 solved the problem. Knowing this, the tivaware drivers work much more as expected.

    Thanks a lot for your help!

    Br

    Christian