cancel
Showing results for 
Search instead for 
Did you mean: 

STL32L433 CAN filtering using mask mode

agennart
Associate

Hello,

I am currently using a STM32l433 with the following configuration:

        CAN_FilterTypeDef  CAN_FilterInitStructure = {0};
        CAN_FilterInitStructure.FilterBank = filterNum;
        CAN_FilterInitStructure.FilterScale = CAN_FILTERSCALE_16BIT;

        // 11-bits StdId left-aligned on the 32-bits word register
        CAN_FilterInitStructure.FilterIdHigh = id << 5;
        CAN_FilterInitStructure.FilterIdLow = 0;
        CAN_FilterInitStructure.FilterMaskIdHigh = mask << 5;
        CAN_FilterInitStructure.FilterMaskIdLow = 0;

        CAN_FilterInitStructure.FilterFIFOAssignment = CAN_FILTER_FIFO0;
        CAN_FilterInitStructure.FilterMode = CAN_FILTERMODE_IDMASK;

 

It globally works. So if my ID is 0x701 and my mask 0xFFFF, the callback will be called for every message ID 0x701.

However, when I change the mask, for exaple to a value like 0x700, in order to only get the '7' from the standard ID, my callback is not called for every message with ID 0x7__.

I also notice the that the 16bit filter lenght require the RTR, IDE and EXID (see picture below). In my case everything is set to 0. Could it be those settings are wrong ?

 

Could it be that there is something wrong with the configuration that makes the mask invalid ?

Any help is appreciated !

Thanks

agennart_0-1744871209560.png

 

0 REPLIES 0