<?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 FIFO appears empty even though it is not (K64 &amp; MQX 4.1) in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372438#M12301</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I had a similar Problem with other Kinetis (K70/60/10) and after some heavy debugging I think there's a hardware bug in the Kinetis Uart module.The Kinetis Uart itself has a internal FIFO (some chips more deep, some chips less deep). After a overrun of this FIFO occurs (a character isn't fetched by IRQ when it is already full and a new one arrives) this FIFO stops functioning: Write and read pointers of that Hardware FIFO will have an offset afterwards, which means you will get your following characters with a delay. The Interrupt for character n+1 lets you read character n, the Interrupt for character n+2 lets you read character n+1 and so on.&lt;/P&gt;&lt;P&gt;After messing around with that problem I found the following solution (more or less empirically):&lt;/P&gt;&lt;P&gt;Locate all occurences of&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14242712610199818 jive_text_macro jive_macro_code" jivemacro_uid="_14242712610199818"&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if(stat &amp;amp; UART_S1_OR_MASK) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ++sci_info_ptr-&amp;gt;RX_OVERRUNS;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;


&lt;/PRE&gt;&lt;P&gt;and replace it with&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14242712610016643 jive_text_macro jive_macro_code" jivemacro_uid="_14242712610016643" modifiedtitle="true"&gt;
&lt;P&gt;&amp;nbsp; if (stat &amp;amp; UART_S1_OR_MASK) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sci_ptr-&amp;gt;CFIFO |= UART_CFIFO_RXFLUSH_MASK;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sci_ptr-&amp;gt;PFIFO &amp;amp;= ~UART_PFIFO_RXFE_MASK;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = sci_ptr-&amp;gt;D;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sci_ptr-&amp;gt;PFIFO |= UART_PFIFO_RXFE_MASK;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ++sci_info_ptr-&amp;gt;RX_OVERRUNS;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; }&lt;/P&gt;



&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;The locations are in&lt;/P&gt;&lt;P&gt;serl_pol_kuart.c and in serl_int_kuart.c&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 18 Feb 2015 14:46:54 GMT</pubDate>
    <dc:creator>johannesschock</dc:creator>
    <dc:date>2015-02-18T14:46:54Z</dc:date>
    <item>
      <title>UART FIFO appears empty even though it is not (K64 &amp; MQX 4.1)</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372432#M12295</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a somewhat rare issue with my UART RX FIFO. The &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;K64 UART is connected to a half duplex RS485. I haven't pinned down exactly how to cause the issue yet, but it seems to occur more frequently when I send lots of contiguous serial data. If I had to guess, it would be caused by a bit r framing error on the UART bus.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Setup:&lt;/P&gt;&lt;P&gt;- K64 &amp;amp; MQX 4.1&lt;/P&gt;&lt;P&gt;- UART1 interrupt mode (8N1 @ 115200)&lt;/P&gt;&lt;P&gt;- RTS pin controls RS485 flow control (flag: IO_SERIAL_HW_485_FLOW_CONTROL)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The symptom: &lt;/P&gt;&lt;P&gt;Once the issue occurs, it never seems to go away until I reset the K64. As an example: the master will send a packet of say 10 bytes&amp;nbsp; to the k64 slaves on the rs485 bus. Then the k64 will read one byte at a time from the UART driver. The following function is used to determine if data is ready to be read:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _io_ioctl(port, IO_IOCTL_CHAR_AVAIL, &amp;amp;ready); &lt;/P&gt;&lt;P&gt;When the issue occurs, I can read say 6 bytes from the UART buffer, and then ready becomes FALSE, even though there is still 4 more bytes that should be ready. This function will continue so indicate no data is ready until an additional byte is sent by the master, in which case I will be able to ready 1 more byte from the UART driver. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It seems as if the data is stuck in the FIFO, but is not accessible. I have put a sniffer on the bus to confirm that the data wasn't being cached in the master side UART and can see all the data on the bus. I've also had multiple k64's on the same bus all receiving the same data and some of the K64s will receive all the data properly and others will get into this erroneous state.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Seems to be related to: &lt;A href="https://community.nxp.com/message/468988"&gt;K22 MXQ4.02 serial port will miss characters if paste a lot of commands together(cause overflow and RX_OVERRUNS)&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Feb 2015 18:47:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372432#M12295</guid>
      <dc:creator>tmeyer</dc:creator>
      <dc:date>2015-02-12T18:47:47Z</dc:date>
    </item>
    <item>
      <title>Re: UART FIFO appears empty even though it is not (K64 &amp; MQX 4.1)</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372433#M12296</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This issue maybe?&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/message/439212"&gt;Re: Bug Report: In MQX 4.1 change of size of bool can cause stack corruption&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Feb 2015 19:30:44 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372433#M12296</guid>
      <dc:creator>matthewkendall</dc:creator>
      <dc:date>2015-02-13T19:30:44Z</dc:date>
    </item>
    <item>
      <title>Re: UART FIFO appears empty even though it is not (K64 &amp; MQX 4.1)</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372434#M12297</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Tim,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you please confirm if the Matthew's suggestion helps???&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt; Sol &lt;BR /&gt; &lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Feb 2015 22:51:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372434#M12297</guid>
      <dc:creator>soledad</dc:creator>
      <dc:date>2015-02-13T22:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: UART FIFO appears empty even though it is not (K64 &amp; MQX 4.1)</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372435#M12298</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the response. This doesn't appear to be related to the IOCTL_CHAR_AVAIL. I can reproduce the same issue using a simple polled UART0 connected to the shell. After sending arbitrary data to the shell, it will then start echoing characters that were sent 1-3 keystrokes ago. (I double checked this with a scope to ensure I was sending the correct chars).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Upon debugging it in this state, it is clear that there is nothing to be read since there are 0 chars in the uart driver CHARQ. Also, the UART peripheral registers indicate that the RX FIFO is empty:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Serial Communication Interface (UART0)&lt;/TD&gt;&lt;TD&gt;&lt;/TD&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lt;/TD&gt;&lt;TD&gt;0x4006a01d&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;UART0_ET7816&lt;/TD&gt;&lt;TD&gt;0x00&lt;/TD&gt;&lt;TD&gt;0x4006a01e&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;/TD&gt;&lt;TD&gt;UART0_TL7816&lt;/TD&gt;&lt;TD&gt;0x00&lt;/TD&gt;&lt;TD&gt;0x4006a01f&lt;/TD&gt;&lt;TD&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I also find interesting is that if I physically unplug the TTL level UART cable from the processor and plug it back in - the characters will start coming in correctly. It is as if, the &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2015 16:20:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372435#M12298</guid>
      <dc:creator>tmeyer</dc:creator>
      <dc:date>2015-02-17T16:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: UART FIFO appears empty even though it is not (K64 &amp; MQX 4.1)</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372436#M12299</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;there are 0 chars in the uart driver CHARQ&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;The CHARQ struct (as defined by psp/PSP_Generic/include/charq.h) includes not only head and tail indexes (.HEAD and .TAIL) but also a count of the number of chars in the queue (.CURRENT_SIZE). This is clearly redundant and is likely included as an optimisation.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;In other contexts I have had trouble with CHARQ where the count became inconsistent with the head and tail indexes. This should not be possible if the CHARQ is always accessed via the provided macros. But there is no flush macro for example, so it is possible that someone decided to directly access the struct. &lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;It might be worth investigating if something in the serial driver can cause a problem, for example by directly setting CURRENT_SIZE to zero to flush the queue without making corresponding change to HEAD and TAIL. &lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px; line-height: 1.5em;"&gt;In your error state it might be worth checking to see if the CHARQ is self-consistent.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2015 17:59:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372436#M12299</guid>
      <dc:creator>matthewkendall</dc:creator>
      <dc:date>2015-02-17T17:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: UART FIFO appears empty even though it is not (K64 &amp; MQX 4.1)</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372437#M12300</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Matthew for the replay. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I looked into the CHARQ and it appears that it is behaving as expected. I can step through the code and see the old character(and not the one most recently typed). &lt;/P&gt;&lt;P&gt;ex:&lt;/P&gt;&lt;P&gt;Sequence of events:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Type "12" into the shell &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;The final character enqueue via _CHARQ_ENQUEUE in the_io_serial_polled_read() function is the '1' character. (Not the '2' as expected).&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;_kuart_polled_status() indicate that the RX FIFO is empty: UART_SFIFO_RXEMPT_MASK is set, and RXCOUNT in the RCFIFO register is also 0.&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;"1" is echoed to the shell console&lt;/LI&gt;&lt;LI&gt;Type "3" into shell&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="font-size: 10pt;"&gt;The '2' character is now enqueued via _CHARQ_ENQUEUE in the_io_serial_polled_read() function. &lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="font-size: 10pt;"&gt;_kuart_polled_status() indicate that the RX FIFO is empty: UART_SFIFO_RXEMPT_MASK is set&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;"2" is echoed to the shell console&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This appears to me that the serial peripheral is somehow caching these characters in it's FIFO or elsewhere. It seems incorrect to me that the FIFO indicates it is empty, however a byte that was sent to the UART prior shows up after sending a new byte.&amp;nbsp; Is there a chance there is an errata relating to the hardware peripheral?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Feb 2015 22:35:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372437#M12300</guid>
      <dc:creator>tmeyer</dc:creator>
      <dc:date>2015-02-17T22:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: UART FIFO appears empty even though it is not (K64 &amp; MQX 4.1)</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372438#M12301</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I had a similar Problem with other Kinetis (K70/60/10) and after some heavy debugging I think there's a hardware bug in the Kinetis Uart module.The Kinetis Uart itself has a internal FIFO (some chips more deep, some chips less deep). After a overrun of this FIFO occurs (a character isn't fetched by IRQ when it is already full and a new one arrives) this FIFO stops functioning: Write and read pointers of that Hardware FIFO will have an offset afterwards, which means you will get your following characters with a delay. The Interrupt for character n+1 lets you read character n, the Interrupt for character n+2 lets you read character n+1 and so on.&lt;/P&gt;&lt;P&gt;After messing around with that problem I found the following solution (more or less empirically):&lt;/P&gt;&lt;P&gt;Locate all occurences of&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14242712610199818 jive_text_macro jive_macro_code" jivemacro_uid="_14242712610199818"&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; if(stat &amp;amp; UART_S1_OR_MASK) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ++sci_info_ptr-&amp;gt;RX_OVERRUNS;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;


&lt;/PRE&gt;&lt;P&gt;and replace it with&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14242712610016643 jive_text_macro jive_macro_code" jivemacro_uid="_14242712610016643" modifiedtitle="true"&gt;
&lt;P&gt;&amp;nbsp; if (stat &amp;amp; UART_S1_OR_MASK) {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sci_ptr-&amp;gt;CFIFO |= UART_CFIFO_RXFLUSH_MASK;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sci_ptr-&amp;gt;PFIFO &amp;amp;= ~UART_PFIFO_RXFE_MASK;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; c = sci_ptr-&amp;gt;D;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; sci_ptr-&amp;gt;PFIFO |= UART_PFIFO_RXFE_MASK;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ++sci_info_ptr-&amp;gt;RX_OVERRUNS;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; }&lt;/P&gt;



&lt;/PRE&gt;&lt;P&gt;&lt;BR /&gt;The locations are in&lt;/P&gt;&lt;P&gt;serl_pol_kuart.c and in serl_int_kuart.c&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Feb 2015 14:46:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372438#M12301</guid>
      <dc:creator>johannesschock</dc:creator>
      <dc:date>2015-02-18T14:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: UART FIFO appears empty even though it is not (K64 &amp; MQX 4.1)</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372439#M12302</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That fixed it. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 18 Feb 2015 15:29:24 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372439#M12302</guid>
      <dc:creator>tmeyer</dc:creator>
      <dc:date>2015-02-18T15:29:24Z</dc:date>
    </item>
    <item>
      <title>Re: UART FIFO appears empty even though it is not (K64 &amp; MQX 4.1)</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372440#M12303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Fixed for me too, thanks a lot !!!&lt;/P&gt;&lt;P&gt;It was a long long problem for me...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yvan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 May 2015 09:46:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372440#M12303</guid>
      <dc:creator>yb</dc:creator>
      <dc:date>2015-05-05T09:46:47Z</dc:date>
    </item>
    <item>
      <title>Re: UART FIFO appears empty even though it is not (K64 &amp; MQX 4.1)</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372441#M12304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Does anyone know if this was ever documented as an Errata for the kinetis parts? I have encountered this same issue again.&lt;/P&gt;&lt;P&gt;I would like to determine if the newer rev's of certain processors have fixed this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jul 2015 16:45:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372441#M12304</guid>
      <dc:creator>tmeyer</dc:creator>
      <dc:date>2015-07-17T16:45:39Z</dc:date>
    </item>
    <item>
      <title>Re: UART FIFO appears empty even though it is not (K64 &amp; MQX 4.1)</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372442#M12305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Be careful !&lt;/P&gt;&lt;P&gt;Under MQX 4.2, the bug is not fixed :-(&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Yvan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Aug 2015 07:23:23 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372442#M12305</guid>
      <dc:creator>yb</dc:creator>
      <dc:date>2015-08-18T07:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: UART FIFO appears empty even though it is not (K64 &amp; MQX 4.1)</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372443#M12306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have detected the same problem in KDS v3.0.0 with SDK v1.2.0 using MQX.&lt;/P&gt;&lt;P&gt;The UART driver is totally different, but the same solution applies :-)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I find very interesting that Freescale does not confirm if this is a hardware-related issue or not. And I find even more interesting that Freescale does not solve the problem, as this existed for a very very long time...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you, Johannes, for your answer :-)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT: oh, I forgot to say that I found the problem using a K64. The same problem happened in a K10 using CodeWarrior and MQX 4.1&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Aug 2015 15:15:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372443#M12306</guid>
      <dc:creator>cgarcia1</dc:creator>
      <dc:date>2015-08-20T15:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: UART FIFO appears empty even though it is not (K64 &amp; MQX 4.1)</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372444#M12307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/johannesschock"&gt;johannesschock&lt;/A&gt;​, is there any chance you have used the KSDK and have seen something similar?&amp;nbsp; I'm using MQX for KSDK 1.2 and have a very similar sort of behavior where over time, something the RX interrupt causes me to miss a byte, but rather than ending up with one bad packet, every packet is bad.&amp;nbsp; If I look at my buffer, it seems like data from the previous partially received packet is read as part of the next packet.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, let's say I normally get something like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;0B 04 08 00 00 00 00 00 04 FA 3F 46 A4&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But at the failure point, the packet could look like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;15 0B 04 08 00 00 00 00 00 04 FA 3F 46&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;so the 15 comes from a previous packet's CRC, and therefore the last byte of the CRC for the present packet gets cut off.&amp;nbsp; And of course, this just completely messes up everything.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know I'm asking for a miracle, but I am hoping that you or someone else has seen this with the KSDK as well.&amp;nbsp; I'm going to take the information you have provided to &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/tmeyer"&gt;tmeyer&lt;/A&gt;​ and see if it helps me find anything that can be fixed in the KSDK, if applicable.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Nov 2015 05:35:26 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372444#M12307</guid>
      <dc:creator>dave408</dc:creator>
      <dc:date>2015-11-09T05:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: UART FIFO appears empty even though it is not (K64 &amp; MQX 4.1)</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372445#M12308</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi dave408,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I was forced to switch to KDS and KSDK, and as I could see, the same issue happens in KSDK 1.2 and the newest KSDK 1.3.&lt;/P&gt;&lt;P&gt;To solve this problem you will have to apply Johannes' solution. In KSDK the UART driver is different, but the same concept applies. When you detect a RX overrun, you will have to perform the same steps shown in Johannes' solution. This worked for me, almost magically :-)&lt;/P&gt;&lt;P&gt;I'm not allowed to share my code, but it's not difficult to do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't understand how Freescale have not pronounced on this issue yet... Everybody uses a UART for almost all projects, and it has to be robust...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EDIT: Please, note that when you fetch a character from UART, status flags are cleared. You will have to check for kUartRxOverrun before UART_HAL_Getchar is called.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Nov 2015 06:30:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372445#M12308</guid>
      <dc:creator>cgarcia1</dc:creator>
      <dc:date>2015-11-09T06:30:16Z</dc:date>
    </item>
    <item>
      <title>Re: UART FIFO appears empty even though it is not (K64 &amp; MQX 4.1)</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372446#M12309</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, Carlos, I hadn't scrolled down all the way and read your response from August.&amp;nbsp; I appreciate your replying to my needless post.&amp;nbsp; :smileyhappy:&amp;nbsp; I'll work on investigating a fix today!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Nov 2015 12:33:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372446#M12309</guid>
      <dc:creator>dave408</dc:creator>
      <dc:date>2015-11-09T12:33:17Z</dc:date>
    </item>
    <item>
      <title>Re: UART FIFO appears empty even though it is not (K64 &amp; MQX 4.1)</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372447#M12310</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/cgarcia" rel="nofollow noopener noreferrer" target="_blank"&gt;cgarcia&lt;/A&gt;​ thanks for the edit.&amp;nbsp; At least now I'm seeing some problems I hadn't caught before.&amp;nbsp; I can see that I am getting RX overruns and framing errors as well.&amp;nbsp; Now I just have to solve the issue.&amp;nbsp; I took &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/johannesschock" rel="nofollow noopener noreferrer" target="_blank"&gt;johannesschock&lt;/A&gt;​'s solution and applied it to my application like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Modification to fsl_uart_driver.c in UART_DRV_IRQHandler:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="_jivemacro_uid_14470800767284401 jive_macro_code jive_text_macro" data-renderedposition="113_8_1232_496" jivemacro_uid="_14470800767284401" modifiedtitle="true"&gt;&lt;P&gt;bool detected_overrun = false;&lt;/P&gt;&lt;P&gt;if (UART_HAL_GetStatusFlag(base, kUartRxOverrun)) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Current test doesn't have this commented out, but it really should be because this function reads the D register.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //UART_HAL_ClearStatusFlag(base, kUartRxOverrun); // Clear the flag, OR the rxDataRegFull will not be set any more */&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; base-&amp;gt;CFIFO |= UART_CFIFO_RXFLUSH_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; base-&amp;gt;PFIFO &amp;amp;= ~UART_PFIFO_RXFE_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;uartState-&amp;gt;rxBuff[0] = base-&amp;gt;D;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; base-&amp;gt;PFIFO |= UART_PFIFO_RXFE_MASK;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;detected_overrun = true;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;if (UART_HAL_GetStatusFlag(base, kUartFrameErr)) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // TODO: I have verified framing errors, need to address after RX overrun&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; UART_HAL_ClearStatusFlag(base, kUartFrameErr);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;if (UART_HAL_GetStatusFlag(base, kUartNoiseDetect)) {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; UART_HAL_ClearStatusFlag(base, kUartNoiseDetect);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Get data and put into receive buffer */&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if( !detected_overrun) {&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; UART_HAL_Getchar(base, uartState-&amp;gt;rxBuff);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;}&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Invoke callback if there is one */&lt;/P&gt;&lt;P&gt;if (uartState-&amp;gt;rxCallback != NULL)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uartState-&amp;gt;rxCallback(instance, uartState);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;else...&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I understand correctly, the main idea here is to correctly detect the overrun condition, save the data in the RX buffer, then flush it out so that incoming bytes no longer get offset.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Nov 2015 14:38:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372447#M12310</guid>
      <dc:creator>dave408</dc:creator>
      <dc:date>2015-11-09T14:38:09Z</dc:date>
    </item>
    <item>
      <title>Re: UART FIFO appears empty even though it is not (K64 &amp; MQX 4.1)</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372448#M12311</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/tmeyer"&gt;tmeyer&lt;/A&gt;​ did you ever try your application at lower baud rates?&amp;nbsp; While I agree that hardware could be at the root of this UART problem, I don't understand why I get an RX overrun in the first place.&amp;nbsp; Although I have the FIFO disabled, I would still expect the K64F to be able to keep up with pulling a byte of data from the UART at 115200.&amp;nbsp; However, I've lowered my speed to 38400 and still get overrun errors.&amp;nbsp; The funny thing is that I have two other identical board configurations talking to identical slave devices at 115200, and neither of them exhibits these RX overrun problems.&amp;nbsp; So I'm just wondering if you've tried your test at lower speeds, as I have to wonder if there's also something else at play here.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 09 Nov 2015 17:29:19 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372448#M12311</guid>
      <dc:creator>dave408</dc:creator>
      <dc:date>2015-11-09T17:29:19Z</dc:date>
    </item>
    <item>
      <title>Re: UART FIFO appears empty even though it is not (K64 &amp; MQX 4.1)</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372449#M12312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hev dave408,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It has been a while since I dealt with this issue, but I think I was able to see it at both 9600 and 115200. What I don’t remember is what, other than handling a UART interrupt, the code busy doing. At 100MHz, the k64 should  be able to keep up to the 115200 baud. This works out to an incoming byte every 80us (roughly).. so as long as you have your system setup to allow the UART ISR to run (or polling loop) at least this frequent you should be okay!??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am not confident that this issue is caused by the overrun, perhaps when the issue occurs a overrun is signalled?! The reason I think this, is that I have in the past reproduced this issue on a 115200 command line shell by my slow typing. I suppose I cannot rule out that I may have copy/pasted a command into the shell.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry I couldn’t be more help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tim&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Nov 2015 21:02:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372449#M12312</guid>
      <dc:creator>tmeyer</dc:creator>
      <dc:date>2015-11-11T21:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: UART FIFO appears empty even though it is not (K64 &amp; MQX 4.1)</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372450#M12313</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Many thanks &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/dave408"&gt;dave408&lt;/A&gt;​ and &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/johannesschock"&gt;johannesschock&lt;/A&gt;​ for taking the time to post on this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We made the mistake of assuming the FIFOs on some of the K22 parts were 16C550 style and belatedly found they are only 2 bytes deep.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've been fighting weird NULLs coming out of the fsl_ drivers for some time now and your suggestions have enabled me to fix&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The only comment I'd make is that the (really helpful!) example snippet probably doesn't want to be calling the callback on an error path.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 12 Dec 2015 23:37:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372450#M12313</guid>
      <dc:creator>AlexJLennon</dc:creator>
      <dc:date>2015-12-12T23:37:45Z</dc:date>
    </item>
    <item>
      <title>Re: UART FIFO appears empty even though it is not (K64 &amp; MQX 4.1)</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372451#M12314</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I should probably have put the callback check into the if statement right before it...&amp;nbsp; thanks for catching that.&amp;nbsp; :smileyhappy:&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Dec 2015 14:01:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/UART-FIFO-appears-empty-even-though-it-is-not-K64-MQX-4-1/m-p/372451#M12314</guid>
      <dc:creator>dave408</dc:creator>
      <dc:date>2015-12-14T14:01:41Z</dc:date>
    </item>
  </channel>
</rss>

