2025-03-05 5:25 AM
New to CAN here,
Is it possible to configure the same CAN peripheral (CAN1) on an STM32F4 to receive messages from one node in RXFIFO0 and from another node in RXFIFO1?
The reason for this setup is that one of the nodes has a higher priority and I would like to separate the messages accordingly. If this is possible, how should I configure the CAN filter settings to achieve this?
Solved! Go to Solution.
2025-03-06 12:43 AM
No.
The filters need to have different CAN filter settings to ensure that one FIFO will accept a set of filters and the other will accept other sets of IDs.
2025-03-05 6:10 AM - edited 2025-03-05 6:15 AM
Hello @GHanj and welcome to the community.
Yes you can make that separation and configure the CAN peripheral to receive a set of CAN IDs on FIFO0 and the other set of IDs on FIFO1.
This is done in the filter configuration:
The message that was accepted by this filter will be received on FIFO0:
sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO0;
The message that was accepted by this filter will be received on FIFO1:
sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO1;
Hope that answers your question.
2025-03-06 12:40 AM
Thank you for your response! If I understand correctly, are you suggesting that I should configure two separate CAN_FilterTypeDef structures and assign each to a specific FIFO, like this?
void CAN_Filter0_Config(void){
CAN_FilterTypeDef canFilter0;
canFilter0.FilterActivation = ENABLE;
canFilter0.FilterBank = 0;
canFilter0.FilterFIFOAssignment = CAN_RX_FIFO0;
canFilter0.FilterIdHigh = 0x0000;
canFilter0.FilterIdLow = 0x0000;
canFilter0.FilterMaskIdHigh = 0x0000;
canFilter0.FilterMaskIdLow = 0x0000;
canFilter0.FilterMode = CAN_FILTERMODE_IDMASK;
canFilter0.FilterScale = CAN_FILTERSCALE_32BIT;
if( HAL_CAN_ConfigFilter(&hcan1, &canFilter0) != HAL_OK){
Error_Handler();
}
}
void CAN_Filter1_Config(void){
CAN_FilterTypeDef canFilter1;
canFilter1.FilterActivation = ENABLE;
canFilter1.FilterBank = 1;
canFilter1.FilterFIFOAssignment = CAN_RX_FIFO1;
canFilter1.FilterIdHigh = 0x0000;
canFilter1.FilterIdLow = 0x0000;
canFilter1.FilterMaskIdHigh = 0x0000;
canFilter1.FilterMaskIdLow = 0x0000;
canFilter1.FilterMode = CAN_FILTERMODE_IDMASK;
canFilter1.FilterScale = CAN_FILTERSCALE_32BIT;
if( HAL_CAN_ConfigFilter(&hcan1, &canFilter1) != HAL_OK){
Error_Handler();
}
}
Or are you suggesting that I should configure both FIFO assignments within a single CAN_FilterTypeDef?
2025-03-06 12:43 AM
No.
The filters need to have different CAN filter settings to ensure that one FIFO will accept a set of filters and the other will accept other sets of IDs.
2025-03-06 12:45 AM
I get it now , thank you for clarification!