2025-01-29 03:15 AM - last edited on 2025-01-29 03:20 AM by SofLit
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?
2025-01-29 03:23 AM
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?
2025-01-29 04:05 AM
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.
2025-01-29 05:08 AM - edited 2025-01-29 07:08 AM
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?