<?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>topic Re: UART Receive Buffer (LPC1768) in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/UART-Receive-Buffer-LPC1768/m-p/522915#M5551</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by embd02161991 on Fri Sep 12 17:07:10 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi ,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The&amp;nbsp; right approach for fetching the valid pair of received byte and its status bits is first to read the content of the LSR register, and then to read a byte from the RBR. The best way is to store the value in RBR into another variable and handle that in main. Since RBR is volatile and changes , it&amp;nbsp; may not be reliable to print the register directly in main as by then the value could have changed. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;NXP Technical Support&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 16:41:56 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T16:41:56Z</dc:date>
    <item>
      <title>UART Receive Buffer (LPC1768)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/UART-Receive-Buffer-LPC1768/m-p/522914#M5550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by expressouser on Tue Jun 24 09:42:29 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi .&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is the UART interrupt handler expected to clear the RBR register upon exit? I am trying to read out the content of the RBR register outside of the handler,but it seems like the value is already cleared by the handler. Thanks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here's some part of my code:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;inside main():&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;while (1) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while (rbr == 0);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;printf ("%c\n", LPC_UART2-&amp;gt;RBR); //this simply prints a \n, not the character from RBR.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rbr = 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;interrupt handler:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;void UART2_IRQHandler(void) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;uint32_t status = LPC_UART2-&amp;gt;IIR;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if ( (status &amp;amp; IRQ_RDA) == IRQ_RDA) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while ((LPC_UART2-&amp;gt;LSR &amp;amp; 0x20) == 0);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rbr =1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;it works well when I am reading RBR inside the handler:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;code&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;inside main:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;while (1) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while (rbr == 0);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;printf ("%c\n", ch); //this is ok.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rbr = 0;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;interrupt handler:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;void UART2_IRQHandler(void) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;uint32_t status = LPC_UART2-&amp;gt;IIR;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;if ( (status &amp;amp; IRQ_RDA) == IRQ_RDA) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;while ((LPC_UART2-&amp;gt;LSR &amp;amp; 0x20) == 0);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ch = LPC_UART2-&amp;gt;RBR;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rbr =1;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;/code&amp;gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:41:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/UART-Receive-Buffer-LPC1768/m-p/522914#M5550</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: UART Receive Buffer (LPC1768)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/UART-Receive-Buffer-LPC1768/m-p/522915#M5551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by embd02161991 on Fri Sep 12 17:07:10 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi ,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The&amp;nbsp; right approach for fetching the valid pair of received byte and its status bits is first to read the content of the LSR register, and then to read a byte from the RBR. The best way is to store the value in RBR into another variable and handle that in main. Since RBR is volatile and changes , it&amp;nbsp; may not be reliable to print the register directly in main as by then the value could have changed. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;NXP Technical Support&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 16:41:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/UART-Receive-Buffer-LPC1768/m-p/522915#M5551</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T16:41:56Z</dc:date>
    </item>
  </channel>
</rss>

