This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Configure CAN filter to accept all messages

Hi All,

Really need help on this one, any suggestions welcome!....

I'm using the CAN bus example program for MCBSTM32C eval board. It has an STM32F107 chip and I am have issues with the CAN Filter....

Does anyone know how to configure the CAN Filter to accept ALL incoming messages?

Thanks

Shane

Parents
  • There supposed to be some functions in ST's OOXX_StdPeriph_Driver Library like:

    void CAN_FilterInit(CAN_FilterInitTypeDef* CAN_FilterInitStruct);
    

    Maybe see this:

    my.st.com/.../Flat.aspx

    Agree, the documentation is a little confusing. The short answer is that the FilterIDLow
    and FilterIDHigh as well as MaskIDLow and MaskIDHigh don't correspond exactly to the SID/EID.
    The bits need to be shifted depending on the type of ID you are trying to filter. It took me
    several weeks to find the answer on a German website that I used google to translate. Please
    look at my example code below, hopefully it will be clear then.
    
    In this example four filters are created to receive only SID 123, 124, 125 and 126. They
    don't have to be in order, just happened to be the numbers I picked. For a SID the numbers
    for the Filter/Mask IDs need to be shifted to the left by 5 bits.
    
    CAN_FilterInitStructure.CAN_FilterNumber = 1;
    CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdList;
    CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_16bit;
    // All filters are shifted left 5 bits
    CAN_FilterInitStructure.CAN_FilterIdHigh = 0x2460;          // 0x123
    CAN_FilterInitStructure.CAN_FilterIdLow = 0x2480;           // 0x124
    CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x24A0;      // 0x125
    CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x24C0;       // 0x126
    CAN_FilterInitStructure.CAN_FilterFIFOAssignment = 0;
    CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;
    CAN_FilterInit(&CAN_FilterInitStructure);
    

Reply
  • There supposed to be some functions in ST's OOXX_StdPeriph_Driver Library like:

    void CAN_FilterInit(CAN_FilterInitTypeDef* CAN_FilterInitStruct);
    

    Maybe see this:

    my.st.com/.../Flat.aspx

    Agree, the documentation is a little confusing. The short answer is that the FilterIDLow
    and FilterIDHigh as well as MaskIDLow and MaskIDHigh don't correspond exactly to the SID/EID.
    The bits need to be shifted depending on the type of ID you are trying to filter. It took me
    several weeks to find the answer on a German website that I used google to translate. Please
    look at my example code below, hopefully it will be clear then.
    
    In this example four filters are created to receive only SID 123, 124, 125 and 126. They
    don't have to be in order, just happened to be the numbers I picked. For a SID the numbers
    for the Filter/Mask IDs need to be shifted to the left by 5 bits.
    
    CAN_FilterInitStructure.CAN_FilterNumber = 1;
    CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdList;
    CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_16bit;
    // All filters are shifted left 5 bits
    CAN_FilterInitStructure.CAN_FilterIdHigh = 0x2460;          // 0x123
    CAN_FilterInitStructure.CAN_FilterIdLow = 0x2480;           // 0x124
    CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x24A0;      // 0x125
    CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x24C0;       // 0x126
    CAN_FilterInitStructure.CAN_FilterFIFOAssignment = 0;
    CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;
    CAN_FilterInit(&CAN_FilterInitStructure);
    

Children