Part Number: TMS320F280049
Other Parts Discussed in Thread: C2000WARE
Dear Team:
Version: C2000Ware_1_00_06_00
Function prototype:
extern void
CAN_setBitRate(uint32_t base, uint32_t clock, uint32_t bitRate,
uint16_t bitTime);
A routine of driverlib, path: C2000Ware_1_00_06_00\driverlib\f28004x\examples\can
The method of founction call is as follows, in which DEVICE_SYSCLK_FREQ = 100e6, the desired baud rate is 500 kbps.
CAN_setBitRate(CANA_BASE, DEVICE_SYSCLK_FREQ, 500000, 16);
However, the actual baud rate set in this way is 521 kbps, with an error of more than 4%. It is totally unacceptable and can not communicate with other 500 kbps CAN nodes.
I found that the problem lies in the calculation of BRP in the function. In the example above, the actual value of BRP should be 12.5. However, the shaping calculation will go to the end of 12, that is, BRP = 12, which directly leads to an error of more than 4%.
// Calculate bit timing values
//
brp = (uint16_t)(clock/(bitRate * bitTime));
tPhase = bitTime - (tSync + tProp);
I looked at this question for a day or two and finally found out that it was the driverlib API. Ask staff to confirm, if true, please repair as soon as possible.
Best regards