Skip to main content
Visitor II
July 16, 2019
Question

CAN Filter ExtID

  • July 16, 2019
  • 2 replies
  • 2805 views

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

    This topic has been closed for replies.

    2 replies

    Graduate II
    July 16, 2019

    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.​

    Graduate II
    July 16, 2019

    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

    AJouvAuthor
    Visitor II
    July 16, 2019

    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

    AJouvAuthor
    Visitor II
    July 31, 2019

    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