element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • 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 Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • 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 Boards Community
  • Avnet Boards Forums
  • More
  • Cancel
Avnet Boards Forums
Software Application Development Configure UART 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 4 replies
  • Subscribers 329 subscribers
  • Views 1428 views
  • Users 0 members are here
Related

Configure UART Baud rate

Former Member
Former Member over 12 years ago

Hi,

I'm using the UART1 to transfer data from a PC program to PS in ZedBoard. It works fine at 115200 baud/s, but I cant get it to work at higher baud rates.
I have changed the settings in XPS (under general settings) and when I use the same baud rate during debugging there are just rubbish coming from the ZedBoard.

Does anyone know how to configure the baud rate for higher speeds? (baud rate > 115200)

// Mikael

  • Sign in to reply
  • Cancel
Parents
  • zedhed
    0 zedhed over 10 years ago

    Hi L30nardoSV,

    I took a look at this and it seems like a call to the BSP API XUartPs_SetBaudRate() would do the trick.  However, if you try to set the baud rate to 230400 using that function, your application will throw an assertion trap because that baud rate falls outside the range for which the SDK API has been tested (110 to 115200).  If you look inside of the XUartPs_SetBaudRate() code, you can see that the BSP code takes the requested baud rate and does some checking to see what is the best baud divider value to achieve the requested baud rate.

    According to the comments in the BSP code, the MIN and MAX baud rates (110 to 115200) are implemented only because that is the range that has been tested.  The Zynq hardware is capable of other baud rates but you may need to do some further work on your end to achieve the divider that also gives a reasonable error rate for 230400 baud.

    I tried this approach in my SDK application and it appears to be working but keep in mind that my ZedBoard is sitting on my desk at room temperature so your results may vary depending upon your application:

    1)  It is not good practice to modify your BSP because your work can be overwritten when SDK regenerates the BSP by calling libgen so copy the entire XUartPs_SetBaudRate() function up to your application and rename it to something else.  I named it simply SetBaudRate() in my application in a platform.c file.

    Now you should be able to modify this function as you see fit for your own application.

    2) I defined my own MAX_BAUD_ERROR_RATE as 3 and changed all of the XUARTPS_MAX_BAUD_ERROR_RATE references to match.

    3) I removed the Xil_AssertNonvoid() checks for XUARTPS_MAX_RATE and XUARTPS_MIN_RATE.

    4) Made a call to my new SetBaudRate() AFTER the PS UART is initialized with XUartPs_CfgInitialize().

    5) Built my application.

    6) Set my Tera Term to 230400 baud.

    7) Run my application and I can see the clean terminal output within Tera Term.

    I am sure that you might think of some ways to make this more elegant but this approach should at least get you to the point of demonstrating that the higher baud rate is achievable.

    Regards,

    -Kevin

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • zedhed
    0 zedhed over 10 years ago

    Hi L30nardoSV,

    I took a look at this and it seems like a call to the BSP API XUartPs_SetBaudRate() would do the trick.  However, if you try to set the baud rate to 230400 using that function, your application will throw an assertion trap because that baud rate falls outside the range for which the SDK API has been tested (110 to 115200).  If you look inside of the XUartPs_SetBaudRate() code, you can see that the BSP code takes the requested baud rate and does some checking to see what is the best baud divider value to achieve the requested baud rate.

    According to the comments in the BSP code, the MIN and MAX baud rates (110 to 115200) are implemented only because that is the range that has been tested.  The Zynq hardware is capable of other baud rates but you may need to do some further work on your end to achieve the divider that also gives a reasonable error rate for 230400 baud.

    I tried this approach in my SDK application and it appears to be working but keep in mind that my ZedBoard is sitting on my desk at room temperature so your results may vary depending upon your application:

    1)  It is not good practice to modify your BSP because your work can be overwritten when SDK regenerates the BSP by calling libgen so copy the entire XUartPs_SetBaudRate() function up to your application and rename it to something else.  I named it simply SetBaudRate() in my application in a platform.c file.

    Now you should be able to modify this function as you see fit for your own application.

    2) I defined my own MAX_BAUD_ERROR_RATE as 3 and changed all of the XUARTPS_MAX_BAUD_ERROR_RATE references to match.

    3) I removed the Xil_AssertNonvoid() checks for XUARTPS_MAX_RATE and XUARTPS_MIN_RATE.

    4) Made a call to my new SetBaudRate() AFTER the PS UART is initialized with XUartPs_CfgInitialize().

    5) Built my application.

    6) Set my Tera Term to 230400 baud.

    7) Run my application and I can see the clean terminal output within Tera Term.

    I am sure that you might think of some ways to make this more elegant but this approach should at least get you to the point of demonstrating that the higher baud rate is achievable.

    Regards,

    -Kevin

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
No Data
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