cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with can filtering

ian
Associate II
Posted on December 08, 2008 at 06:19

Problems with can filtering

2 REPLIES 2
ian
Associate II
Posted on May 17, 2011 at 12:54

Hi

Am trying to use the HW filter on the stm32 allow only certain message into my system.

Am having a few problems which leads me to think that the CAN filter is not working.

I set the filter up as shown

CAN_FilterInitStructure.CAN_FilterNumber = 1;

CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask;

CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit;

CAN_FilterInitStructure.CAN_FilterIdHigh = 0x0000;

CAN_FilterInitStructure.CAN_FilterIdLow = 0x8102;

CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x0000;

CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x8102;

CAN_FilterInitStructure.CAN_FilterFIFOAssignment = CAN_FIFO0;

CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;

CAN_FilterInit(&CAN_FilterInitStructure);

And here is a sample of some messages i can see on the bus

0x048081B2

0x0E808001

0x048061B0

0x0E806001

0x00008102

The stm32 does not pick any of these messages:

Change the setting to

CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x0000;

CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x0000;

And here is a sample of some messages i can see on the bus

Ext ID = 0x048061B6

Ext ID = 0x0E806001

Ext ID = 0x1A802303

Ext ID = 0x1A802303

I am interestd in the ID 0x1A8023??, so I change settings to

CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x1A80;

CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x23FF;

i can see these messages on the bus

Ext ID = 0x1A802303

Ext ID = 0x0E806001

but the CAN filter does not allow message to pass into the system

I change the setting to

CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x1A80;

CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x2300;

the only message i message i can see is

0x00008102

Can anyone help here??

I really dont want to manually filter the ID i.e. if (ID == wantedID).

Is anyone else use the CAN bus on the stm32 can anyone suggest a suitable alternative if I can get this working?

stevemelnikoff9
Associate II
Posted on May 17, 2011 at 12:54

Quote:

I am interestd in the ID 0x1A8023??, so I change settings to

CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x1A80;

CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x23FF;

i can see these messages on the bus

Ext ID = 0x1A802303

Ext ID = 0x0E806001

but the CAN filter does not allow message to pass into the system

I change the setting to

CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x1A80;

CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x2300;

the only message i message i can see is

0x00008102

Can anyone help here??

The filter mask registers are 0 for ''don't care'', and 1 for ''must match'' (RM0008 STM32F10xxx Reference Manual v6, p537).

So to match 0x1A8023?? - i.e. everything except the last two bytes:

  • Filter mask ID = 0x1FFFFF00

  • Filter ID = 0x0x1A802300

    Note that the IDE bit needs to match as well - though the firmware library may do this for you.

    Steve.