<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>UART BAUDRATE register values</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/391/uart-baudrate-register-values</link><description>What is the formula for calculation of values for the UART BAUDRATE register from bit rates?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 30 Aug 2013 09:38:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/391/uart-baudrate-register-values" /><item><title>RE: UART BAUDRATE register values</title><link>https://devzone.nordicsemi.com/thread/2050?ContentTypeID=1</link><pubDate>Fri, 30 Aug 2013 09:38:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5e364abf-fd9f-469a-b3ca-4b828d00a9f2</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi Bengt,&lt;/p&gt;
&lt;p&gt;That specific value got me a bit puzzled.
I had a quick chat with a HW-designer, and he assured me that the baudrate generator for the UART is actually 20 bits, so rounding procedure is required.&lt;/p&gt;
&lt;p&gt;As far as I see, the 921K600 baud definition in nrf51_bitfields.h is incorrect. I will input a bug regarding this item.
I see that this define is removed from our reference manual, so it&amp;#39;s likely a glitch that it&amp;#39;s still defined in the header file.&lt;/p&gt;
&lt;p&gt;I will also push for the calculation to be inserted into our documentation.&lt;/p&gt;
&lt;p&gt;BR
Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART BAUDRATE register values</title><link>https://devzone.nordicsemi.com/thread/2049?ContentTypeID=1</link><pubDate>Fri, 30 Aug 2013 08:26:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9aae3278-edeb-47b4-a084-bb246f27e4fd</guid><dc:creator>Bengt Florin</dc:creator><description>&lt;p&gt;This is the tested code to get the BAUDRATE value from an arbitrary bit rate. It gives the same values as  &amp;#39;nrf51_bitfields.h&amp;#39; except for 921600bps and for that we wait for an explanation from Håkon.&lt;/p&gt;
&lt;p&gt;static uint32_t uartBaudrate(uint32_t bps)
{
return ((bps * 0x100000000ULL) / SYSCLK + 0x800) &amp;amp; 0xfffff000;
}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART BAUDRATE register values</title><link>https://devzone.nordicsemi.com/thread/2048?ContentTypeID=1</link><pubDate>Fri, 30 Aug 2013 08:22:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5bfe96ed-b7dc-4ef6-9dc5-f7da55bee9f8</guid><dc:creator>Bengt Florin</dc:creator><description>&lt;p&gt;BTW, why the heavy rounding? &amp;#39;nrf51_bitfields.h&amp;#39; have a value for 921600bps that is 0x0EBEDFA4UL. By rounding this gets 0x0EBEE000. Does this imply the the baud rate counter is not 32-bit but mere 20-bit?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART BAUDRATE register values</title><link>https://devzone.nordicsemi.com/thread/2047?ContentTypeID=1</link><pubDate>Fri, 30 Aug 2013 07:25:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ebefe61d-26e1-4cd9-8ac5-278d8d8af5d1</guid><dc:creator>Bengt Florin</dc:creator><description>&lt;p&gt;Tnx Håkon. I assume you put this in the next Reference Manual as well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: UART BAUDRATE register values</title><link>https://devzone.nordicsemi.com/thread/2046?ContentTypeID=1</link><pubDate>Fri, 30 Aug 2013 06:48:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:923ff84d-c204-49c0-89cb-e363f3f4e53a</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi Bengt,&lt;/p&gt;
&lt;p&gt;&lt;em&gt;note&lt;/em&gt;: &lt;strong&gt;this formula is simplified and may differ from the actual baudrate measurement&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The formula is:
Baudrate = desired baudrate * 2^32 / 16000000&lt;/p&gt;
&lt;p&gt;Example:
Baudrate of 31250 should then be 8388608 decimal = 0x800000.&lt;/p&gt;
&lt;p&gt;Note that you will have to round the number afterwards:
rounded_value = (value + 0x800) &amp;amp; 0xFFFFF000&lt;/p&gt;
&lt;p&gt;Since the baudrate generator will be sourced by the 16 M (Either RC or XOSC, depending on your configuration), then your error rate will be ~equal to the overall drift of the system clock and the accuracy of the baudrate generator towards your target baudrate.&lt;/p&gt;
&lt;p&gt;Other way around:
Check out this define in nrf51_bitfields.h line 5702:&lt;/p&gt;
&lt;p&gt;UART_BAUDRATE_BAUDRATE_Baud115200 (0x01D7E000UL) /*!&amp;lt; 115200 baud. */&lt;/p&gt;
&lt;p&gt;The actual baudrate set with the above define is:&lt;/p&gt;
&lt;p&gt;baudrate_reg_val * 16M / 2^32 = 115203.86 baud.&lt;/p&gt;
&lt;p&gt;Best regards
Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>