msCAN xep100: Implementation of acceptance filtering

cancel
Showing results for 
Search instead for 
Did you mean: 

msCAN xep100: Implementation of acceptance filtering

272 Views
mandarsansare
Contributor I

Hello,

I want to implement acceptance filtering for can message. Using msCAN XEP100.

For eg i want to filter msg id: 1234

for this i have configured below things

if( Init_CAN (2,FAST) == ERR_OK_CAN)
{
err_temp = Config_CAN_MB(2,0,TXDF,0);
err_temp |= Config_CAN_MB(2,1,TXDF,0);
err_temp |= Config_CAN_MB(2,2,TXDF,0);
err_temp |= Config_CAN_MB(2,3,TXDF,0);
err_temp |= Config_CAN_MB(2,4,RXDF,0);
err_temp |= Config_CAN_MB(2,5,RXDF,0);
err_temp |= Config_CAN_MB(2,6,RXDF,0);
err_temp |= Config_CAN_MB(2,7,RXDF,0);

if(err_temp != ERR_OK_CAN)
{
ErrorLog(CAN_BUS_INIT_FAULTCODE);
}
}

and for filtering i have used the below part

#define ID_MASK0_CAN2 0x00
#define ID_MASK1_CAN2 0x00

#define ID_CODE0_CAN2 0x9A
#define ID_CODE1_CAN2 0x40

what is significance of AIdentifierRef in below function defination?

uint8 Config_CAN_MB(uint8 AChn, uint8 ABuffer, uint8 ACmode, uint8 AIdentifierRef)

additionaly i have defined below things

#define MO0_ID_TYPE_CAN2 CAN_STANDARD
#define MO0_ID_CAN2 0x4D2

after updating the MO0_ID i was able to filter the msg ID.

I want to filter more signals for this, how to handle MOx_ID_CAN thing for filtering.

what is difference between msg buffer and msg object.

It will be helpful if anyone can provide more documentation or sample code for acceptance filtering usage in msCAN driver

0 Kudos
1 Reply

62 Views
lama
NXP TechSupport
NXP TechSupport

Hi,

Because, you present ID corresponding to extended ID I will use answer I have already provided to another guy.

 

„We are  using Extended identifier. And we want to be able to receive two CAN IDs, 0x41 and 0xff.

 

According to the data sheet, it is set using a combination of CANIDMR & CANIDAR.

But I did not understand the explanation in the datasheet. and my customer too.

Please provide register value and explanation about the setting value.“

 

The explanation is for two IDs. However, if you want to filter the only one ID then both filters should be set in the same way.

 

Answer was:

 

Because you use extended identifier I suggest to use 2x32bit filter. In this case we do not have to think about unused filers because all IDAR and IDMR registers are covered by this size of filter. Moreover, it enables using only two filters which is enough for you now - you need only two exact numbers. The issue would be if you need more than two exact filters. In this case either filter logic including IDAR logic should be implemented and specific IDs must be selected or  4x16b filters should be used which, however, will accept all IDs with correct lower 16bits and any value in higher 16bit of ID - so additiona SW filter should be added.

I suppose you want to receive data frames only so I will set RTR to 0. (remote frames are filtered out)

CANIDAC=0x00; // select 2x32bit filters// exact filter ID= 0x41, Data frames only are accepted (no remote frame)

CANIDAR0 = 0x00;

CANIDMR0 = 0x00;

CANIDAR1 = 0x18;   // SRR=IDE=1CANIDMR1 = 0x00;

CANIDAR2 = 0x00;

CANIDMR2 = 0x00;

CANIDAR3 = 0x82;

CANIDMR3 = 0x00;

 

// exact filter ID= 0xFF, Data frames only are accepted (no remote frame)

CANIDAR4 = 0x00;

CANIDMR4 = 0x00;

CANIDAR5 = 0x18;   // SRR=IDE=1

CANIDMR5 = 0x00;

CANIDAR6 = 0x01;

CANIDMR6 = 0x00;

CANIDAR7 = 0xFE;

CANIDMR7 = 0x00;

Better explanation for your exact case you can find in the attached excell workbook, sheet EXTENDED ID, lines 51-56

I hope I have not made a mistake.

 

I have also attached an example I found in my PC.

 

To update this case, please reply to this email.

Some more examples I put a few days ago at: https://community.nxp.com/docs/DOC-329209

Best regards,

Ladislav

0 Kudos