cancel
Showing results for 
Search instead for 
Did you mean: 

How do you set CAN Filter to allow only exact CAN IDs?

SLam.1
Associate

I am trying to set the CAN bus rx filter so that only the CAN message IDs that I specify in the can_lld_cfg.c file will be received. I tried to use the CAN classic filter setup for extended IDs. I set the mask to all ones (0x0fFFFFFFUL) so, it should only allow IDs with exact matches. The snippet of the filter is below:

  /* rx extended buffer filters */

 {

 {0x18fff180UL,0x0fFFFFFFUL,CAN_FILTER_CLASSIC,CAN_FIFO0}, /* Extended filter 0*/

 {0x18ff1680UL,0x0fFFFFFFUL,CAN_FILTER_CLASSIC,CAN_FIFO0}, /* Extended filter 1*/

 },

/* number of standard filters */

 0U,

/* number of extended filters */

 2U,

I would expect that the above filter would only allow exact matches to the IDs to be received and only if IDs matching 0x18fff180UL or 0x18ff1680UL would be allowed.

However, I am sending CAN IDs 18FE4DFE, 18FE4EFE, 18FEF1FE and 18FD16FE and all of them are being received by the system. I don't understand why this is happening, since none of the IDs match the filter and they should all be rejected.

I tried to use the CAN_FILTER_RANGE setting such as this.

 {0x18fff180UL,0x18fff180UL,CAN_FILTER_RANGE ,CAN_FIFO0}, /* Extended filter 0*/

But this still fails to filter out IDs that are not set in the filter. The processor is SPC582B60E1 and the can_lld_cfg.c file is attached. What am I doing wrong? Thanks.

This discussion has been locked for participation. If you have a question, please start a new topic in order to ask your question
0 REPLIES 0