cancel
Showing results for 
Search instead for 
Did you mean: 

about filter settings for receiving extended IDs.

Ukazu
Associate III

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!!

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SofLit
ST Employee

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 on "Accept as Solution" on the reply which solved your issue or answered your question.

View solution in original post

4 REPLIES 4
SofLit
ST Employee

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 on "Accept as Solution" on the reply which solved your issue or answered your question.

@SofLit 

Thank you for your advice!

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

This code is great!

 

 

 

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 on "Accept as Solution" on the reply which solved your issue or answered your question.

@SofLit 

 

Hi

The design department is currently developing the board.
Therefore, it will be a while before you can actually try this sample code.

I'm currently writing a software design document.

When the board is completed I will post the results in this thread.