**UPGRADE YOUR BROWSER**

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Community Forums
- :
- Forums
- :
- Hardware Development
- :
- Processor System Design
- :
- Re: uart16550 with external clock - baudrate formu...

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

head_up

Contributor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-13-2019 03:42 AM

415 Views

Registered:
10-11-2009

uart16550 with external clock - baudrate formula?

I have created design with MicroBlaze + uart16550, Vivado 2018.3. My requirements are baudrate error less than 0.5%. I have generated frequency, good enough at xin pin of uart16550 using MMCM and PLL in chain to produce the required baudrate and error if I'm using the forumla in PG143, page 27:

divisor = (AXI CLK frequency/(16 × Baud Rate))

But this formula assumes the clock used to feed the baudrate generator is actually the AXI clock, not the external xin. And I can't find formula for external clock on xin. Anyway, when exploring the driver generated for this IP by SDK I found this (xuartns550.c, XUartNs550_SetBaudRate() ):

/* * Determine what the divisor should be to get the specified baud * rater based upon the input clock frequency and a baud clock prescaler * of 16 */ Divisor = ((InstancePtr->InputClockHz +((BaudRate * 16UL)/2)) / (BaudRate * 16UL));

Well, this formula differs from the documented one, so with it my error is above the desired limit.

The question is: **how must I calculate the correct divisor value and error when using external clock (xin) for uart16550 IO?**

7 Replies

head_up

Contributor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

06-18-2019 10:35 PM

369 Views

Registered:
10-11-2009

Re: uart16550 with external clock - baudrate formula?

Someone, please? The question is coming hot.

abhinayp

Xilinx Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-02-2019 12:55 AM

338 Views

Registered:
07-12-2018

Re: uart16550 with external clock - baudrate formula?

Hi @head_up ,

Please follow the below link and check the example 2 for usage of the AXI UART 16550 when external xin clock is used.

https://www.xilinx.com/support/documentation/ip_documentation/ds748_axi_uart16550.pdf

Best Regards

Abhinay PS

------------------------------------------------------------------------------------------------------------------------------

Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give kudos to a post which you think is helpful and reply oriented.

-------------------------------------------------------------------------------------------------------------------------------

Abhinay PS

------------------------------------------------------------------------------------------------------------------------------

Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.

Give kudos to a post which you think is helpful and reply oriented.

-------------------------------------------------------------------------------------------------------------------------------

head_up

Contributor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

07-02-2019 01:22 AM

327 Views

Registered:
10-11-2009

Re: uart16550 with external clock - baudrate formula?

khagen@irisdynamics.com

Visitor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-14-2019 04:07 PM

256 Views

Registered:
03-21-2019

Re: uart16550 with external clock - baudrate formula?

I would like to know where this equation comes from as well

xuart550.c /* * Determine what the divisor should be to get the specified baud * rater based upon the input clock frequency and a baud clock prescaler * of 16 */ Divisor = ((InstancePtr->InputClockHz +((BaudRate * 16UL)/2)) / (BaudRate * 16UL));

This is not consistent with the documentation of the PC16550, and this new equation apparently specific to the IP is not doucmented in the product guide, or in the driver code, apart from the comment block shown.

khagen@irisdynamics.com

Visitor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-14-2019 05:19 PM

244 Views

Registered:
03-21-2019

Re: uart16550 with external clock - baudrate formula?

The Xilinx driver forumula adds exactly 0.5 to the divisor for some reason..possiby for the following error calculations?

In any case, the 0.5 is dropped when the divisor is assigned to the uart's divisor latch, so assuming your baud passes the error calculations, it is correctly assigned.

I tested the UART using the PC16550 equation for finding the divisor and it works as expected.

In other words, if you assign the divisor manually as per the PC16550 documentation, you will get the BAUD you are expecting. And if you assign the BUAD using the xuartns550 drivers, asuming it passes the error calculations, it will also be assigned correctly despite the somewhat misleading equation.

Highlighted
##

allanherriman

Scholar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-16-2019 01:10 AM

220 Views

Registered:
01-08-2012

Re: uart16550 with external clock - baudrate formula?

Integer division is defined in C (for positive values) to round the result down to an integer.

e.g x is 111 and y is 16,

x / y gives the value 6.

For the Baud rate, we want to round to nearest (rather than down) because we want to minimise the rate error. In this case, we probably want x / y to give us the value 7, because 7 is closer to the exact result (6.9375) than 6.

The usual way of rouding to nearest is:

(x + y / 2) / y

which does give us the correct value in this case.

The Baud rate error depends on the exact ratio of clock frequencies. The formula that rounds to nearest is the one to use in the general case.

khagen@irisdynamics.com

Visitor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-16-2019 10:59 AM

195 Views

Registered:
03-21-2019

Re: uart16550 with external clock - baudrate formula?

Nice explaination, Allan

Thank you