CAN Bus communication on an XMC 4500

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

cross mob
Not applicable
Dear Ladies and Gentlemen,

Preface: we are currently developing a CAN Bus system for a Formula Student Electric Team. We would like to port our current analog wire harness to a CAN bus system to reduce wiring complexity as well as weight.

Question: We are using DAVE3 for software development and have the problem that the XMC 4500 Relax Lite Board is not outputing the CAN bus signals to the CAN transceiver. We suspect it is due to an app setting / interupt problem since the hardware was tested with other CAN capable devices and has shown to have worked. As a template we used the CAN examples provided.

What are possible causes of this problem?

Kind Regards,
Moritz Ulmer
0 Likes
4 Replies
Not applicable
Do you measure directly at the pins? If the software is known to work, there are still many reasons why it can fail.
I would check the pin assignment first. And if you do not connect the transceiver correctly, it also is difficult to measure a CAN signal at TX.
0 Likes
Not applicable
Hi Moritz,

From your description, I understand that you already communicated using the Relax Kit to other devices, correct?

So if the only change is the source code on the RelaxKit, then I would sugest checking for pins assignment, also if you are using the correct MSGObj in the can function when sending data.

If you need any more help maybe you could give more information regarding Message Objects used and if they are configured as transmit or receive, if interrupts are enabled, etc.

Best regards,
Filipe Teixeira
www.about.me/teixeirafms
0 Likes
Not applicable
Hi,


I am facing a problem with CAN interface with XMC4500. I am using CAN app in DAVE. I am receiving the packet but want to access the data bytes received. Couldn't find the right parameter in the message object structure to do it. I want to copy the received bytes in unit8_t array for further processing.

Kindly suggest.
0 Likes
Not applicable
Hi folks,

Below are some code fragments from our project, showing extraction of 16-bit integer values, from the 8 received bytes. It allow extraction of value 0, 1, 2 or 3. You can adapt to extract byte values instead, by accessing instead the CAN_NODE_1_LMO_01_Config.mo_ptr->can_data_byte[8] array. Or just use that array as-is. Hope helps ! Oh and I'm afraid the forum system has un-indented the code.

Best regards,

David King




#define BYTE_SWAP( Value ) __builtin_bswap16( Value )
// Swap 16-bit integer byte order, uses rev16 instruction

int16_t CANValue( uint8_t Index )
{
int16_t Word = CAN_NODE_1_LMO_01_Config.mo_ptr->can_data_word[ Index ];
// Obtain word

return BYTE_SWAP( Word ); // Return byte-swapped
}

// Below, CAN_NODE_1 is the configured APP
// ID1/2 are constants for the CAN message IDs in which you are interested
// TYPE_UNUSED, TYPE1 and TYPE2 are constants, values 0, 1, 2
// Within the 8-byte CAN data, for type 1, the code is interested in the
// first 16-bit integer. And for type 2, in the second 16-bit integer.

void CANNodeInterrupt( void )
{
uint32_t Id; // CAN identifier
uint8_t Type; // Value type
int16_t Value; // Value
:

if ( CAN_NODE_GetStatus(&CAN_NODE_1) &
XMC_CAN_NODE_STATUS_LAST_ERROR_CODE ) // Node error
{
// No action as yet
}

else // No Node error
{
if ( CAN_NODE_MO_GetStatus(&CAN_NODE_1_LMO_01_Config) &
XMC_CAN_MO_STATUS_RX_PENDING ) // Received message object
{
CAN_NODE_MO_Receive ( &CAN_NODE_1_LMO_01_Config ); // Read object

Id = CAN_NODE_1_LMO_01_Config.mo_ptr -> can_identifier;
// CAN identifier

Type = TYPE_UNUSED; // Default

// Map CAN identifier to value type
if ( Id == ID1 ) Type = TYPE1;
if ( Id == ID2 ) Type = TYPE2;
:

if ( Type != TYPE_UNUSED ) // Used value
{
if ( Type == TYPE1 ) Value = CANValue(0);
else Value = CANValue(1);
// CAN data word 0 or 1, byte-swapped
:

0 Likes