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.

AM2632: How to set CAN ID filter in AM263x MCAL

Part Number: AM2632

Tool/software:

Hi, experts,

I am asking this question on behalf of my customer.

Customer tried to communicate with external CAN device with can_app in AM263x MCAL 10.01.00, with CAN_LOOPBACK_ENABLE setting to OFF. The CAN frame sending from AM263x can be received as expected. But the CAN frame sending from external device can not be received by AM263x. Through debugging, we found if setting CAN ID to 0xC1, it can be received by AM263x, as the Can_HwFilterType are set to pass frames with CAN ID 0x40, 0x41, 0xBE ~ 0xC3.

Customer need to receive CAN frame with ID 0x480 ~ 0x4F0, and below is his configuration in EB.

CanHandleType  :BASIC
CanHwObjectCount :2 (bitmask is enabled only with CanHwObjectCount > 1)
CanHwFilterCode:0x4f0
CanHwFilterMask:  0xf80

But CAN frames with ID 0x480 ~ 0x4F0 can not be received.

Please help to share the method and guideline to configure CAN ID filter in EB.

Thanks.

  • QJ is looking into this with Fan

  • Hi Fan,

    Are you going to store the message with ID=0x40, 0x41, and 0xBE~0xC3 to one mailbox? You can have more than one filter/mask for each mailbox.

    static Can_HwFilterType CanConfigSet_CanHardwareObject_0_CanHwFilter_0 =
    {
       0x40U,            /*CanHwFilterCode*/
       0x1FFFFFFF, /*Filter Mask*/
    };

    static Can_HwFilterType CanConfigSet_CanHardwareObject_0_CanHwFilter_1 =
    {
       0x41U,            /*CanHwFilterCode*/
       0x1FFFFFFF, /*Filter Mask*/
    };

    static Can_HwFilterType CanConfigSet_CanHardwareObject_0_CanHwFilter_2 =
    {
       0xBEU,            /*CanHwFilterCode*/
       0x1FFFFFFF, /*Filter Mask*/
    };

    static Can_HwFilterType CanConfigSet_CanHardwareObject_0_CanHwFilter_3 =
    {
       0xBFU,            /*CanHwFilterCode*/
       0x1FFFFFFF, /*Filter Mask*/
    };

    static Can_HwFilterType CanConfigSet_CanHardwareObject_0_CanHwFilter_4 =
    {
       0xC3,            /*CanHwFilterCode*/
       0x1FFFFFFC, /*Filter Mask*/
    };

    Then

    static Can_HwFilterType *CanConfigSet_CanHardwareObject_0_HwFilterConfigList[]=
    {
       &CanConfigSet_CanHardwareObject_0_CanHwFilter_0,

       &CanConfigSet_CanHardwareObject_0_CanHwFilter_1,

       &CanConfigSet_CanHardwareObject_0_CanHwFilter_2,

       &CanConfigSet_CanHardwareObject_0_CanHwFilter_3,

       &CanConfigSet_CanHardwareObject_0_CanHwFilter_4,
    };

  • Hi, Qingjun,

    Thanks for your reply.

    With default filter settings in can_app, only CAN frames with ID 0x40, 0x41, 0xBE ~ 0xC3 can be received. Customers want to receive CAN frames with ID 0x480 ~ 0x4F0. 

  • To receive the ID 0x480~0x4F0 (standard, 11-bit ID)

    Please use filter =0x480

    and mask = 0x78F

    Filter:  1    0    0     1   0   0   0      0   0   0   0

    Mask:  1    1    1     1   0   0   0     1    1   1   1

  • A 0 in the mask corresponds to a "don't care" and a 1 signifies that the bit must match the value in the filter.

    So the bit[10:7] of incoming message ID must be b1001

                bit[3:0] of the incoming msg ID must be b0000

    and bit[6:4] of the incoming msg can be any combinations 

  • Hi, Qingjun,

    Per talked, we have same understanding on the expected behavior about the bits setting in mask, but the test result is not as expected.

  • Hi Fan,

    I am working on the example, but I haven't make the range filter work. 

  • Working with customer offline (webex and message).

  • This issue is not reproducible, the expected functionality of CAN classic filtering is working correctly.

    Below are more details:

    #1. Hardware object configuration: Ensure that the CanHwObjectCount is greater than 1 for CAN classic filtering to work. When CanHwObjectCount =  1, hardware object is used as dedicated message buffer.

    #2. Can Filter configuration: To pass 0x480 to 0x7FF id range as per understanding of classic CAN filtering, use code 0x480 and mask 0x400

    Note: We have also tested for the exact range as given in E2E and it works as expected

    #3. When we try to send CAN frame using any id in the range of 0x480 to 0x7FF, we are able to receive the data successfully using Can_app example.

    #4. We had debug session with Fan, and it is working as expected at his end too. He will debug with customer and try to make it work in customer’s application also.