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