LPC1549: multiple CAN filters using ccan_rom API

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

LPC1549: multiple CAN filters using ccan_rom API

1,251件の閲覧回数
jkingeet
Contributor I

I'm utilizing the LPCOpen libraries called "ccan_rom.c," "rom_can_15xx.h," and "romapi_15xx.h" to set up a basic CAN interface for the LPC1549.

In the example code, there is this excerpt:

/* Configure message object 1 to receive all 11-bit messages 0x400-0x4FF */
msg_obj.msgobj = 1;
msg_obj.mode_id = 0x400;
msg_obj.mask = 0x700;

LPC_CAND_API->hwCAN_ConfigRxmsgobj(pCanHandle, &msg_obj);

Which is used to configure a receive object filter.

This sets up one filter, essentially.

I tried to modify this code to the following:

msg_obj.msgobj = 1;
msg_obj.mode_id = 0x400;
msg_obj.mask = 0x700;

LPC_CAND_API->hwCAN_ConfigRxmsgobj(pCanHandle, &msg_obj);

msg2_obj.msgobj = 2;
msg2_obj.mode_id = 0x10000320;
msg2_obj.mask = 0x10000400;
LPC_CAND_API->hwCAN_ConfigRxmsgobj(pCanHandle, &msg2_obj);

In an attempt to add multiple filters.
I thought this would create two receive message objects with different filters, but it does not seem to.
No matter what I do, the ISR is only thrown for the first entry. If I comment out the msg_obj code portion, then the 0x10000320 filter is applied. If I leave the msg_obj code portion uncommented, then the 0x400 filter is applied, and the 0x10000320 filter is not.

What is the right way to add multiple filters, or multiple receive message objects using the ccan_rom API?

0 件の賞賛
返信
3 返答(返信)

954件の閲覧回数
jkingeet
Contributor I

After further research, I have found the solution to this.

I found a post here:

Introduction to CAN 

That contains this line:

msg_obj.mode_id = CAN_MSGOBJ_EXT | 0x0;

I modified my existing code to the following:

#define CAN_MSGOBJ_EXT 0x20000000UL // CAN 2.0b 29-bit ID

// Message object #1
msg_obj.msgobj = 1;
msg_obj.mode_id = 0x400;
msg_obj.mask = 0x700;
LPC_CAND_API->hwCAN_ConfigRxmsgobj(pCanHandle, &msg_obj);

// Message object #2
msg_obj.msgobj = 2;
msg_obj.mode_id = CAN_MSGOBJ_EXT | 0x10000320;
msg_obj.mask = CAN_MSGOBJ_EXT | 0x10000400;
LPC_CAND_API->hwCAN_ConfigRxmsgobj(pCanHandle, &msg_obj);‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

And that works. The interrupt triggers on both, and I can check which message object called the interrupt as per the example code:

static void CAN_rx(uint8_t msgNumber)
{
     /* Determine which CAN message has been received */
     msg_obj.msgobj = msgNumber;

     /* Now load up the msg_obj structure with the CAN message */
     LPC_CAND_API->hwCAN_MsgReceive(pCanHandle, &msg_obj);
     
     // Message object #1
     if (msgNumber == 1) {
          Board_LED_Toggle(0);
     }
     
     // Message object #2
     else if (msgNumber == 2){
          Board_LED_Toggle(1);
     }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 件の賞賛
返信

954件の閲覧回数
jeremyzhou
NXP Employee
NXP Employee

Hi Justin King

I'm glad to hear that
If you have any further questions about it, please feel free to contact me.
Have a great day,
TIC

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

0 件の賞賛
返信

954件の閲覧回数
chensiyan618
Contributor I

Excuse me, jeremyzhou

Would you like to do me a favor ? There is a question about the FIFO of CAN.

I'm utilizing the LPCOpen libraries called "ccan_rom.c," "rom_can_15xx.h," and "romapi_15xx.h" to set up a basic CAN interface for the LPC1549.

Firstly,when I initialize the FIFO of CAN, I have finished the configuration the filter. Secondly, I made it work normally. However, good times don't last long, a question happened that when the frames of CAN reached 500,000 , the FIFO of CAN can not receive it and more. Then I attempt to reconfigure the filter, the FIFO continue to receiving the frame of CAN again. 

So, which measure can prevent this phenomenon from coming into being ? Can you help me to solve this problem ?

0 件の賞賛
返信