Automotive CAN bus interface using an XMC4500 - Getting started

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
User13960
Level 3
Level 3
First like received
Hi all,

I am developing an electronic module incorporating an XMC4500 which needs to communicate five values onto the CAN bus of an automobile. From a firmware viewpoint I have zero experience in this field and I would really appreciate any help on how to go about this.

Thank you very much

PHAB
0 Likes
5 Replies
jferreira
Employee
Employee
10 sign-ins 5 sign-ins First like received
Hi,

You can start looking to the CAN_NODE APP and examples
3540.attach

Regards,
Jesus
0 Likes
User13960
Level 3
Level 3
First like received
Thanks Jesus (sorry for the delay in replying, didn't get a notification for some reason).

Would you be able to confirm if the following are possible with the XMC4500 please...

1) 2 x physical CAN buses operating simultaneously.
2) Different baud rates on each CAN bus
3) Pass received data from CAN 1 to CAN 2 via the gateway (with different baud rates) but also receive the data from CAN 1 (either directly from CAN 1 or indirectly from CAN 2)


Thank you very much

Aaron
0 Likes
SunYajun
Employee
Employee
10 replies posted 5 replies posted Welcome!
yes, you can use Gateway feature to forward frame without any modification or CPU load or controlled per SW, e.g. add instruction code for transmit trigger, etc. detailed info see please an appnote
https://www.infineon.com/dgdl/Infineon-MultiCAN-XMC4000-AP32300-AN-v01_00-EN.pdf?fileId=5546d4624e76...
https://www.infineon.com/dgdl/Infineon-MultiCAN-XMC4000-AP32300_Example_Code-AN-v01_00-EN.exe?fileId...
0 Likes
User13960
Level 3
Level 3
First like received
Thank you very much.
0 Likes
User13960
Level 3
Level 3
First like received
For anyone looking to implement basic CAN, here are the steps for building and transmitting two CAN messages each containing 8 bytes of data (without error handling)…


1) ADD the 'CAN_NODE' App to your project using DAVE's 'Add New APP' feature


2) Configure the APP. In this example I have specified 2 message objects with a transmission rate of 500kbps. The messages have CAN ID's of 0x130 and 0x131. Each message object (MO) contains 8 data bytes to be transmitted (64 bits of data).

3617.attach

3618.attach


3) To transmit a message object containing your data, you need to write your 64 bits of data into the two 32 bit registers (Data_H and Data_L) of a message object before initiating a CAN message transmission.
It is entirely up to you and the receiver what you put in the 8 bytes. For example two of the bytes might contain 16 independent flags, a 32 bit value spread over 4 consecutive bytes and two 8 bit values in two independent bytes.
The data format is normally specified in a '.dbc' data base file. There are many free viewers for such files enabling you to agree the format with the receiver.



CAN_NODE_STATUS_t mo_tranmit_status;

uint8_t CAN_Data[9];

// Fill the 'CAN_Data' array with 8 bytes of your data (for message 1)
// Your own code here

// Load the 'CAN_Data' array into message object 1 (Data_H and Data_L)
CAN_NODE_MO_UpdateData(CAN_NODE_0.lmobj_ptr[0],CAN_Data);


// Fill the 'CAN_Data' array with 8 bytes of your data (for message 2)
// Your own code here

// Load the 'CAN_Data' array into message object 2 (Data_H and Data_L)
CAN_NODE_MO_UpdateData(CAN_NODE_0.lmobj_ptr[1],CAN_Data);


//Transmit message object 1
mo_tranmit_status = CAN_NODE_MO_Transmit(CAN_NODE_0.lmobj_ptr[0]);

//Transmit message object 2
mo_tranmit_status = CAN_NODE_MO_Transmit(CAN_NODE_0.lmobj_ptr[1]);





4) The Data_H and Data_L contents can be viewed within the DAVE Debug perspective. Useful for ensuring you have loaded them correctly.

5) There are very low cost CAN analyser modules which will enable you to view the actual CAN message contents the receiver will see. Useful for ensuring you are sending the bytes in the correct order and multi-byte values are sent in the correct order. e.g. Little endian (Intel format) or big endian(Motorola format).

I hope this helps

PHAB
0 Likes