2023-12-21 6:30 AM - last edited on 2024-01-25 3:32 AM by mƎALLEm
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.
Solved! Go to Solution.
2024-02-20 7:55 AM - edited 2024-02-20 7:59 AM
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
2024-02-20 7:55 AM - edited 2024-02-20 7:59 AM
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