2022-10-03 08:46 AM
Hello,
I am trying to work with the CAN filters and I am experimenting with various techniques. One thing I would like to do is have more than one filter on the same bus. For example, I would like to have the following message IDs be possible:
0x10 and 0x20
AND
0x111 to 0x555
So I would like to do two filters:
sFilterConfig.IdType = FDCAN_STANDARD_ID;
sFilterConfig.FilterIndex = 0;
sFilterConfig.FilterType = FDCAN_FILTER_DUAL;
sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXBUFFER;
sFilterConfig.FilterID1 = 0x10;
sFilterConfig.FilterID2 = 0x20;
sFilterConfig.RxBufferIndex = 0;
HAL_FDCAN_ConfigFilter(&hfdcan, &sFilterConfig);
sFilterConfig.IdType = FDCAN_STANDARD_ID;
sFilterConfig.FilterIndex = 0;
sFilterConfig.FilterType = FDCAN_FILTER_RANGE;
sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXBUFFER;
sFilterConfig.FilterID1 = 0x111;
sFilterConfig.FilterID2 = 0x555;
sFilterConfig.RxBufferIndex = 0;
HAL_FDCAN_ConfigFilter(&hfdcan, &sFilterConfig);
I know the code above would not work since the second configuration would overwrite the first. I would like to know what I have to do to make what I explained above possible.
For my testing, I am using an STM32H7B3I-EVAL board.
Solved! Go to Solution.
2022-10-03 09:21 AM
sFilterConfig.FilterIndex <- Enumerate properly
2022-10-03 09:21 AM
sFilterConfig.FilterIndex <- Enumerate properly
2022-10-03 09:31 AM
Hello,
Thank you for the reply!
Would I also have to alter the initialization? For example:
hfdcan.Init.StdFiltersNbr = 1; // <--- Change this to 2??
2022-10-03 11:10 AM
I've mainly used BxCAN peripheral, not the FDCAN one.
With BxCAN you could manage 28 filters, and split then between CAN1 / CAN2
Suggest you grep all FDCAN examples across H7 boards/libraries to use cases, and .C source of library to specifics.