cancel
Showing results for 
Search instead for 
Did you mean: 

CAN Filter ExtID

AJouv
Associate II

Hi,

I want to setup the CAN filter but I don't understand how to do so.

I have made lot of test but nothing work fine.

I want to have only message 0x18FF01D0, 0x18FF02D0, 0x18FF03D0, 0x18FF05D0, 0x18FF07D0, 0x18FF0CD0 and a stdID 0x401.

To test to have only message 0x18FF01D0 I have set my filter as:

CAN_FilterTypeDef  		sFilterConfig;
	sFilterConfig.FilterBank = 0;
	sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
	sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
	sFilterConfig.FilterIdHigh = 0x18FF;
	sFilterConfig.FilterIdLow = 0x01D0;
	sFilterConfig.FilterMaskIdHigh = 0x18FF;
	sFilterConfig.FilterMaskIdLow = 0x01D0;
	sFilterConfig.FilterFIFOAssignment = 0;
	sFilterConfig.FilterActivation = ENABLE;
	sFilterConfig.SlaveStartFilterBank = 14;
 
	if (HAL_CAN_ConfigFilter(&hcan1, &sFilterConfig) != HAL_OK)

I have set the Id and the mask to the same value because I want to have exactly 0x18FF01D0 value and only this one.

I know the formula:

if ((ID & MASK) == COMP) then AddToFifo

But for ExtId I'm not sure if it works?

Thanks in advence for you help

5 REPLIES 5

Putting the same value in the mask doesn't guarantee singular hits, that's not how the logic works here. Review what a logical AND does.

For bits on the wire and where the ID bits fall in the register, review the diagrams in the Reference Manual, and attached to several posts. You're probably going to need to shift bits around, and mask out irrelevant ones.​

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

sFilterConfig.FilterIdHigh = STDID << 5; // Standard ID is top 11 high bits

sFilterConfig.FilterIdMaskIdHigh = 0x7FF < 5;

0690X000009YnmDQAS.jpg

Review how the bits within the ExtID map

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

Thanks so much Clive.

But on my side I want to use Extended ID, and you talk about SDTID.

I know this figure of the RM, but with it I don't know how to setup the parameters for the ExtID.

Thanks Clive for your feedback

I mentioned STDID because it provides CONTEXT to the diagram

Where ExtID is 29-bit value

Hi = EXTID >> 13

Lo = (EXTID << 3) | 4

HiMask = 0xFFFF

LoMask = 0xFFFD

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

Hi Clive,

Thanks so much for your answer, sorry for the delais but I was in vacation and then in buisness trip.

If I understand your explaination, you don't use the MASK?

Is it requested to create 1 filter per frame which I want to received ??

Thanks I advance for your help