This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software:
I am trying to operate the MCAN module on an F280039C MCU at 1 Mbps nominal and 5 Mbps data bit rates. I am having trouble spotting the correct settings to do so.
The MCAN module clock prescaler is set to 3.
I am able to get a nominal baud rate of 1 Mbps using the following settings
I am able to operate correctly at 2.5 Mbps using the setting below.
I am trying to get a data baud rate of 5 Mbps by setting the data rate prescaler to 0 above. However, I do not see any message transmission attempts on the bus (using a scope to watch the CANH/CANL pins) if I make that change. I also tried changing the MCAN clock prescalar to do so but to no avail.
Can somebody please verify if I am using valid settings ?
several comments for choosing TSeg1 and TSeg2:
1. The bit time segments (TSeg1, TSeg2) should be configured so that the sample point is as late as possible in the bit. The sample point = (1 + TSeg1)/(1 + TSeg1 + TSeg2)
2. The TSeg2 may not be shorter than any CAN controller’s Information Processing Time, which is device dependent and can be in the range of [0 … 2] tq
3. SJW defines how far the resynchronizing mechanism may move the sample point inside the limits. It should not be 0
Can you try those settings:
MCAN module clock prescaler: /2
Nominal:
prescaler: 2
TSEG1: 14
TSEG2: 3
SJW: 3
Data:
prescaler: 0
TSEG1: 7
TSEG2: 2
SJW: 2
Thanks for pointing out the issue with SJW. I tried using the recommended settings but I still see the same issue - no CAN transmit attempts.
Hi Rishab,
Have you enabled the TDC (transmission delay compensation)? TDC is disabled by default. After it is enabled, please program TDCO and TDCF.
I recommend TDCO=TDCF=data TSEG1
Hi Rishab,
I tested 5Mbps data baudrate on a F28x device, it works as expected.
My config is listed in below for CPU speed = 150MHz (For F280039, the CPU speed is 120MHz):
/**********************************************/
SysCtl_setMCANClk(SYSCTL_MCANA, SYSCTL_MCANCLK_DIV_3); //MCAN_CLK=50MHz
/* baudrate = 50MHz/(0x4+0xe+3)(0x4+1)= 500kbps*/
bitTimes.nomRatePrescalar = 0x4U; // Nominal Baud Rate Pre-scaler
bitTimes.nomTimeSeg1 = 0x0EU; // Nominal Time segment before SP
bitTimes.nomTimeSeg2 = 0x3U; // Nominal Time segment after SP
bitTimes.nomSynchJumpWidth = 0x3U; // Nominal SJW
/* baudrate = 50MHz/(0x6+1+3)(0x0+1)= 5000kbps*/
bitTimes.dataRatePrescalar = 0x0U; // Data Baud Rate Pre-scaler
bitTimes.dataTimeSeg1 = 0x6U; // Data Time segment before SP
bitTimes.dataTimeSeg2 = 0x1U; // Data Time segment after SP
bitTimes.dataSynchJumpWidth = 0x1U; // Data SJW
initParams.emulationEnable = 0x1; //Added by QJ
initParams.tdcEnable = 0x1U; //Transmitter Delay Compensation enabled
The PCAN receives all the messages transmitted by F28x MCAN node:
The PCAN CAN-FD settings:
You can not get 2.5Mbps baudrate using the parameters in your 1st message. The actualk baudrate is: 40MHz/3/(3+1+3)= 40/21 mbps
Please use the timing parameters below for test.
SysCtl_setMCANClk(SYSCTL_MCANCLK_DIV_2); //MCAN clock = 60MHz
bitTimes.nomRatePrescalar = 0x5U; // Nominal Baud Rate Pre-scaler
bitTimes.nomTimeSeg1 = 14U; // Nominal Time segment before SP
bitTimes.nomTimeSeg2 = 3U; // Nominal Time segment after SP
bitTimes.nomSynchJumpWidth = 0x3U; // Nominal SJW
/* baudrate = 60/1/(8+1+3) = 5mbps*/
bitTimes.dataRatePrescalar = 0x0U; // Data Baud Rate Pre-scaler
bitTimes.dataTimeSeg1 = 0x8U; // Data Time segment before SP
bitTimes.dataTimeSeg2 = 0x1U; // Data Time segment after SP
bitTimes.dataSynchJumpWidth = 0x1U; // Data SJW
and
initParams.emulationEnable = 0x1;
initParams.tdcEnable = 0x1U; //Transmitter Delay Compensation enabled
//
// Transmitter Delay Compensation parameters.
//
initParams.tdcConfig.tdcf = 0xAU;
initParams.tdcConfig.tdco = 0x9U;
I am sorry the parameters I gave you is for different CPU clock.
Hi QJ,
I was able to resolve this with your parameter set. I believe the issue was most likely due to transmission delay compensation not being enabled. MCAN example 13 on C2000ware 5.02 (mcan_ex13_transmit_TxEventFIFO) sets the compensation parameters without actually ever enabling the delay compensation itself.
I copied over the same example and was under the impression that the compensation is enabled.
Thanks a lot once again for all these inputs. A small addition - the parameter set above gets the MCAN to work at 500 kbps nominal and 5 Mbps data rates. I changed the nominal baud rate prescalar to 2 from the 5 recommended above to get the MCAN to work at 1 Mbps nominal and 5 Mbps data rates.