- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Teams,
I'm looking for help about MCAN iLLD for TC375
I put values to struct of canNodeConfig
IfxCan_Can_BaudRate Can00_baudrate = {
(uint32)500000, (uint16)8750, (uint16)3,
(uint16)10, (uint8)13, (uint8)2
};
g_mcmcan.canNodeConfig.baudRate = Can00_baudrate;
but values in baudRate struct is wrong
g_mcmcan.canNodeConfig.baudRate = { baudrate = 4028628992; samplePoint = 769; syncJumpWidth = 2;
prescaler = 41248; timeSegment1 = 7 ' ...
How can i handle it?
Regards, DJ Lee
Solved! Go to Solution.
- Labels:
-
Aurix
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi DJ Lee,
2. The wrong value of nodeConfig.baudRate seems to be causing the mismatch in the observed baudrate.
After the execution of the line( nodeConfig.baudRate = mcan0_baudrate; ) in the code, Could you verify the value of nodeConfig.baudRate, and if the values are not as expected, could you change them manually in the debugger and ensure that the values are as required and after that check the baudrate in the oscilloscope?
Best Regards,
Nambi.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
something wrong in values.
codes are below.
#include "Ifx_Types.h"
#include "IfxCpu.h"
#include "IfxScuWdt.h"
#include "Blinky_LED.h"
#include "IfxCan.h"
#include "IfxCan_Can.h"
#include "IfxPort.h"
#include "IfxCan_reg.h"
#include "IfxCan_PinMap.h"
#define MODULE_CAN0_RAM 0xF0200000
#define NODE0_RAM_OFFSET 0x0
#define NODE1_RAM_OFFSET 0x1000
IFX_ALIGN(4) IfxCpu_syncEvent g_cpuSyncEvent = 0;
IFX_CONST IfxCan_Can_Pins mcan0_pins = {
&IfxCan_TXD01_P14_0_OUT, IfxPort_OutputMode_pushPull,
&IfxCan_RXD01B_P14_1_IN, IfxPort_InputMode_pullUp,
IfxPort_PadDriver_cmosAutomotiveSpeed1
};
IFX_CONST IfxCan_Can_BaudRate mcan0_baudrate = {
(uint32)500000, (uint16)8750, (uint16)3, (uint16)5, (uint8)6, (uint8)1
};
IfxCan_Can can;
IfxCan_Can_Node canNode[1];
uint32 txData[2];
IFX_CONST IfxCan_Can_BaudRate mcan0_baudrate = {
(uint32)500000, (uint16)8750, (uint16)3, (uint16)5, (uint8)6, (uint8)1
};
void core0_main(void)
{
IfxCpu_enableInterrupts();
/* !!WATCHDOG0 AND SAFETY WATCHDOG ARE DISABLED HERE!!
* Enable the watchdogs and service them periodically if it is required
*/
IfxScuWdt_disableCpuWatchdog(IfxScuWdt_getCpuWatchdogPassword());
IfxScuWdt_disableSafetyWatchdog(IfxScuWdt_getSafetyWatchdogPassword());
/* Wait for CPU sync event */
IfxCpu_emitEvent(&g_cpuSyncEvent);
IfxCpu_waitEvent(&g_cpuSyncEvent, 1);
volatile float mcan_freq = 0.0;
IfxScuCcu_setMcanFrequency(20000000.0);
mcan_freq = IfxScuCcu_getMcanFrequency();
IfxCan_Can_Config canConfig;
IfxCan_Can_initModuleConfig(&canConfig, &MODULE_CAN0);
IfxCan_Can_initModule(&can, &canConfig);
IfxCan_Can_NodeConfig nodeConfig;
IfxCan_Can_initNodeConfig(&nodeConfig, &can);
nodeConfig.nodeId = IfxCan_NodeId_1;
nodeConfig.clockSource = IfxCan_ClockSource_both;
nodeConfig.frame.type = IfxCan_FrameType_transmit;
nodeConfig.baudRate = mcan0_baudrate;
nodeConfig.pins = &mcan0_pins;
nodeConfig.txConfig.dedicatedTxBuffersNumber = 2;
nodeConfig.messageRAM.txBuffersStartAddress = 0x400;
nodeConfig.messageRAM.baseAddress = MODULE_CAN0_RAM + NODE1_RAM_OFFSET;
IfxCan_Can_initNode(&canNode[0], &nodeConfig);
while (IfxCan_Can_isNodeSynchronized(&canNode[0]) != TRUE);
txData[0] = 0xC0CAC01A;
txData[1] = 0xBA5EBA11;
IfxCan_Message txMsg;
IfxCan_Can_initMessage(&txMsg);
txMsg.bufferNumber = 0;
txMsg.messageId = 0x777;
initLED(); /* Initialize the LED port pin */
while(1)
{
blinkLED(); /* Make the LED blink */
IfxCan_Can_sendMessage(&canNode[0], &txMsg, txData);
}
}
baudrates are too fast
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
1. Based on your second response, mcan0_baudrate is defined twice. Could you check that?
2. It is not very clear from the screenshot on what the issue is. The expanded variable baudrate indicates that the values of the individual structure elements are as expected. Could you share the expanded screenshot of both the structures mcan0_baudrate and nodeConfig.baudRate? Could you explain more about what the issue is?
Best Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Nambi,
thanks for your help
1. I modified the statement by declaring it once
2. In the case of the mcan0_baudrate structure, the member variables were normally inserted into the structure, but in the case of the nodeConfig.baudRate structure, the member variables entered values wrong. I've attached a photo.
[mcan0_baudrate]
[nodeConfig.baudRate]
Additionally, it is the current CAN waveform.
I set the baud rate to 500kbps, but I am getting the wrong baudrate, and it seems that the speed is too fast.
Regards, DJ Lee
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
And Here is my pin mapping
I use Can0 Node1 (p14.0, p14.1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi DJ Lee,
2. The wrong value of nodeConfig.baudRate seems to be causing the mismatch in the observed baudrate.
After the execution of the line( nodeConfig.baudRate = mcan0_baudrate; ) in the code, Could you verify the value of nodeConfig.baudRate, and if the values are not as expected, could you change them manually in the debugger and ensure that the values are as required and after that check the baudrate in the oscilloscope?
Best Regards,
Nambi.