<?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: fsl_usart.c: How to properly handle RX FIFO overflows, i.e., kStatus_USART_RxError</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/fsl-usart-c-How-to-properly-handle-RX-FIFO-overflows-i-e-kStatus/m-p/2296863#M59224</link>
    <description>&lt;P&gt;Hello &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/139806"&gt;@danielholala&lt;/a&gt;,&lt;BR /&gt;I understand that you have an issue with how to clear rxDataSize. From what I can see, the SDK (version 25.09) does not handle this automatically, but you can call the function USART_TransferAbortReceive inside the callback. This function clears the&amp;nbsp;rxDataSize, as shown in the following image:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Habib_MS_0-1768941580726.png" style="width: 579px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/373550i708D75AE9DD86ADA/image-dimensions/579x273?v=v2" width="579" height="273" role="button" title="Habib_MS_0-1768941580726.png" alt="Habib_MS_0-1768941580726.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;However, this function also aborts the current transfer, so you will need to resume the transmission manually.&lt;/P&gt;
&lt;P&gt;Lef me know if this helps you.&lt;BR /&gt;BR&lt;BR /&gt;Habib&lt;/P&gt;</description>
    <pubDate>Tue, 20 Jan 2026 20:40:33 GMT</pubDate>
    <dc:creator>Habib_MS</dc:creator>
    <dc:date>2026-01-20T20:40:33Z</dc:date>
    <item>
      <title>fsl_usart.c: How to properly handle RX FIFO overflows, i.e., kStatus_USART_RxError</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/fsl-usart-c-How-to-properly-handle-RX-FIFO-overflows-i-e-kStatus/m-p/2295145#M59181</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;on LPC5528/LPC5526/LPC55xx, I'm using the USART driver from the SDK, see&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/nxp-mcuxpresso/mcuxsdk-core/blob/main/drivers/flexcomm/usart/fsl_usart.c#L1123" target="_blank" rel="noopener"&gt;https://github.com/nxp-mcuxpresso/mcuxsdk-core/blob/main/drivers/flexcomm/usart/fsl_usart.c#L1123&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The code works properly when requesting to receive &lt;STRONG&gt;single bytes&amp;nbsp;&lt;/STRONG&gt;using&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="andale mono,times"&gt;&lt;SPAN&gt;USART_TransferReceiveNonBlocking()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;It also recovers on RX FIFO overflows by reinitiating reception.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Situation is different when using&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT face="andale mono,times"&gt;&lt;SPAN&gt;USART_TransferReceiveNonBlocking()&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;with&amp;nbsp;&lt;STRONG&gt;xfer-&amp;gt;dataSize&amp;nbsp; &amp;gt; 1&lt;/STRONG&gt;. For example, the receive callback inspects the RX FIFO level and if the RX FIFO level is &amp;gt; 1, it calls&amp;nbsp;&amp;nbsp;&lt;FONT face="andale mono,times"&gt;USART_TransferReceiveNonBlocking() &lt;/FONT&gt;&amp;nbsp;with the exact number of bytes of in the RX FIFO to retrieve these bytes more efficiently, say 10 bytes.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;However, if the system is busy handling other interrupts, the RX FIFO might overflow. Then&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;FONT face="andale mono,times"&gt;&lt;SPAN&gt;void&lt;/SPAN&gt; &lt;SPAN&gt;USART_TransferHandleIRQ&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;USART_Type&lt;/SPAN&gt;&lt;SPAN&gt; *base, &lt;/SPAN&gt;&lt;SPAN&gt;usart_handle_t&lt;/SPAN&gt;&lt;SPAN&gt; *handle)&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;clears the RX FIFO overflow bit, empties the FIFO and&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;calls the callback with&amp;nbsp;&lt;STRONG&gt;kStatus_USART_RxError&lt;/STRONG&gt;. All the bytes from the FIFO are therefore discarded and cannot be received any more.&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&lt;SPAN&gt;However, it does not reset&amp;nbsp;&lt;STRONG&gt;rxDataSize&lt;/STRONG&gt;. So the callback will not be called again until the number of bytes (in the example ten bytes) have been received. Until this, the receive mechanics hangs.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;How do you recover from this situation?&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Resetting the dataSize by calling &lt;FONT face="verdana,geneva"&gt;USART_TransferReceiveNonBlocking() &lt;/FONT&gt;&lt;FONT face="helvetica"&gt;with&lt;/FONT&gt; &lt;FONT face="verdana,geneva"&gt;xfer-&amp;gt;dataSize = 1&lt;/FONT&gt;&lt;/SPAN&gt;does not work as the receive mechanics is still in status&amp;nbsp;&lt;SPAN&gt;kUSART_RxBusy.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;So I wonder what is the proper way to handle RX FIFO overflows with the SDK drivers.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;PS: sorry for the strange text formatting. I tried to markup code so it is easier to read but&amp;nbsp;screwed up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jan 2026 15:46:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/fsl-usart-c-How-to-properly-handle-RX-FIFO-overflows-i-e-kStatus/m-p/2295145#M59181</guid>
      <dc:creator>danielholala</dc:creator>
      <dc:date>2026-01-16T15:46:02Z</dc:date>
    </item>
    <item>
      <title>Re: fsl_usart.c: How to properly handle RX FIFO overflows, i.e., kStatus_USART_RxError</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/fsl-usart-c-How-to-properly-handle-RX-FIFO-overflows-i-e-kStatus/m-p/2296863#M59224</link>
      <description>&lt;P&gt;Hello &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/139806"&gt;@danielholala&lt;/a&gt;,&lt;BR /&gt;I understand that you have an issue with how to clear rxDataSize. From what I can see, the SDK (version 25.09) does not handle this automatically, but you can call the function USART_TransferAbortReceive inside the callback. This function clears the&amp;nbsp;rxDataSize, as shown in the following image:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Habib_MS_0-1768941580726.png" style="width: 579px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/373550i708D75AE9DD86ADA/image-dimensions/579x273?v=v2" width="579" height="273" role="button" title="Habib_MS_0-1768941580726.png" alt="Habib_MS_0-1768941580726.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;However, this function also aborts the current transfer, so you will need to resume the transmission manually.&lt;/P&gt;
&lt;P&gt;Lef me know if this helps you.&lt;BR /&gt;BR&lt;BR /&gt;Habib&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jan 2026 20:40:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/fsl-usart-c-How-to-properly-handle-RX-FIFO-overflows-i-e-kStatus/m-p/2296863#M59224</guid>
      <dc:creator>Habib_MS</dc:creator>
      <dc:date>2026-01-20T20:40:33Z</dc:date>
    </item>
  </channel>
</rss>

