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.

MCU-PLUS-SDK-AM261X: CAN Filter configuration

Part Number: MCU-PLUS-SDK-AM261X
Other Parts Discussed in Thread: SYSCONFIG

Tool/software:

Hello TI team:

   In my project. Only Standard ID equal to 0x757, 0x2F6 can be receive.  I want to use 3 acceptance filter to filtering these standard id.  In additional , CAN message with standard id 0x757  store in RX FIFO0, and CAN message with standard id 0x2F6 store in RX FIFO1 or dedicate RX buffer. below is my configuration 1: 

stCanRxDiagMsgObj.direction = CANFD_Direction_RX;
stCanRxDiagMsgObj.msgIdType = CANFD_MCANXidType_11_BIT;
stCanRxDiagMsgObj.args = (uint8_t*) Can_au8RxDiagData;
stCanRxDiagMsgObj.startMsgId = 0x757;
stCanRxDiagMsgObj.endMsgId = 0;
stCanRxDiagMsgObj.rxElement = 0;
stCanRxDiagMsgObj.dataLength = 64;
stCanRxDiagMsgObj.rxMemType = MCAN_MEM_TYPE_FIFO;
status = CANFD_createMsgObject (gCanfdHandle[CONFIG_MCAN0], &stCanRxDiagMsgObj);
u32FilterNum++;

stCanRxTimeSyncMsgObj.direction = CANFD_Direction_RX;
stCanRxTimeSyncMsgObj.msgIdType = CANFD_MCANXidType_11_BIT;
stCanRxTimeSyncMsgObj.args = (uint8_t*) Can_au8RxTimeSyncData;
stCanRxTimeSyncMsgObj.startMsgId = 0x2F6;
stCanRxTimeSyncMsgObj.endMsgId = 0;
stCanRxTimeSyncMsgObj.rxElement = 0; /** buffer num */
stCanRxTimeSyncMsgObj.dataLength = 64;
stCanRxTimeSyncMsgObj.filterConfig;
stCanRxTimeSyncMsgObj.rxMemType = MCAN_MEM_TYPE_BUF;

The filters worked. But CAN message with Standard id 0x2F6 store in FIFO0, NOT in dedicate rx buffer.  All the message receive with stCanRxDiagMsgObj.  Object stCanRxTimeSyncMsgObj  was meaningless.

Base on above,  add another configuration : 

    uint32_t u32BaseAddr = 0U;
    uint32_t u32FilterNum = 1;
    MCAN_StdMsgIDFilterElement  stStdMsgIdFilter;
    u32BaseAddr = stCanRxDiagMsgObj.canfdHandle->object->regBaseAddress;
    /**ID */
    stStdMsgIdFilter.sfid1 = 0x2F6;
    stStdMsgIdFilter.sfid2 = 0;
    /* store in rx buffer */
    stStdMsgIdFilter.sfec = MCAN_STD_FILT_ELEM_BUFFER;
    /**< Dual ID filter for SFID1 or SFID2, will be ignore in buffer mode. */
    stStdMsgIdFilter.sft = MCAN_STD_FILT_TYPE_DUAL;
    MCAN_addStdMsgIDFilter(u32BaseAddr, u32FilterNum, &stStdMsgIdFilter);

In this configuration ,  CAN message with standard id 0x2F6 can trig the receive interrput.  But can not get the correct CAN id and message data.

So, Can you help to  modify the filter configuartion to meet my requirement? Thank you!

Another question:

SFID2 have  been explain in blue box,   so how to understand the description in red box?


  • So, Can you help to  modify the filter configuartion to meet my requirement? Thank you!

    If your requirement is to receive only 0x2F6 and 0x757 then you have correctly set DUAL filter but your filter IDs are 0x0 and 0x1 respectively in your SysConfig screenshot. I think you should you set them to 0x2F6 and 0x757 (in FIFO mode).


  • Hello , thanks for your reply. 

    Below is my requirement:

     "CAN message with standard id 0x757  store in RX FIFO0, and CAN message with standard id 0x2F6 store in RX FIFO1 or dedicate RX buffer. "

  • Ah sorry, I missed that you wanted a different FIFO for each filtered ID. I'm not sure that's possible.

  • Hi Jevin,

    This is certainly possible as up to 128 filter elements can be defined for the MCAN IP.

    Filter1 is configured to accept ID 0x757 in RX FIFO0

    Filter2 is configured to accect ID 0x2F6 in RX Buffer

    AM261x MCU+ SDK: MCAN_StdMsgIDFilterElement Struct Reference

    In order for the filter to capture only the signle ID's the "Classical Filter" option should be used. Where SFID1 = ID to accept and SFID = All 1 (Full Mask to make sure only the exact match of SFID1 is accepted).

    Please refer to the MCAN - RX Handling section of the device TRM for additional details.

    In regards to the SFID2 bitfield descriptions shown in your screenshot, can you confirm the source this screenshot is coming from?

    I am providing an a secondary description of these bits taken directly from the Bosch MCAN User Guide document.

    The details in the red box describe the register bitfield functions only when SFEC = 111. 

    When SFEC != 111 or 000, then SFID2 acts as the actual second ID value according to the Filter Type (eg: end of filter range ID value, second filter, ID value or filter mask value)

    Best Regards,

    Zackary Fleenor