2021-03-03 06:53 AM
I am using the STM32G474E-EVAL1 board and the example FDCAN_Com_polling.
It is working and only accept ID of 0x111.
The code is:
sFilterConfig.IdType = FDCAN_STANDARD_ID;
sFilterConfig.FilterIndex = 0;
sFilterConfig.FilterType = FDCAN_FILTER_MASK;
sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO0;
sFilterConfig.FilterID1 = 0x111;
sFilterConfig.FilterID2 = 0x7FF;
if (HAL_FDCAN_ConfigFilter(&hfdcan1, &sFilterConfig) != HAL_OK)
{
Error_Handler();
}
I now want the code to be able to accept two CAN IDs. Like 0x123 and 0x400.
I tried to set sFilterConfig.FilterID2 = 0x400 like this
/* Configure reception filter to Rx FIFO 0 on both FDCAN instances */
sFilterConfig.IdType = FDCAN_STANDARD_ID;
sFilterConfig.FilterIndex = 0;
sFilterConfig.FilterType = FDCAN_FILTER_MASK;
sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO0;
sFilterConfig.FilterID1 = 0x111;
sFilterConfig.FilterID2 = 0x400;
but this won't accept 0x400.
I also tried to change sFilterConfig.FilterIndex = 1;
/* Configure reception filter to Rx FIFO 0 on both FDCAN instances */
sFilterConfig.IdType = FDCAN_STANDARD_ID;
sFilterConfig.FilterIndex = 1;
sFilterConfig.FilterType = FDCAN_FILTER_MASK;
sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO0;
sFilterConfig.FilterID1 = 0x400;
sFilterConfig.FilterID2 = 0x7FF;
if (HAL_FDCAN_ConfigFilter(&hfdcan1, &sFilterConfig) != HAL_OK)
{
Error_Handler();
}
but that doesn't work either.
How can I set the filter to accept two CAN IDs ?
2021-03-24 10:50 AM
I have the same problem with G4.