<?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中的主题 LPC1766 UART send garbled</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1766-UART-send-garbled/m-p/863374#M34405</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;&lt;/CODE&gt;My code is below, when i run this code, I received the data like the picture. Anyone can tell me why?&lt;/P&gt;&lt;P&gt;Receive baudrate is 9600. Use TTL-USB connect to my computer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt; uint32_t i,j, k=0;&lt;BR /&gt;&lt;BR /&gt; SystemInit();&lt;BR /&gt; UART0_Init(9600);&lt;BR /&gt;&lt;BR /&gt; UART0_SendString("hello world");&lt;BR /&gt; Delay(250);&lt;BR /&gt;}&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;&lt;/CODE&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;#define FOSC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12000000&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;#define FCCLK &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(FOSC &amp;nbsp;* 8)&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;#define FCCO &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (FCCLK * 3)&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;#define FPCLK &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(FCCLK / 4)&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;void UART0_Init (uint32_t baudrate)&lt;BR /&gt;{&lt;BR /&gt; uint16_t usFdiv;&lt;BR /&gt; /* UART0 */&lt;BR /&gt; LPC_PINCON-&amp;gt;PINSEL0 |= (1 &amp;lt;&amp;lt; 4);&lt;BR /&gt; LPC_PINCON-&amp;gt;PINSEL0 |= (1 &amp;lt;&amp;lt; 6);&lt;BR /&gt;&lt;BR /&gt; LPC_UART0-&amp;gt;LCR = 0x83;&lt;BR /&gt; usFdiv = (FPCLK / 16) / baudrate;&lt;BR /&gt; LPC_UART0-&amp;gt;DLM = usFdiv / 256;&lt;BR /&gt; LPC_UART0-&amp;gt;DLL = usFdiv % 256;&lt;BR /&gt; LPC_UART0-&amp;gt;LCR = 0x03;&lt;BR /&gt; LPC_UART0-&amp;gt;FCR = 0x06;&lt;BR /&gt; }&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/77912i13F0A14C6D276998/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_2.png" alt="pastedImage_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 16 Mar 2019 07:39:13 GMT</pubDate>
    <dc:creator>125621365</dc:creator>
    <dc:date>2019-03-16T07:39:13Z</dc:date>
    <item>
      <title>LPC1766 UART send garbled</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1766-UART-send-garbled/m-p/863374#M34405</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;&lt;/CODE&gt;My code is below, when i run this code, I received the data like the picture. Anyone can tell me why?&lt;/P&gt;&lt;P&gt;Receive baudrate is 9600. Use TTL-USB connect to my computer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt; uint32_t i,j, k=0;&lt;BR /&gt;&lt;BR /&gt; SystemInit();&lt;BR /&gt; UART0_Init(9600);&lt;BR /&gt;&lt;BR /&gt; UART0_SendString("hello world");&lt;BR /&gt; Delay(250);&lt;BR /&gt;}&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;&lt;/CODE&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;#define FOSC &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;12000000&amp;nbsp;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;#define FCCLK &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(FOSC &amp;nbsp;* 8)&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;#define FCCO &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; (FCCLK * 3)&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;#define FPCLK &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;(FCCLK / 4)&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;void UART0_Init (uint32_t baudrate)&lt;BR /&gt;{&lt;BR /&gt; uint16_t usFdiv;&lt;BR /&gt; /* UART0 */&lt;BR /&gt; LPC_PINCON-&amp;gt;PINSEL0 |= (1 &amp;lt;&amp;lt; 4);&lt;BR /&gt; LPC_PINCON-&amp;gt;PINSEL0 |= (1 &amp;lt;&amp;lt; 6);&lt;BR /&gt;&lt;BR /&gt; LPC_UART0-&amp;gt;LCR = 0x83;&lt;BR /&gt; usFdiv = (FPCLK / 16) / baudrate;&lt;BR /&gt; LPC_UART0-&amp;gt;DLM = usFdiv / 256;&lt;BR /&gt; LPC_UART0-&amp;gt;DLL = usFdiv % 256;&lt;BR /&gt; LPC_UART0-&amp;gt;LCR = 0x03;&lt;BR /&gt; LPC_UART0-&amp;gt;FCR = 0x06;&lt;BR /&gt; }&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_2.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/77912i13F0A14C6D276998/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_2.png" alt="pastedImage_2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 16 Mar 2019 07:39:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1766-UART-send-garbled/m-p/863374#M34405</guid>
      <dc:creator>125621365</dc:creator>
      <dc:date>2019-03-16T07:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: LPC1766 UART send garbled</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1766-UART-send-garbled/m-p/863375#M34406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Teng,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding your question, I suppose that the incorrect baudrate leads to the issue.&lt;/P&gt;&lt;P&gt;From the code, it seems that the oscillator clock frequency is 12MHz, the cpu core clock frequency FCCLK is 12*8=96MHz, the uart0 driving clock frequency FPCLK is 96MHz/4=24MHz.&lt;/P&gt;&lt;P&gt;Pls confirm whether the peripheral clock is 24MHz, you can output FCCLK signal to CLKOUT pin and use scope to measure the frequency.&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;usFdiv = (FPCLK / 16) / baudrate;&lt;BR /&gt; LPC_UART0-&amp;gt;DLM = usFdiv / 256; //LPC_UART0-&amp;gt;DLM = usFdiv&amp;gt;&amp;gt;8;&lt;BR /&gt; LPC_UART0-&amp;gt;DLL = usFdiv&amp;amp;0xFF;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;BTW, I suppose you have to write the &lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;PCLKSEL0&amp;amp;=~(0x03&amp;lt;&amp;lt;6); //select FCLK/4&lt;BR /&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;Hope it can help you&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;BR&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;XiangJun Rong&lt;/CODE&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="border: 0px; font-weight: inherit;"&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Mar 2019 03:36:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1766-UART-send-garbled/m-p/863375#M34406</guid>
      <dc:creator>xiangjun_rong</dc:creator>
      <dc:date>2019-03-18T03:36:16Z</dc:date>
    </item>
    <item>
      <title>Re: LPC1766 UART send garbled</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1766-UART-send-garbled/m-p/863376#M34407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your reply, I solved this problem. I used TTL to USB to receive the messages, but there is a MAX232 chip translate the signal to RS232. So when I used RS232 to USB then the data&amp;nbsp; is normal.&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 18 Mar 2019 15:56:50 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1766-UART-send-garbled/m-p/863376#M34407</guid>
      <dc:creator>125621365</dc:creator>
      <dc:date>2019-03-18T15:56:50Z</dc:date>
    </item>
  </channel>
</rss>

