How to use can_receive on LPC11C24?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How to use can_receive on LPC11C24?

跳至解决方案
1,993 次查看
yuzurumizuno
Contributor I

Hi there,

I'm new to CAN and NXP uC.

I'm now trying to use CAN on LPC11C24.

So far sending data from LPC11C24 successfully worked very easily. 

What I would like to know is how to handle and see the content of message which LPC11C24 received.

Let's say the other side node sends two bytes data and LPC11C24 receives it.

I would like to process the 2 bytes data in my codes.

I just added below codes to the example one but it does not work.

//variable declaration

uint8_t received_message=0;

/* Configure message object 1 to receive all 11-bit messages 0x400-0x4FF */
msg_obj.msgobj = 1;
msg_obj.mode_id = 0x400;
msg_obj.mask = 0x0;
LPC_CCAN_API->config_rxmsgobj(&msg_obj);

//receive message
LPC_CCAN_API->can_receive(&msg_obj);
received_message = msg_obj.data[0];
}

Could somebody kindly advice me how to use can_receive or give some example?

Thank you very much.

标签 (1)
标记 (1)
0 项奖励
1 解答
1,484 次查看
jeremyzhou
NXP Employee
NXP Employee

Hi Yuzuru Mizuno ,

Thank you for your interest in NXP Semiconductor products and 
the opportunity to serve you.
To provide the fastest possible support, I'd highly recommend you to refer to the periph_ccan_rom demo in the LPCOpen library whose link is below.
2018-01-11_14-19-25.jpg

TIC

 

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

在原帖中查看解决方案

10 回复数
1,484 次查看
funa
Contributor I

How do you implement the data transmission?Can you teach me?

0 项奖励
1,484 次查看
jeremyzhou
NXP Employee
NXP Employee

Hi ,
Whether you can clarify your issue in detail.
In the periph_ccan_rom demo, it demonstrates the transmit and receive function via the CAN ROM driver, you can refer to it.
Have a great day,
TIC

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

0 项奖励
1,484 次查看
funa
Contributor I

How to test the data sent?

0 项奖励
1,484 次查看
jeremyzhou
NXP Employee
NXP Employee

Thanks for your reply.
For testing, you need a CAN protocol analyzer, for instance, PCAN-USB, you can send a CAN frame to the MCU, after receiving, it will echo a CAN frame with ID +0x100.
Please give a try.
Have a great day,
TIC

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

0 项奖励
1,484 次查看
funa
Contributor I

Thanks for your answer.

I took two wires in TXD and RXD, measured with an oscilloscope, and then run the following program. Found no signal. It was found that VCC is always 0. Does VCC require external power supply?

/////////////////////////////////////////////////////

while(1) {
        msg_obj.msgobj  = 0;
        msg_obj.mode_id = 0x345;
        msg_obj.mask    = 0x0;
        msg_obj.dlc     = 4;
        msg_obj.data[0] = 'T';    // 0x54
        msg_obj.data[1] = 'E';    // 0x45
        msg_obj.data[2] = 'S';    // 0x53
        msg_obj.data[3] = 'T';    // 0x54
        LPC_CCAN_API->can_transmit(&msg_obj);
        for(j=0;j<1000000;j++) {
            ;
        }
        Board_LED_Toggle(0);
    }

0 项奖励
1,484 次查看
jeremyzhou
NXP Employee
NXP Employee

Hi na fu,

Thanks for your reply.
Yes, the Vcc and VDD_CAN pins both should be connected to the power, please refer to the schematic of LPCXpresso LPC11C24 board.

Have a great day,
TIC

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

0 项奖励
1,483 次查看
funa
Contributor I

EXT_VIN need externally provided 5V ?

0 项奖励
1,483 次查看
jeremyzhou
NXP Employee
NXP Employee

Hi,

No, it doesn't need it.
Have a great day,
TIC

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

0 项奖励
1,485 次查看
jeremyzhou
NXP Employee
NXP Employee

Hi Yuzuru Mizuno ,

Thank you for your interest in NXP Semiconductor products and 
the opportunity to serve you.
To provide the fastest possible support, I'd highly recommend you to refer to the periph_ccan_rom demo in the LPCOpen library whose link is below.
2018-01-11_14-19-25.jpg

TIC

 

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

1,483 次查看
yuzurumizuno
Contributor I

Dear Jeremy,

Thank you very much for the response.

I carefully read the sample program and tried it. Then I successfully confirmed that the board is receiving the data.

It works.

Best regards,

Yuzuru

0 项奖励