LPC11C24 multiple CAN filters

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

LPC11C24 multiple CAN filters

2,348 Views
ruslan1
Contributor II

I try to set several CAN filters in my application. For some reason only the first one is taken into account. My code:

ROM **rom = (ROM **)0x1fff1ff8;

void set_filter( uint8_t can_msg_obj, uint32_t msg_filter_id, uint32_t msg_filter_mask)

{
    CAN_MSG_OBJ can_filter;
    can_filter.msgobj = can_msg_obj;
    can_filter.mode_id = msg_filter_id;
    can_filter.mask = msg_filter_mask;
    (*rom)->pCAND->config_rxmsgobj(&can_msg_filer);
}

(*rom)->pCAND->init_can(&ClkInitTable[0], 1);
(*rom)->pCAND->config_calb(&callbacks);

NVIC_EnableIRQ(CAN_IRQn);

set_filter(1, 0x100, 0x700);

set_filter(2, 0x200, 0x700);

So when I send a CAN message with ID:100 I can see that CAN_rx has called. when I send a CAN message with ID:200 nothing happens.

Sure, I can set filter 0x0 with mask 0x0 and so receive all the messages but I still look for the right solution with filters. 

Labels (1)
Tags (2)
0 Kudos
Reply
11 Replies

2,140 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Muhlinin Ruslan,

Sorry to reply you late, I just got my board.

After check and test your code on my side, the issue is the

pastedImage_1.png

the same with the code in "CAN_rx()"

pastedImage_2.png

Change one of them to 3 will fix the issue.

I use a CAN bus tool on PC communicate with LPC11c24 board, and take a video about on my side, please check my attachment.

Hope it helps,

Have a great day,
TIC

 

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

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply

2,140 Views
ruslan1
Contributor II

Thanks Alice_Yang, you are just genius! I really didn't pay attention to this. Your answer really helped me a lot. Thank you so much for your efforts.

0 Kudos
Reply

2,140 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Muhlinin Ruslan,

Welcome!

Have a great day,
TIC

 

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

 

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply

2,140 Views
ruslan1
Contributor II
0 Kudos
Reply

2,140 Views
ruslan1
Contributor II

Hi Alice_Yang thanks for the replay. I can't delete 0x100, I need multiple filters, that's the point of this post.

I need several (2 in this case) filters.

0 Kudos
Reply

2,140 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Muhlinin,

I have checked your code,  it seems there is no issue.

There is same question about yours, you can have a look:

LPC1549: multiple CAN filters using ccan_rom API 

https://community.nxp.com/thread/461266 

And how about use a logic measure the signal when second CAN (0x200) send data to LPC11c24 ?

0 Kudos
Reply

2,140 Views
ruslan1
Contributor II

Thanks Alice_Yang‌ for the response. Yes, I've already read the topic from the link you've provided. But I have a bit different problem. Our system uses 11 bit CAN ID, the old one. In the provided topic the author tried to set up 29 bit ID. Ok, I've modified the code. ie. instead of 

 

msg_obj.msgobj = 2;
msg_obj.mode_id = 0x200;
msg_obj.mask = 0x7FF;

 

I used:

#define CAN_MSGOBJ_EXT 0x20000000UL

msg_obj.msgobj = 2;
msg_obj.mode_id = CAN_MSGOBJ_EXT | 0x200;
msg_obj.mask = CAN_MSGOBJ_EXT | 0x7FF; 

 

Nothing works. The testing board is connected to external Linux board connected with CAN bus. If I send 0x100 from the Linux box  the CAN_rx callback is called. If I send 0x200 nothing happens.

 

As you can see the testing code is as simple as possible. I use no tricks, workarounds or whatever. So for me it looks like a bug. I still look for a solution. 

0 Kudos
Reply

2,140 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello Muhlinin,

- Sorry I haven't the lpc11c24 board just now, so could you please help me test when config as blow,

whether ID 0x200 can work well : 

msg_obj.msgobj = 1;
msg_obj.mode_id = 0x100;
msg_obj.mask = 0x4FF; //  sorry for my mistake

- And also use a CAN analyzer send data to LPC11c24, whether it can work well?

- Is there signal when use oscilloscope measure ?

Also I will order a board to test it on my side, please give me sometime.

 

0 Kudos
Reply

2,140 Views
ruslan1
Contributor II

Hi Alice_Yang‌, thank you for the collaboration.

msg_obj.msgobj = 1;
msg_obj.mode_id = 0x100;
msg_obj.mask = 0x6FF

works with 0x100 and doesn't work with 0x200, and it seems to me right, according to the can filters logic:

received_can_id & mask == can_id & mask

ie:

(0x100 & 0x6FF) = (0x100 & 0x6FF) - true

(0x100 & 0x6FF) = (0x200 & 0x6FF) - false

Sure, I can remove the filtering or set it to:

msg_obj.msgobj = 1;
msg_obj.mode_id = 0x0;
msg_obj.mask = 0x0

and so I will receive both 0x100 and 0x200 messages. But my target is to set strong filters. I will explain a bit my target taking into account our real system. We have some kind of a tree, where each node hosts lpc11c24 MCU and connected to others through CAN bus. Each node should process ~ 10 messages with different CAN ID. If I will remove filtering so each node will receive every message send to the bus and that will create serious overloading to the system.

The IDs that a node should are not a sequence so I cannot set ranges in filters, only strong 0x7FF mask.

0 Kudos
Reply

2,140 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello,

Sorry for my mistake, I wanted to test

msg_obj.mask = 0x4FF; //  sorry for my mistake

OK, I will test on my side after I get my board, I'm not sure, and I check the previous tickets,

there isn't mentioned this issue.

0 Kudos
Reply

2,140 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello  Muhlinin Ruslan 

 

How about just only set ID:0x200, delete ID:0x100 setting.

If still can't work, could you please share your whole project .


Have a great day,
TIC

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

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos
Reply