CAN message acceptance filtering -- C_CAN on-chip driver

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CAN message acceptance filtering -- C_CAN on-chip driver

Jump to solution
2,061 Views
ekki
Contributor III

Hello,

does anybody know how the message filtering works, using the C_CAN on-chip driver?

In the example  from "nxp_lpcxpresso_11c24_periph_ccan_rom" there is written value 0x700 to the mask register and 0x400 to the mode_id register, to accept message with id's from 0x400 to 0x4FF.

But still I could not figure out e.g. how to create an acceptance filter range from 0x100 to 0x129? 

What is the logic relation from mode_id and mask register to accept message id ranges???

I apreciate any hint.

Ekki

Labels (1)
Tags (1)
0 Kudos
1 Solution
1,128 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Ekkehard,

Thank you for your interest in NXP LPC product, I would like to provide service for you!
You are misunderstanding the CAN filter range.
Actually, it is not the range for the acceptance filter, the acceptance filter is judge whether the receive ID bit should the same with mode_id.
Now, use the example to describe it.
1.  receive all 11-bit messages 0x400-0x4ff
    msg_obj.msgobj = 1;
    msg_obj.mode_id = 0x400;//// define the ID compare data
    msg_obj.mask = 0x700; //define which receive ID bit should be ignored, and which ID bit should be the same as the according bit in mod_id.0, ignored, 1, must the same as mod_id.

=======================================================================

msg_obj.mode_id = 0x400 = 0b100 0000 0000  (11bits)

msg_obj.mask     = 0x700  = 0b111 0000 0000  (11bits) 1, means receive the standard ID bit9,10,11 must be the same as 100.

So, MCU can receive  standard ID is:0b100 xxxx xxxx , it is 0x400- 0x4ff.

2. receive all 11-bit message 00x400-0x40f
    msg_obj.msgobj = 1;
    msg_obj.mode_id = 0x400;// define the ID compare data
    msg_obj.mask = 0x7f0;

=======================================================================

msg_obj.mode_id = 0x400 = 0b100 0000 0000  (11bits)

msg_obj.mask     = 0x7f0   = 0b111 1111 0000  (11bits) 1, means receive the standard ID bit9,10,11 must be the same as 100.

So, MCU can receive  standard ID is:0b100 0000 xxxx , it is 0x400- 0x40f.

msg_obj.mask is defined 11bits data, this data is used to define the MSK1, MSK2 register, this two register is defining whether the received ID bit should for acceptance filter.

pastedImage_1.png

If you want to receive the standard ID:0X100 ~0X129, you can't configure it directly, the closely data is 0x100-0x13f, let me tell you why.

0X100= 0b 001 0000 0000 (11bits)

0x129= 0b 001 0010 1001 (11 bits)

As you know, you should configure msg_obj.mask to 0b111 1100 0000, because in your 0X100-0X129 range, bit0- bit5 all can be 0 or 1, so you should ignore bit0- bit5.

Then configure your code like this :

    msg_obj.msgobj = 1;
    msg_obj.mode_id = 0x100;//
    msg_obj.mask = 0x7c0;

So, actually, you can receive the standard ID from 0X100 to 0x13f.

Wish it helps you!

If you still have question, please contact me!

Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

2 Replies
1,128 Views
ekki
Contributor III

Perfect answer. Thank you very much for the efford you spend for the detailed explanation.

Regards,

Ekkehard

0 Kudos
1,129 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Ekkehard,

Thank you for your interest in NXP LPC product, I would like to provide service for you!
You are misunderstanding the CAN filter range.
Actually, it is not the range for the acceptance filter, the acceptance filter is judge whether the receive ID bit should the same with mode_id.
Now, use the example to describe it.
1.  receive all 11-bit messages 0x400-0x4ff
    msg_obj.msgobj = 1;
    msg_obj.mode_id = 0x400;//// define the ID compare data
    msg_obj.mask = 0x700; //define which receive ID bit should be ignored, and which ID bit should be the same as the according bit in mod_id.0, ignored, 1, must the same as mod_id.

=======================================================================

msg_obj.mode_id = 0x400 = 0b100 0000 0000  (11bits)

msg_obj.mask     = 0x700  = 0b111 0000 0000  (11bits) 1, means receive the standard ID bit9,10,11 must be the same as 100.

So, MCU can receive  standard ID is:0b100 xxxx xxxx , it is 0x400- 0x4ff.

2. receive all 11-bit message 00x400-0x40f
    msg_obj.msgobj = 1;
    msg_obj.mode_id = 0x400;// define the ID compare data
    msg_obj.mask = 0x7f0;

=======================================================================

msg_obj.mode_id = 0x400 = 0b100 0000 0000  (11bits)

msg_obj.mask     = 0x7f0   = 0b111 1111 0000  (11bits) 1, means receive the standard ID bit9,10,11 must be the same as 100.

So, MCU can receive  standard ID is:0b100 0000 xxxx , it is 0x400- 0x40f.

msg_obj.mask is defined 11bits data, this data is used to define the MSK1, MSK2 register, this two register is defining whether the received ID bit should for acceptance filter.

pastedImage_1.png

If you want to receive the standard ID:0X100 ~0X129, you can't configure it directly, the closely data is 0x100-0x13f, let me tell you why.

0X100= 0b 001 0000 0000 (11bits)

0x129= 0b 001 0010 1001 (11 bits)

As you know, you should configure msg_obj.mask to 0b111 1100 0000, because in your 0X100-0X129 range, bit0- bit5 all can be 0 or 1, so you should ignore bit0- bit5.

Then configure your code like this :

    msg_obj.msgobj = 1;
    msg_obj.mode_id = 0x100;//
    msg_obj.mask = 0x7c0;

So, actually, you can receive the standard ID from 0X100 to 0x13f.

Wish it helps you!

If you still have question, please contact me!

Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------