2023-11-27 10:43 PM
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.
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!!
Solved! Go to Solution.
2023-11-28 07:46 AM
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])
2023-11-28 07:46 AM
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])
2023-11-28 03:22 PM
Thank you for your advice!
After looking at your sample code, my doubts are gone.
This code is great!
2023-11-29 12:19 AM
Hello @Ukazu
Thank your for the feedback.
Just wanted to check if my sample code worked fine from your side?
2023-11-29 12:26 AM
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.