STM32CubeIDE 1.7.0 code on STM32G0B1 CAN bus ID filter not working once using (HAL_FDCAN_ConfigGlobalFilter(&hfdcan1, FDCAN_REJECT, FDCAN_REJECT, FDCAN_FILTER_REMOTE, FDCAN_FILTER_REMOTE) .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-12 12:47 PM
Classic CAN configuration as below. when the line "if(HAL_FDCAN_ConfigGlobalFilter(...))" is removed, the CAN messages are received without issue. The transmitted message is set as ID: 0x111 . Confirmed by a CAN bus monitor.
Configuration as below:
FDCAN_FilterTypeDef sFilterConfig;
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();
}
// If comment this one, it works.
if(HAL_FDCAN_ConfigGlobalFilter(&hfdcan1, FDCAN_REJECT, FDCAN_REJECT, FDCAN_FILTER_REMOTE, FDCAN_FILTER_REMOTE) != HAL_OK)
{
Error_Handler();
}
if(HAL_FDCAN_Start(&hfdcan1) != HAL_OK)
{
Error_Handler();
}
Solved! Go to Solution.
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-02 7:10 AM
Mystery Solved! Need to change the default "Std Filters Nbr" setting from 0 to 1 or More.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-13 2:07 PM
Please help. ​ @Imen DAHMEN
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-17 7:42 AM
Hello @Jackle​ ,
Which CubeG0 version are you using ?
Imen
Thanks
Imen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-17 8:57 AM
STM32Cube FW_G0 V1.5.0
STM32CubeIDE 1.7.0
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-18 8:08 AM
Hi @Jackle​ ,
After check the code, the message ID responds to the filter, and it should be accepted and work.
Maybe the passed parameter to the function HAL_FDCAN_ConfigGlobalFilter are wrong.
The message matchs with the filter so the call of this function has no effect because it treats message in case that they don’t match with filters.
Did you try with other parameters in the function HAL_FDCAN_ConfigGlobalFilter ? try to replace FDCAN_REJECT with FDCAN_ACCEPT_IN_RX_FIFO0 ?
Imen
Thanks
Imen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-08-18 11:51 AM
Hi @Imen DAHMEN​ ,
This is exactly my point. The code seems no problem. But it's not working once I add
if(HAL_FDCAN_ConfigGlobalFilter(&hfdcan1, FDCAN_REJECT, FDCAN_REJECT, FDCAN_FILTER_REMOTE, FDCAN_FILTER_REMOTE) != HAL_OK)
{
Error_Handler();
}.
If I use FDCAN_ACCEPT_IN_RX_FIFO0 as parameter, I can receive the message.
But this is wrong. It means the message doesn't match with the ID.
Jackle
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-09-02 7:10 AM
Mystery Solved! Need to change the default "Std Filters Nbr" setting from 0 to 1 or More.
