Skip to main content
HKim.23
Associate III
April 14, 2023
Solved

How to set FDCAN Masking Filter with stm32H503?

  • April 14, 2023
  • 1 reply
  • 3053 views

I am using STM32H503.

I want to receive only incoming ids as 0x222 using masking .

If set like the code below, IDs other than 0x222 are also entered into the rx callback function. Is there something wrong with the masking process?

FDCAN_FilterTypeDef sFilterConfig;
 
 sFilterConfig.IdType = FDCAN_STANDARD_ID;
 sFilterConfig.FilterIndex = 0;
 sFilterConfig.FilterType = FDCAN_FILTER_MASK;
 sFilterConfig.FilterConfig = FDCAN_FILTER_TO_RXFIFO0;
 sFilterConfig.FilterID1 = 0x222;
 sFilterConfig.FilterID2 = 0x7FF;
 
 if(HAL_FDCAN_ConfigFilter(&hfdcan1, &sFilterConfig) != HAL_OK)
 {
 Error_Handler();
 }

This topic has been closed for replies.
Best answer by LCE

My notes tell me:

/*
RX
FIFO vs buffer:
	- RX buffer is only filled when buffers's specific FILTER is matched
	- FIFO is better for filter ranges / bit masks
 
LISTENING:
	if global reject is NOT turned on with HAL_FDCAN_ConfigGlobalFilter(),
	then all messages are received in
	RX FIFO 0
 
CAN to IP:
	- in RX ISR:
		- take timestamp
		- prepare buffer
		- set flag
 
*/

Therefore, put at the end of the init function, before starting the peripheral:

	/* Configure global filter to reject all non-matching frames */
	HAL_FDCAN_ConfigGlobalFilter(phCan, FDCAN_REJECT, FDCAN_REJECT, FDCAN_REJECT_REMOTE, FDCAN_REJECT_REMOTE);

1 reply

LCE
LCEBest answer
Principal II
April 14, 2023

My notes tell me:

/*
RX
FIFO vs buffer:
	- RX buffer is only filled when buffers's specific FILTER is matched
	- FIFO is better for filter ranges / bit masks
 
LISTENING:
	if global reject is NOT turned on with HAL_FDCAN_ConfigGlobalFilter(),
	then all messages are received in
	RX FIFO 0
 
CAN to IP:
	- in RX ISR:
		- take timestamp
		- prepare buffer
		- set flag
 
*/

Therefore, put at the end of the init function, before starting the peripheral:

	/* Configure global filter to reject all non-matching frames */
	HAL_FDCAN_ConfigGlobalFilter(phCan, FDCAN_REJECT, FDCAN_REJECT, FDCAN_REJECT_REMOTE, FDCAN_REJECT_REMOTE);

HKim.23
HKim.23Author
Associate III
April 14, 2023

solved!!

Thank you twice.​