cancel
Showing results for 
Search instead for 
Did you mean: 

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

Jackle
Associate III

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

}

1 ACCEPTED SOLUTION

Accepted Solutions
Jackle
Associate III

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

0693W00000Dm0UJQAZ.png

View solution in original post

6 REPLIES 6
Jackle
Associate III

Please help.   ​ @Imen DAHMEN

Imen.D
ST Employee

Hello @Jackle​ ,

Which CubeG0 version are you using ?

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

STM32Cube FW_G0 V1.5.0

STM32CubeIDE 1.7.0

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

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

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

Jackle
Associate III

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

0693W00000Dm0UJQAZ.png