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.

TMS320F28379D: TMS28379D Can bit Timing

Part Number: TMS320F28379D

Hi,

I want to use the CAN module with a bit rate = 125kbit/s ; if I use the following function, it works :

CANBitRateSet(CANB_BASE, 200000000, 125000);

But I don't like to use function, I prefer programming directly registers, it's more flexible I think.
This is the configuration :

EALLOW;
// Configure the eCAN timing
// CANB Bit-Clock Source Select Bit:
ClkCfgRegs.CLKSRCCTL2.bit.CANBBCLKSEL = 0;      // 00 = PERx.SYSCLK (default on reset)
EDIS;

CanbRegs.CAN_BTR.bit.BRPE = 4; // Baud Rate Prescaler Extension - Valid programmed values are 0 to 15.
CanbRegs.CAN_BTR.bit.BRP = 19; // Baud Rate Prescaler - Value by which the CAN_CLK frequency is divided for generating the bit time quanta. The bit time is built up from a multiple of this quanta.

CanbRegs.CAN_BTR.bit.TSEG1 = 12; // Or 11 because The actual TSeg1 value interpreted for the Bit Timing will be the programmed TSeg1 value + 1.
CanbRegs.CAN_BTR.bit.TSEG2 = 1;   // Or 0 because The actual TSeg2 value interpreted for the Bit Timing will be the programmed TSeg2 value + 1.

With this settings, I have a bit time (on the oscilloscope) of about 23µs (about 45kHz) instead of bit time of 8µs (125kHz).

Can you explain where am I wrong?

time quantum = SYSCLK / ((BRP + 1)*(BRPE + 1)) = 200MHz / (20 * 5) = 2MHz = 0,5µs

bit time = [TSEG1 + TSEG2 + 3] * tq  = 16 * tq = 8µs ?!?

Thanks for your help

Regards

  • Hello,

    Thanks for your question! You are correct in how this is meant to be viewed (that the time quanta per bit is different than the bit timing itself). I definitely understand the desire to use the registers directly to modify these values for better flexibility. Because of this, rather than using just the registers from the code snippet above, I would suggest using the following resource to dig into the timing control of the device:

    "Calculator for CAN Bit Timing Parameters": http://www.ti.com/lit/an/sprac35/sprac35.pdf

    Direct link to the calculator (also linked in the document): http://www.ti.com/lit/zip/sprac35

    This calculator shows the suggested parameters based on a given bit rate/time quanta/etc, with many details on what to set in the device based on that.

    Let me know if this helps with your development process!


    Regards,

    Vince

  • Hi,

    Thanks for this very helpful document. Now I have the good period on the oscilloscope.

    But I just don't understand how I can find the good result with calculations..

    Regards