Skip to main content
Jackle
Associate II
August 12, 2021
Solved

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) .

  • August 12, 2021
  • 3 replies
  • 3024 views

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();

}

This topic has been closed for replies.
Best answer by Jackle

Mystery Solved! Need to change the default "Std Filters Nbr" setting from 0 to 1 or More.

0693W00000Dm0UJQAZ.png

3 replies

Jackle
JackleAuthor
Associate II
August 13, 2021

Please help.   ​ @Imen DAHMEN

ST Technical Moderator
August 17, 2021

Hello @Jackle​ ,

Which CubeG0 version are you using ?

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
Jackle
JackleAuthor
Associate II
August 17, 2021

STM32Cube FW_G0 V1.5.0

STM32CubeIDE 1.7.0

ST Technical Moderator
August 18, 2021

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

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
Jackle
JackleAuthorBest answer
Associate II
September 2, 2021

Mystery Solved! Need to change the default "Std Filters Nbr" setting from 0 to 1 or More.

0693W00000Dm0UJQAZ.png