cancel
Showing results for 
Search instead for 
Did you mean: 

stm32g4 FDCAN fiters problem

zemlemer
Associate

Hi. I have a problem with can filers on a G4 board. With standard ids device worked well, but when i changed id to extended the filters stopped working.

// 5. FDCAN Filters configuration
// 5.1. Dual filter for broadcast messages
sFilterConfig.IdType = FDCAN_EXTENDED_ID; //FDCAN_STANDARD_ID;
sFilterConfig.FilterIndex = 0;
sFilterConfig.FilterType = FDCAN_FILTER_DUAL; //FDCAN_FILTER_MASK;
sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO0;
sFilterConfig.FilterID1 = 0x800 | 0xFF;
sFilterConfig.FilterID2 = 0x800 | 0xFF; // For acceptance, MessageID and FilterID1 must match exactly
if(HAL_FDCAN_ConfigFilter(&hfdcan, &sFilterConfig) != HAL_OK) {
   return -2;
}



// 5.1. Range filter
uint16_t canRcvHeaderMaskL = 0x00000803;
uint16_t canRcvHeaderMaskH = 0x00000806;

sFilterConfig.IdType = FDCAN_EXTENDED_ID; //FDCAN_STANDARD_ID;
sFilterConfig.FilterIndex = 1;
sFilterConfig.FilterType = FDCAN_FILTER_RANGE; //; FDCAN_FILTER_DUAL
sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO1;
sFilterConfig.FilterID1 = canRcvHeaderMaskL;
sFilterConfig.FilterID2 = canRcvHeaderMaskH;

if(HAL_FDCAN_ConfigFilter(&hfdcan, &sFilterConfig) != HAL_OK) {
return -2;
}
// Activate Rx FIFO 0 new message notification
if (HAL_FDCAN_ActivateNotification(&hfdcan, FDCAN_IT_RX_FIFO0_NEW_MESSAGE, 0) != HAL_OK) {
setTerminalMessage(error, "FDCAN filter notification alert failed");
return -3;
}
if (HAL_FDCAN_ActivateNotification(&hfdcan, FDCAN_IT_RX_FIFO1_NEW_MESSAGE, 0) != HAL_OK) {
setTerminalMessage(error, "FDCAN filter notification alert failed");
return -3;
}

HAL_FDCAN_ConfigGlobalFilter(&hfdcan, FDCAN_REJECT, FDCAN_REJECT, FDCAN_REJECT_REMOTE, FDCAN_REJECT_REMOTE);

If i comment HAL_FDCAN_ConfigGlobalFilter string - every input packet appears in fifo0. What can i do to make filter work?

 

3 REPLIES 3
SofLit
ST Employee

Hello,


@zemlemer wrote:

Hi. I have a problem with can filers on a G4 board. With standard ids device worked well, but when i changed id to extended the filters stopped working.


Are you sure you are sending Extended IDs? are you using Loopback mode?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
PS:
1 - This is NOT an online support (https://ols.st.com) but a collaborative space.
2 - Please be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help.

Well, if i comment HAL_FDCAN_ConfigGlobalFilter string, i receive packet with id 0x803 and this is not 11-bit id, so it seems that it is an extended id. Device is not in loopback mode.

If possible to try with the loopback mode (more easier to debug) and send your project so we could help efficiently + what STM32G4 part number are you using?

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
PS:
1 - This is NOT an online support (https://ols.st.com) but a collaborative space.
2 - Please be polite in your reply. Otherwise, it will be reported as inappropriate and you will be permanently blacklisted from my help.