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 RX Filtering using the function of CANMessageSet()

Other Parts Discussed in Thread: TM4C1290NCZAD

Hi,

I made a CAN RX filtering function.
It works well, but when I mix it with filter disabling function, sometimes the filtering fails.

I have an interrupt service routine, so my tm4c1290nczad controller receives the messages
with CAN ID 0x100. Usually my filter function works fine.
But, after I run these enable/disable functions in random times,
I can't see 0x100 messages even after running the enable function
or I can see 0x100 messages even after running the disable function.

When I commented the disable function and run the only enable function multiple times,
I've never seen this type of error.

Do you have any idea?

Regards,

Young

int main()
{
    ...
    while (1)
    {
        CAN_EnableReceivingFilter(8, 0x100, 0xfff);
        delay(0.5);     // 0.5s
        CAN_DisableReceivingFilter(8);
        delay(0.5);     // 0.5s
    }
    ...
}

void CAN_EnableReceivingFilter(uint32_t canObjId, uint32_t msgId, uint32_t msgIdMask)
{
    tCANMsgObject msgObj;

    msgObj.ui32MsgID = msgId;
    msgObj.ui32MsgIDMask = msgIdMask;
    msgObj.ui32Flags = MSG_OBJ_RX_INT_ENABLE | MSG_OBJ_USE_ID_FILTER;

    CANMessageSet(CAN_BASE, canObjId, &msgObj, MSG_OBJ_TYPE_RX);
}

void CAN_DisableReceivingFilter(uint32_t canObjId)
{
    tCANMsgObject msgObj;

    msgObj.ui32MsgID = 0xfff;
    msgObj.ui32MsgIDMask = 0xfff;
    msgObj.ui32Flags = 0;

    CANMessageSet(CAN_BASE, canObjId, &msgObj, MSG_OBJ_TYPE_RX);
}