cancel
Showing results for 
Search instead for 
Did you mean: 

CAN FILTERS

puneethj
Associate II
Posted on November 11, 2015 at 17:50

Hi every one, especially Mr.Clive, today i have problem with CAN FILTERS i want to allow all IDS from 100 to 1FF in other words block all messages after 0x0200

here is my code, Please help me, Thanks in advance

void CAN_FilterConfiguration(void) {
CAN_FilterInitTypeDef CAN_FilterInitStructure;
/* CAN filter configuration */
// CAN_FilterInitStructure.CAN_FilterNumber = 0; // CAN 1
CAN_FilterInitStructure.CAN_FilterNumber = 14; // CAN 2
CAN_FilterInitStructure.CAN_FilterFIFOAssignment = CAN_FIFO0; // FIFO = 0
CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask; // Filter mode = identifier mask based filtering
CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_16bit;
CAN_FilterInitStructure.CAN_FilterIdHigh = 0x0100 << 5;
CAN_FilterInitStructure.CAN_FilterIdLow = 0;
CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x01ff << 5;
CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0;
CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;
//Interrrupts
CAN_ITConfig(CAN2,CAN_IT_FMP0,ENABLE);
CAN_FilterInit(&CAN_FilterInitStructure);
}

#!stm32f4-disco #can-filter
23 REPLIES 23
Posted on March 22, 2017 at 15:28

Lot of thanks, Clive!

PRABU Appunu
Associate II

hi Clive

am working on STM32F417 with CAN extended ID .

i would like to reject the ID for example 0x0500xxxx.

I need to receive all messages which is > 0x0500xxxx.The only bit i need to check is 0x0500

I checked with ID masking mode , it was not possible to reject single ID .

I am not sure that ID list will serve this purpose .

How to reject signle ID using IDmasking or list mode ?

Appreciated to get some input

Thank YOU,

You filter the stuff you WANT to receive, it ignores the rest

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

Clive,

i supposed to receive 50 CAN devices with specific ID's.

Instead of filtering those ID's , i would like to reject one single ID from that group and received rest of them without any issue.

I just want to filter CAN ID with 0x05000xxx...rest of ID's like 0x0501XXXX ,0x0502XXXX rest of all ID's i would like to receive.

i tried in ID MASK mode

filter _id 0x05001000

mask id 0x05FFF000

here i can only receive 0x05001XXX ID's which is logical.This is working fine.

But i want to reject only 0x05000xxx ID , which i coulnd't do it with masking .

Do you see any possibility here ?

Appreciated for the help

Clive,

Did you see the any logic to reject the ID 0x0500xxx?

Thanks in advance for your help

Hi Clive,

i am facing a problem, i want to accept all messages to CAN except with the ID 0x17F00010 that uses a EXT ID. all my other messages are StdID. i am able to create filter that wastes the messages with IDs 0x10 but that also filters messages with ID like 0x710. need your help. Thanks in advance.

The filter only really allows for acceptance, you would need to have multiple filters to cherry pick things to reject by accepting everything around the specific thing you don't want. A narrow-band notch filter may be hard to achieve.

The mask should permit you to filter on STD/EXT ID. Bit 2 of the filter will be 1 for Extended Identifier Messages

What is the 29-bit ID you want to exclude? What other messages are you expecting? Create a list

0690X00000AQwEmQAL.jpg

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

i want to exclude the message with ExtId 0x17F00010 mean while i want to accept the messages with StidID 0x710.

if you can help me to make filter that passes the messages from 0x11 ...0x7FF, that will be great

Uvess.1
Associate II

hi @Community member​ ,

I tried to understand with this examples but it's not obvious for me...

For exemple we want to accept address between 0x008 and 0x04F

So Filter_id_high = 0x008<<5

but i don't know how to calculate the mask....

EDIT1: so we've (MASK & ID) = 0x008

CAN_FilterInitTypeDef CAN_FilterInitStructure;
/* CAN filter configuration */
CAN_FilterInitStructure.CAN_FilterNumber = 14;
CAN_FilterInitStructure.CAN_FilterFIFOAssignment = CAN_FIFO0; 
CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask; 
CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit;
CAN_FilterInitStructure.CAN_FilterActivation = ENABLE;
CAN_FilterInitStructure.CAN_FilterIdHigh = 0x008 << 5; //11-bit ID in top bits
CAN_FilterInitStructure.CAN_FilterIdLow = 0;
CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x??? << 5;
CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0;

Thx in advance,

Uvess