cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Contributor
Contributor
694 Views
Registered: ‎05-18-2018

Xilinx CAN bitrate calculation

I am using Picozed 7030 SoM and have enabled the CAN0 via MIO pins. Also on the carrier board there is CAN translator and then I have connected it to PEAK PCAN-USB pro. How to configure the can bitrate in SDK? As per the CAN's PG, it shows BRPR & bit timing calculation but what how to calculate the bitrate? What should be the CAN CLK selected in Zynq PS settings.

I tried setting BRPR =6, TS1 = 12, TS2 = 1, SJW = 0 (1 less for TS1, TS2, SJW as per product guide) for 250Kbps speed at 24MHz and have selected in PCAN view also the same settings (24MHz & 250Kbps). Are these values correct? How to calculate bitrate depending on clock, prescalar and time segment values.

Regards,

Bhavin

0 Kudos
Reply
1 Reply
Observer
Observer
622 Views
Registered: ‎04-25-2017

Here is what worked for setting 1 Mbps:

.......

/* The Baud Rate Prescaler Register (BRPR) and Bit Timing Register (BTR) required
 * to be set for the desired baud rate.
 * For more information see the CAN 2.0A, CAN 2.0B, ISO 11898-1 specifications.
 * The CAN clock is 24MHz.
 */
#define TEST_BTR_SYNCJUMPWIDTH        3   // 100, 250 -> 3
#define TEST_BTR_SECOND_TIMESEGMENT    2   // 100, 250 -> 5 500 -> 2
#define TEST_BTR_FIRST_TIMESEGMENT    3   // 100, 250 -> 8 500 -> 3
#define TEST_BRPR_BAUD_PRESCALAR    2   // 100->14  250,500->5 750->3, 1000->2

.....

    XCanPs_SetBaudRatePrescaler(CanInstPtr, TEST_BRPR_BAUD_PRESCALAR);
    XCanPs_SetBitTiming(CanInstPtr, TEST_BTR_SYNCJUMPWIDTH,

......

Everything is explained in the \data\embeddedsw\XilinxProcessorIPLib\drivers\canps_

Hope it is what you are looking for.

0 Kudos
Reply