STMicroelectronics/STM32CubeH7

FDCAN HAL_FDCAN_ConfigGlobalFilter() doesnt filter

cstyx opened this issue · 4 comments

Describe the set-up

  • STM32 NUCLEO-H723 board
  • STM32 CubeIDE 1.15.1 Build: 21094_20240412_1041 (UTC)
  • H723 firmware FW_H7 V1.11.2

Describe the bug

  • FDCAN_RxHeaderTypeDef property data_length is always 0 when receiving FDCAN messages

How To Reproduce

  • set up two boards H723A and H723B for FDCAN (no bit rate switching)
  • both use same initialization code, but different filter IDs
  • let H723A be the sender and H723B the receiver
canFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO1;
canFilterConfig.IdType = FDCAN_EXTENDED_ID;
canFilterConfig.FilterType = FDCAN_FILTER_MASK;
  1. receive H723B FAIL
  • FilterID2 matches the only incomming CAN ID (0x1FFFFFFF matches all 29Bit)
  • gobal reject all non matching CAN IDs
  • should be receiving since FIlterID2 matches the send ID and the global filter rejects all other CAN IDs (no others are send, so nothing left to reject)
canFilterConfig.FilterID1 = own_address;	// canIdentifier
canFilterConfig.FilterID2 = 0x1FFFFFFF;		// mask: 0 => accept all messages
	
HAL_FDCAN_ConfigGlobalFilter(&hfdcan2,
			FDCAN_REJECT,
			FDCAN_REJECT,
			FDCAN_FILTER_REMOTE,
			FDCAN_FILTER_REMOTE);
  1. receive H723B FAIL
  • FilterID2 match all CAN IDs
  • gobal reject all non matching CAN IDs
  • should be receiving since the FilterID matches all CAN IDs and the global filter rejects all other CAN IDs (no others are send, so nothing left to reject)
canFilterConfig.FilterID1 = own_address;	// canIdentifier
canFilterConfig.FilterID2 = 0;			// mask: 0 => accept all messages
	
HAL_FDCAN_ConfigGlobalFilter(&hfdcan2,
			FDCAN_REJECT,
			FDCAN_REJECT,
			FDCAN_FILTER_REMOTE,
			FDCAN_FILTER_REMOTE);

  1. receive H723B OK
  • FilterID2 matches the only incomming CAN ID (0x1FFFFFFF matches all 29Bit)
  • gobal accept all non matching CAN IDs
  • receives since all IDs are allowed by global filter
canFilterConfig.FilterID1 = own_address;	// canIdentifier
canFilterConfig.FilterID2 = 0x1FFFFFFF;		// mask: 0 => accept all messages
	
HAL_FDCAN_ConfigGlobalFilter(&hfdcan2,
			FDCAN_ACCEPT_IN_RX_FIFO1,
			FDCAN_ACCEPT_IN_RX_FIFO1,
			FDCAN_FILTER_REMOTE,
			FDCAN_FILTER_REMOTE);
  1. receive H723B OK

FilterID2 matches the all incomming CAN IDs
gobal accept all non matching CAN IDs
receives since all ID are allowed by FilterID2 and by global filter

canFilterConfig.FilterID1 = own_address;	// canIdentifier
canFilterConfig.FilterID2 = 0;		// mask: 0 => accept all messages
	
HAL_FDCAN_ConfigGlobalFilter(&hfdcan2,
			FDCAN_ACCEPT_IN_RX_FIFO1,
			FDCAN_ACCEPT_IN_RX_FIFO1,
			FDCAN_FILTER_REMOTE,
			FDCAN_FILTER_REMOTE);

Not calling HAL_FDCAN_ConfigGlobalFilter() at all will lead to no received message.

In my understanding 1. and 2. should receive too. I seems like either the FilterID2 is set false, or that FDCAN_REJECT recjects always, despite any FilterID2 setting.

Testproject
Attached is a test project using 2 NUCLEO-144-H723 boards using FDCAN2, where H723A is the sender and H723B is the receiver.

The sender will send an extended FDCAN message every second, indicated by the RED on-board LED toggling. Every successful received extended FDCAN message at the receiver will be indicated by a toggled GREEN on-board LED. Both H723A/B use the same project code, two #defines select the task.

Setup the sender H723A

uncomment line 105 at the main.c

#define sender			// use this definition for the sender H723A

compile, program and run.

Setup the receiver H723B

comment out line 105 at the main.c

//#define sender			// use this definition for the sender H723A
  1. setup for successful receiving

uncomment line 188 at the ProcessCAN.c

#define RECEIVE_SUCCSEFUL

compile, program and run.

The receiver will use the following global CAN filter setup

// EITHER uncomment this and GREEN BOARD LED toggles -> receiving
HAL_FDCAN_ConfigGlobalFilter(&hfdcan2,
   		FDCAN_ACCEPT_IN_RX_FIFO1,
   		FDCAN_ACCEPT_IN_RX_FIFO1,
   		FDCAN_FILTER_REMOTE,
   		FDCAN_FILTER_REMOTE);
  1. setup for unsuccessful receiving

comment out line 188 at the ProcessCAN.c

//#define RECEIVE_SUCCSEFUL

compile, program and run.

The receiver will use the following global CAN filter setup, which should allow the message to pass the filter, but it doesn't.

// OR uncomment this and GREEN BOARD LED does not toggle -> not receiving
HAL_FDCAN_ConfigGlobalFilter(&hfdcan2,
   		FDCAN_REJECT,
   		FDCAN_REJECT,
   		FDCAN_FILTER_REMOTE,
   		FDCAN_FILTER_REMOTE);

NUCLEO - H723 - FDCAN - Test.zip