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.
Solved! Go to Solution.
Hi Yuzuru Mizuno ,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
How do you implement the data transmission?Can you teach me?
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!
-----------------------------------------------------------------------------------------------------------------------
How to test the data sent?
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!
-----------------------------------------------------------------------------------------------------------------------
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);
}
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!
-----------------------------------------------------------------------------------------------------------------------
EXT_VIN need externally provided 5V ?
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!
-----------------------------------------------------------------------------------------------------------------------
Hi Yuzuru Mizuno ,
TIC
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
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