Skip to main content
Ukazu
Associate III
November 28, 2023
Solved

about filter settings for receiving extended IDs.

Hi

I don't know how to configure the CAN filter bank registers to receive extended IDs in ID list mode.
Naturally, I read the manual, but there was no explanation.

Even if there was, it would probably be difficult to understand.

 

I found the following diagram in the manual.

c013.PNG

I would like to know the settings of the filter bank register to receive 0x18DAF1DA.

Please tell me the code for ???? using canId variable

canId = 0x18DAF1DA

sFilterConfig.FilterMode = CAN_FILTERMODE_IDLIST;
sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
sFilterConfig.FilterIdHigh = ????
sFilterConfig.FilterIdLow = ????
sFilterConfig.FilterMaskIdHigh = ????
sFilterConfig.FilterMaskIdLow = ????

Since it is in ID list mode, you can set two CAN IDs, but the same setting is fine.

It seems that the IDE bit needs to be set to 1....

 

Help Me!!

 

 

 

This topic has been closed for replies.
mƎALLEm
mƎALLEmBest answer
ST Technical Moderator
November 28, 2023

Hello,

I didn't test it but try this:

#define REMOTE_FRAME 0 /* If = 1 the frame should be a remote frame. If = 0 the frame will be either remote or data frame */
#define EXTID 1 /* If = 0 the frame should be a frame with standard ID. If = 1 the frame should be a frame with extended ID */
#define ID 0x18DAF1DA /* The ID value */
#define MASK 0x1FFFFFFF /* The mask value */
#define FILTER_ID ((ID << 3) | (REMOTE_FRAME<<1) | (EXTID <<2)) 
#define FILTER_MASK ((MASK << 3) | (REMOTE_FRAME<<1) | (EXTID <<2)) 

.
.
 sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
 sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
 sFilterConfig.FilterIdHigh = (FILTER_ID >> 16); // Filter ID MSB (FxFR2[0:15])
 sFilterConfig.FilterIdLow = (FILTER_ID & 0xFFFF); // Filter ID LSB (FxFR1[0:15])
 sFilterConfig.FilterMaskIdHigh = (FILTER_MASK >> 16); // Filter Mask MSB (FxFR2[16:31])
 sFilterConfig.FilterMaskIdLow = (FILTER_MASK & 0xFFFF); // Filter Mask LSB (FxFR1[16:31])	
To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.

5 replies

mƎALLEm
mƎALLEmBest answer
ST Technical Moderator
November 28, 2023

Hello,

I didn't test it but try this:

#define REMOTE_FRAME 0 /* If = 1 the frame should be a remote frame. If = 0 the frame will be either remote or data frame */
#define EXTID 1 /* If = 0 the frame should be a frame with standard ID. If = 1 the frame should be a frame with extended ID */
#define ID 0x18DAF1DA /* The ID value */
#define MASK 0x1FFFFFFF /* The mask value */
#define FILTER_ID ((ID << 3) | (REMOTE_FRAME<<1) | (EXTID <<2)) 
#define FILTER_MASK ((MASK << 3) | (REMOTE_FRAME<<1) | (EXTID <<2)) 

.
.
 sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
 sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
 sFilterConfig.FilterIdHigh = (FILTER_ID >> 16); // Filter ID MSB (FxFR2[0:15])
 sFilterConfig.FilterIdLow = (FILTER_ID & 0xFFFF); // Filter ID LSB (FxFR1[0:15])
 sFilterConfig.FilterMaskIdHigh = (FILTER_MASK >> 16); // Filter Mask MSB (FxFR2[16:31])
 sFilterConfig.FilterMaskIdLow = (FILTER_MASK & 0xFFFF); // Filter Mask LSB (FxFR1[16:31])	
To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Ukazu
UkazuAuthor
Associate III
November 28, 2023

@mƎALLEm 

Thank you for your advice!

After looking at your sample code, my doubts are gone.

This code is great!

 

 

 

mƎALLEm
ST Technical Moderator
November 29, 2023

Hello @Ukazu 

Thank your for the feedback.

Just wanted to check if my sample code worked fine from your side?

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.