2019-07-16 01:03 AM
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
2019-07-16 05:02 AM
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.
2019-07-16 06:27 AM
sFilterConfig.FilterIdHigh = STDID << 5; // Standard ID is top 11 high bits
sFilterConfig.FilterIdMaskIdHigh = 0x7FF < 5;
Review how the bits within the ExtID map
2019-07-16 06:32 AM
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
2019-07-16 06:50 AM
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
2019-07-31 06:14 AM
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
2024-05-07 04:33 AM
Hi Man
This is for IDMASK mode,
If I want to configure the filter in IDLIST mode, how can I do that?
2024-05-07 05:45 AM
Hello @Narendran , and welcome to the community.
Could you please open a new thread for your question? and please specify the product you are using.
Thank you.