<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>LPC MicrocontrollersのトピックRe: Set UART baud rate with UARTCLKDIV </title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Set-UART-baud-rate-with-UARTCLKDIV/m-p/527860#M9482</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by IanB on Sun Jul 26 23:41:54 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;The UART has another trap for the unwary. You can switch the FIFOs on or off. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If you switch them off, the UART doesn't work. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;. . .&amp;nbsp; so why the option to switch them on and off?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 19:27:56 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T19:27:56Z</dc:date>
    <item>
      <title>Set UART baud rate with UARTCLKDIV </title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Set-UART-baud-rate-with-UARTCLKDIV/m-p/527856#M9478</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by drvrh on Thu Jul 23 01:25:04 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://https://goo.gl/8py5XJ"&gt;this&lt;/A&gt;&lt;SPAN&gt; article is show how set baud rate for UART with UARTCLKDIV. From User manual I can't &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;set for 57600 baud rate. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;What is difference between set baud rate with UARTCLKDIV and DLL DLM.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:27:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Set-UART-baud-rate-with-UARTCLKDIV/m-p/527856#M9478</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: Set UART baud rate with UARTCLKDIV</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Set-UART-baud-rate-with-UARTCLKDIV/m-p/527857#M9479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by IanB on Sun Jul 26 10:48:13 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;It seems best to set UARTCLKDIV to 1.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then this will set DLL and DLM&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LDR R2,=clockspeed/(baudrate*16)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; STRB R2,[R3,DLL]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LSRS R2,R2,#8
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; STR R2,[R3,DLM]&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;SPAN&gt;Assuming you have the clock via the PLL running at 48MHz then&amp;nbsp; for 57600 baud it gives DLL=52, DLM=0 and a real baud rate of 57692 baud. Because the UART resynchronises every start bit, anything that's less than half a bit out in 10 bits will work!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;10 bits at 57600 baud = 173.6µs&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;10 bits at 57692 baud = 173.3µs&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;300ns out on a bit time of 17.3µs is not going to be a problem.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;However, if you want to use a lower clock speed, things might get trickier and you might have to use the fractional divider.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:27:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Set-UART-baud-rate-with-UARTCLKDIV/m-p/527857#M9479</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: Set UART baud rate with UARTCLKDIV </title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Set-UART-baud-rate-with-UARTCLKDIV/m-p/527858#M9480</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by IanB on Sun Jul 26 10:50:07 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;R3 contains LPC_UART_BASE, (0x40008000) but you'd already figured that out, hadn't you?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:27:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Set-UART-baud-rate-with-UARTCLKDIV/m-p/527858#M9480</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: Set UART baud rate with UARTCLKDIV</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Set-UART-baud-rate-with-UARTCLKDIV/m-p/527859#M9481</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by drvrh on Sun Jul 26 22:45:49 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I'am using DLM and DLL..&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;void SerialInit(uint32_t baudrate){
//uint32_t DL;

LPC_IOCON-&amp;gt;PIO1_7 &amp;amp;= ~0x07;
LPC_IOCON-&amp;gt;PIO1_7 |= 0x01;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* UART TXD */
LPC_SYSCON -&amp;gt; SYSAHBCLKCTRL|= (1 &amp;lt;&amp;lt; 12);
LPC_SYSCON -&amp;gt; UARTCLKDIV= 0x01;//
//DL = (SystemCoreClock * LPC_SYSCON -&amp;gt; SYSAHBCLKDIV)/(16 * baudrate * LPC_SYSCON -&amp;gt; UARTCLKDIV);
LPC_UART-&amp;gt;LCR = 0x83;&amp;nbsp; //&amp;nbsp; 8-bit character length, DLAB enable ( DLAB = 1)
LPC_UART-&amp;gt;DLM = (((SystemCoreClock)/ (16* baudrate)) / (256));&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp; Determines the baud rate of the UART (MSB Register)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Access DLAB = 1)
LPC_UART-&amp;gt;DLL = (((SystemCoreClock)/ (16* baudrate)) % (256));&amp;nbsp;&amp;nbsp;&amp;nbsp; //&amp;nbsp; Determines the baud rate of the UART (LSB Register)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (Access DLAB = 1)
LPC_UART-&amp;gt;LCR = 0x03;&amp;nbsp; //&amp;nbsp; 8-bit character length , DLAB disable ( DLAB = 0)
LPC_UART-&amp;gt;FCR = 0x07;
}
//***************end function SerialInit *******************************************&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:27:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Set-UART-baud-rate-with-UARTCLKDIV/m-p/527859#M9481</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:27:55Z</dc:date>
    </item>
    <item>
      <title>Re: Set UART baud rate with UARTCLKDIV </title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Set-UART-baud-rate-with-UARTCLKDIV/m-p/527860#M9482</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by IanB on Sun Jul 26 23:41:54 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;The UART has another trap for the unwary. You can switch the FIFOs on or off. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If you switch them off, the UART doesn't work. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;. . .&amp;nbsp; so why the option to switch them on and off?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:27:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Set-UART-baud-rate-with-UARTCLKDIV/m-p/527860#M9482</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:27:56Z</dc:date>
    </item>
    <item>
      <title>Re: Set UART baud rate with UARTCLKDIV</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Set-UART-baud-rate-with-UARTCLKDIV/m-p/527861#M9483</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by starblue on Mon Jul 27 03:10:51 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: drvrh&lt;/STRONG&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;((SystemCoreClock)/ (16* baudrate))&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This will always round down. It is better to round to the nearest integer, because that halves the maximal error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;((SystemCoreClock + 8 * baudrate) / (16 * baudrate))&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;BTW, 24MHz is a very nice clock frequency to get 115200 baud. The error is about 1/625 or 0.16%, because 25 * 25 = 26 * 24 + 1.&amp;nbsp; 24000000 = 2^9 * 3 * 5^6 ~ 2^13 * 3^2 * 5^2 * 13 and 16 * 115200 = 2^13 * 3^2 * 5^2, so if you divide the 24MHz by 13 you get almost exactly the right UART sample frequency.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Isn't math fun? &lt;SPAN class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;&lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jürgen&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:27:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Set-UART-baud-rate-with-UARTCLKDIV/m-p/527861#M9483</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: Set UART baud rate with UARTCLKDIV </title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Set-UART-baud-rate-with-UARTCLKDIV/m-p/527862#M9484</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by IanB on Mon Jul 27 23:59:58 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, I should have included the +0.5 - I think the assembler works out the constants using floating point, so &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SystemCoreClock/(16*baudrate) + 0.5 would have done the trick as well, but once the baud rate gets low enough and the divisor gets big enough the error is vanishingly small.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But watch out for those divisors which add an extra 1 (I think the A/D clock does that)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So everything also divides down from 48MHz pretty well (115200 is a divide by 26 with the same error), and all the other common values are factors of 115200 (9600 = 115200/12), so all have the same % error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Whose idea were all these strange baud rates?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I remember the days of the 6850 UART when we had to buy a 4.915MHz crystal to generate the baud rates, and that crystal had no other use.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Now I mainly deal with MIDI (31250 baud) and DMX (250kbaud) both of which (sensibly) divide down exactly from both 12MHz and 16MHz&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:27:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Set-UART-baud-rate-with-UARTCLKDIV/m-p/527862#M9484</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:27:57Z</dc:date>
    </item>
    <item>
      <title>Re: Set UART baud rate with UARTCLKDIV </title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Set-UART-baud-rate-with-UARTCLKDIV/m-p/527863#M9485</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by starblue on Sat Aug 01 11:48:50 MST 2015&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: IanB&lt;/STRONG&gt;&lt;BR /&gt;Whose idea were all these strange baud rates?&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It started with 300 baud (at least that is the lowest I encountered in the early eighties, ignoring 1200/75 for BTX), on an acoustic coupler.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Then you start doubling it: 600, 1200, 2400, 4800, 9600, 19200, 38400 were all common baud rates for modems.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The ISDN phone system sends 8K samples of 8 bits per second, so it maxes out at 64Kbit/s, so you can't get 76800 over a phone line.&amp;nbsp; You can't get 64Kbit/s either on an analog phone because of the digital-to-analog-to-digital conversion. But you can get 57600 = 3 * 19200 if the line is good.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Continue doubling: 115200, ...&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:27:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Set-UART-baud-rate-with-UARTCLKDIV/m-p/527863#M9485</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:27:58Z</dc:date>
    </item>
  </channel>
</rss>

