element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Avnet Boards Forums
  • Products
  • Dev Tools
  • Avnet & Tria Boards Community
  • Avnet Boards Forums
  • More
  • Cancel
Avnet Boards Forums
Avnet Boards General CAN Bus Baud Rate
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Avnet Boards Forums to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 1 reply
  • Subscribers 346 subscribers
  • Views 699 views
  • Users 0 members are here
  • zynq 7000 can bus
Related

CAN Bus Baud Rate

iaguilar
iaguilar over 6 years ago

I am going through UG585 document and trying to understand the formulas for the can bus baud rate.  I am using the example from SDK (xcanps_intr_example).  I am trying to understand how they are arriving at those numbers.  Ultimately I would like to set up the baud rate at 1 megabit per second.

/*

* The Baud Rate Prescaler Register (BRPR) and Bit Timing Register (BTR)

* are setup such that CAN baud rate equals 40Kbps, assuming that the

* the CAN clock is 24MHz. The user needs to modify these values based on

* the desired baud rate and the CAN clock frequency. For more information

* see the CAN 2.0A, CAN 2.0B, ISO 11898-1 specifications.

*/

 

/*

* Timing parameters to be set in the Bit Timing Register (BTR).

* These values are for a 40 Kbps baudrate assuming the CAN input clock

* frequency is 24 MHz.

*/

#define TEST_BTR_SYNCJUMPWIDTH          3

#define TEST_BTR_SECOND_TIMESEGMENT    2

#define TEST_BTR_FIRST_TIMESEGMENT      15

 

/*

* The Baud rate Prescalar value in the Baud Rate Prescaler Register

* needs to be set based on the input clock  frequency to the CAN core and

* the desired CAN baud rate.

* This value is for a 40 Kbps baudrate assuming the CAN input clock frequency

* is 24 MHz.

*/

#define TEST_BRPR_BAUD_PRESCALAR 29

 

Formulas from the UG585:

tTQ_CLK = tCAN_REF_CLK * (can.BRPR[BRP] + 1)

freqTQ_CLK = freqCAN_REF_CLK / (can.BRPR[BRP] + 1)

tSYNC_SEGMENT = 1 * tTQ_CLK

tTIME_SEGMENT1 = tTQ_CLK * (can.BTR[TS1] + 1)

tTIME_SEGMENT2 = tTQ_CLK * (can.BTR[TS2] + 1)

tBIT_RATE = tSYNC_SEGMENT + tTIME_SEGMENT1 + tTIME_SEGMENT2

freqBIT_RATE = freqCAN_REF_CLK / ((can.BRPR[BRP] + 1) * (3 + can.BTR[TS1] + can.BTR[TS2]))

 

How are they deriving those numbers?  How do I choose BRP?  How are they getting  TEST_BTR_SYNCJUMPWIDTH, TEST_BTR_SECOND_TIMESEGMENT and TEST_BTR_FIRST_TIMESEGMENT. Again I am trying to understand configure the baud rate for 1 megabit per second. 

  • Sign in to reply
  • Cancel
  • michaelkellett
    0 michaelkellett over 6 years ago

    To use CAN effectively you need to understand a bit more about how it works.

    I've always found it hard to Google for CAN info because can is such a common word.

    You will find a decent description of some of this stuff in various CAN equipped micro controller data sheets.

     

    The essence of it is that the CAN bit time is considered to be made up from several pieces (each tQ long) and you can set the size of them. tQ is set by the basic clock rate of 24MHz divided by the pre-scaler.

    Depending on the hardware there division may be by BRP or BRP + 1,

    in the example 24MHz is divided by 30 = 800000

    so (3 + can.BTR[TS1] + can.BTR[TS2]) needs to be 20 to meet the 40kHz requirement

    In your case try BRP = 0 and then (3 + can.BTR[TS1] + can.BTR[TS2]) = 24

    there will be maximum allowed values for TS1 and TS2 so you may possibly need to use BRP = 1n and then (3 + can.BTR[TS1] + can.BTR[TS2]) = 12

    To fully understand the TS1 and TS2 setting you need to read up on CAN

     

    Here's a link:

     

    https://sites.google.com/site/johnkneenmicrocontrollers/19_can_bus/can_stm32f107

     

    Very much about a  different processor but halfway down the page is a section on TS setting that may help.

     

    MK

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube