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

cross mob
User8620
Level 2
Level 2
Hello,

I am trying to configure the CAN Nodes of an xmc4500 with the Dave App.
The Microcontroller is connected to a PCAN Device, so that I can monitor the messages on my computer.

The PCAN has the following timing configuration:
Bitrate: 500kbit/s
Sample point: 87.5%
Synchronization jump width: 1

So here is the first problem. In the GUI of the CAN App I can not set the sample point to 87.5%, only to even values (87 or 88).
To fix that I went into the generated con_node_conf.c and set the sample_point in XMC_CAN_NODE_NOMINAL_BIT_TIME_CONFIG_t to 8750.
The baudrate is set to 500 in the GUI and the jump width to 1.
So the config looks like this:
/* CAN_NODE Bit Time Configuration */
XMC_CAN_NODE_NOMINAL_BIT_TIME_CONFIG_t CAN_NODE_VEH_BitTimeConfig = {
.can_frequency = (uint32_t)1.2E8,
.baudrate = (uint32_t)(500 * 1000),
.sample_point = (uint16_t)(8750),
.sjw = (uint16_t)1
};


I tested the configuration for two nodes with loobpack mode enabled.
This works fine.

But now I want to send messages to my PCAN. I only get BUSHEAVY or BUSLIGHT Error messages in the PCAN Explorer.
So I guess something in the bit timing is not correct?

I looked into the XMC_CAN_NODE_NominalBitTimeConfigure method and saw that the timing register is set there.
So I went to http://www.can-wiki.info/bittiming/tq.html#Infineon and looked up the recommended values for the given timing.
It says:
Prescaler: 15
Seg1: 13
Seg2: 2
Sample Point at 87.5%
Div8: 0

I tried to hardcode these values in the method ,but it still doesnt work.
What else could be the problem? And how does the calculation in the method works? By debugging I could find that the calculated values are different.

I know that the wiring is correct, because I have an old software, where the CAN works. (But I still need to redo it)

Dave App Version is 4.1.10
0 Likes
3 Replies
User10215
Level 4
Level 4
First like received
Hi oliver,

is it really crucial that you have a sample point of 87.5% and not 87 or 88%? I think that wether to have this additional 0.5% or not doesn't make a big difference.
What I would suggest is that you, as a first step, leave the generated Dave code untouched and try if it works with an untouched configuration (since I have projects working with that Dave-code I'm assuming that your modifications might ruin something).
You say your hardware worked with old software? So you mean with old software running on the same XMC4500? What did you use to write the old software? An older version of the APP?
Maybe also check again if the terminating resistors are connected properly.

Regards,
Niclas
0 Likes
User8620
Level 2
Level 2
I didnt write the old software myself. But i suppose they used an older version of the CAN App.
I also tested the untouched generated version, but it didnt work.
But I looked through the source code and could find out that they use only 40Mhz as the CAN frequency. So I changed the CAN frequency to 40mhz in the newer version, but that still does not work.
0 Likes
User10215
Level 4
Level 4
First like received
Hm, ok. Point is, the App works for me. How about starting a fresh project? This shouldn't take more than 5 minutes. Just create a new DAVE CE Project and only add the Can-App. Default configuration is a baudrate of 500kHz, an ok sample point and one Tx-Message-Object. Leave it like that (Identifier and data bytes of the message object can be modified)
Don't forget to set the correct pins for the Can-App! Then add this code in the main.c


#include //Declarations from DAVE Code Generation (includes SFR declaration)

uint32_t MilliSecCounter = 0;
uint32_t MillisecTimestamp = 0;
/**

* @brief main() - Application entry point
*
* Details of function

* This routine is the application entry point. It is invoked by the device startup code. It is responsible for
* invoking the APP initialization dispatcher routine - DAVE_Init() and hosting the place-holder for user application
* code.
*/

int main(void)
{
DAVE_STATUS_t status;

status = DAVE_Init(); /* Initialization of DAVE APPs */

if(status == DAVE_STATUS_FAILURE)
{
/* Placeholder for error handler code. The while loop below can be replaced with an user error handler. */
XMC_DEBUG("DAVE APPs initialization failed\n");

while(1U)
{

}
}

SysTick_Config(SystemCoreClock/1000);
MillisecTimestamp = MilliSecCounter;

/* Placeholder for user application code. The while loop below can be replaced with user application code. */
while(1U)
{
/* Send Data frame */
CAN_NODE_MO_Transmit(&CAN_NODE_0_LMO_01_Config);

/* wait a second */
while((MilliSecCounter-MillisecTimestamp) < 1000);
MillisecTimestamp = MilliSecCounter;
}
}

void SysTick_Handler(void)
{
MilliSecCounter++;
}



This will transmit a can frame with the identifier and data configured in the message object (default: Identifier 2047 and all data bytes = 0x00) every second.
If this works then there's only the possibility that there is some configuration in your other project that breaks things.
If this doesn't work and you again only see can-errors on the bus then there is something wrong with your hardware.

Regards,
Niclas
0 Likes