cancel
Showing results for 
Search instead for 
Did you mean: 

How to set FDCAN Masking Filter with stm32H503?

HKim.23
Associate III

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();
    }

1 ACCEPTED SOLUTION

Accepted Solutions
LCE
Principal

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);

View solution in original post

2 REPLIES 2
LCE
Principal

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
Associate III

solved!!

Thank you twice.​