cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f103rg can filter

melihcicek
Associate II
Posted on March 08, 2011 at 10:19

stm32f103rg can filter

4 REPLIES 4
melihcicek
Associate II
Posted on May 17, 2011 at 14:27

any idea?

Posted on May 17, 2011 at 14:27

any idea?

 

 

You could always use Google, it's quite effective.

With a little thought the following would appear to be the syntax you want. No doubt you could add additional filters, going to different FIFO's. I'd tell you how, but I'd have to read the manual.

    CAN_FilterInitStructure.CAN_FilterNumber = 0;

    CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask;

    CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit;

    CAN_FilterInitStructure.CAN_FilterIdHigh = 0x0000;

    CAN_FilterInitStructure.CAN_FilterIdLow = 0x07E0;

    CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x0000;

    CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x07E0; // 0111 111x xxxx (7E0..7FF)

    CAN_FilterInitStructure.CAN_FilterFIFOAssignment = 0;

    CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;

    CAN_FilterInit(&CAN_FilterInitStructure);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
melihcicek
Associate II
Posted on May 17, 2011 at 14:27

Hi clive!

You are right i used google but for can bus filter there are different infos for example someone said this work for 7E8-7FF like this:

CAN_FilterInitStructure.CAN_FilterScale=CAN_FilterScale_32bit;

CAN_FilterInitStructure.CAN_FilterIdHigh=(Ou32) 0x07E8 << 5;

CAN_FilterInitStructure.CAN_FilterIdLow = (Ou32) ((Ou32)((Ou32) 0x7E8 << 21) & (Ou32)0xFFFFFFFF);

CAN_FilterInitStructure.CAN_FilterMaskIdHigh=(Ou32) 0x00000FF8 << 5;

CAN_FilterInitStructure.CAN_FilterMaskIdLow=(Ou32) 0x00000FF8 << 21;

CAN_FilterInitStructure.CAN_FilterFIFOAssignment=CAN_FIFO0;

CAN_FilterInitStructure.CAN_FilterActivation=ENABLE;

CAN_FilterInit(&CAN_FilterInitStructure);

So I confused how will i use

i didn understand why he make left shift 5 times or 21 times

Regards

Posted on May 17, 2011 at 14:27

So I confused how will i use

 

i didn understand why he make left shift 5 times or 21 times

 

The Hi/Lo portions are 16-bit wide (21 - 16 = 5), and they are stuffing a 32-bit pattern into the split registers. The placement might relate to the use of Standard or Extended ID's.

If you look at your unfiltered data, it should be pretty evident where the 11-bit ID you are looking for is placed. Can you experiment with this?

Most examples I've seen place it in the low order word.

http://users.ece.utexas.edu/~valvano/EE345MSp10/view15_CAN.doc

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..