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.
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
the same with the code in "CAN_rx()"
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.
-------------------------------------------------------------------------------
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.
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.
-------------------------------------------------------------------------------
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.
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 ?
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.
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.
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.
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.
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.
-------------------------------------------------------------------------------