cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure FDCAN receive filter configuration for multiple message ID's?

Pavankumar1_
Associate II

Hi

I am using STM32H747I-DISCO board, where I am using FDCAN module, I tried with external loop back mode with FDCAN1 able to transmit and receive single message ID, but i want to transmit three message ID's and receive the data as per the message ID's. But I don't how to configure for multiple messages ID's please someone suggest any example with multiple message ID transmit and receive.

1 ACCEPTED SOLUTION

Accepted Solutions
SofLit
ST Employee

Hello, and sorry for the late answer.

To receive specific IDs you can use either DUAL filter or filter Mask.

Example: 

If you want to receive only the two standard IDs: 0x111 and 0x555, you can use filter in DUAL mode:

 

  sFilterConfig.IdType = FDCAN_STANDARD_ID;
  sFilterConfig.FilterIndex = <you need to define the index>;
  sFilterConfig.FilterType = FDCAN_FILTER_DUAL;
  sFilterConfig.FilterConfig = <you need to define the filter config>;
  sFilterConfig.FilterID1 = 0x111;
  sFilterConfig.FilterID2 = 0x555;
  HAL_FDCAN_ConfigFilter(&hfdcan1, &sFilterConfig); 

 

If you want to receive only one standard ID: 0x222 you have to use filter in Mask mode:

 

  sFilterConfig.IdType = FDCAN_STANDARD_ID;
  sFilterConfig.FilterIndex = <you need to define the index>;
  sFilterConfig.FilterType = FDCAN_FILTER_MASK;
  sFilterConfig.FilterConfig = <you need to define the filter config>;
  sFilterConfig.FilterID1 = 0x222;
  sFilterConfig.FilterID2 = 0x7FF;
  HAL_FDCAN_ConfigFilter(&hfdcan1, &sFilterConfig); 

 

if you use the two configs you will receive only 3 messages with IDs: 0x111, 0x555 and 0x222.

Attached a project on which I used NUCLEO-H743 / FDCAN in loopback mode (you can port it easily to STM32H747I-DISCO board). In while(1) loop all IDs are transmitted from ID=0x0 to 0x7FF are send to sweep all the STD ID range. CAN frames with message IDs 0x111 and 0x555 will be received on FIFO0 and the CAN frame with message ID 0x222 will be received on FIFO1. 

Hope it helps

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.

View solution in original post

1 REPLY 1
SofLit
ST Employee

Hello, and sorry for the late answer.

To receive specific IDs you can use either DUAL filter or filter Mask.

Example: 

If you want to receive only the two standard IDs: 0x111 and 0x555, you can use filter in DUAL mode:

 

  sFilterConfig.IdType = FDCAN_STANDARD_ID;
  sFilterConfig.FilterIndex = <you need to define the index>;
  sFilterConfig.FilterType = FDCAN_FILTER_DUAL;
  sFilterConfig.FilterConfig = <you need to define the filter config>;
  sFilterConfig.FilterID1 = 0x111;
  sFilterConfig.FilterID2 = 0x555;
  HAL_FDCAN_ConfigFilter(&hfdcan1, &sFilterConfig); 

 

If you want to receive only one standard ID: 0x222 you have to use filter in Mask mode:

 

  sFilterConfig.IdType = FDCAN_STANDARD_ID;
  sFilterConfig.FilterIndex = <you need to define the index>;
  sFilterConfig.FilterType = FDCAN_FILTER_MASK;
  sFilterConfig.FilterConfig = <you need to define the filter config>;
  sFilterConfig.FilterID1 = 0x222;
  sFilterConfig.FilterID2 = 0x7FF;
  HAL_FDCAN_ConfigFilter(&hfdcan1, &sFilterConfig); 

 

if you use the two configs you will receive only 3 messages with IDs: 0x111, 0x555 and 0x222.

Attached a project on which I used NUCLEO-H743 / FDCAN in loopback mode (you can port it easily to STM32H747I-DISCO board). In while(1) loop all IDs are transmitted from ID=0x0 to 0x7FF are send to sweep all the STD ID range. CAN frames with message IDs 0x111 and 0x555 will be received on FIFO0 and the CAN frame with message ID 0x222 will be received on FIFO1. 

Hope it helps

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.