<?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: lpc55s16 USART data read related issue in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/lpc55s16-USART-data-read-related-issue/m-p/2040779#M57658</link>
    <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/75589"&gt;@firmwareteam&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May I ask if updating the code has resolved your issue?&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Harry&lt;/P&gt;</description>
    <pubDate>Mon, 10 Feb 2025 09:12:55 GMT</pubDate>
    <dc:creator>Harry_Zhang</dc:creator>
    <dc:date>2025-02-10T09:12:55Z</dc:date>
    <item>
      <title>lpc55s16 USART data read related issue</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/lpc55s16-USART-data-read-related-issue/m-p/2037094#M57613</link>
      <description>&lt;P&gt;&lt;SPAN&gt;i am using lpc55s16 usart interrupt sample code .lpc55s16 next side another device&amp;nbsp; transmit data in this code i can read 32 bytes and same time another 32 bytes data read 9times loop ran then full completed 258 byte data correct and i want to read more than 258 bytes read but at&amp;nbsp;singles times loop.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;attach&amp;nbsp;screenshot(83) read data 32 byte and 9loop full completed .&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;data in 1 singel loop 258 byte data read?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;screenshot singels 32 bytes data read ss&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;how to change in usart code.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;usart data read function.&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;bool usart_Read(uint8_t* b) {&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; if ((kUSART_RxFifoNotEmptyFlag&amp;nbsp; ) &amp;amp; USART_GetStatusFlags(USART1))&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *b = USART_ReadByte(USART1);&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return true;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp;else&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;{&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; return false;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/DIV&gt;&lt;DIV&gt;}&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;9times loop ran then full completed 258 byte data.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;case STEP_READ_LEN: /* Read length byte */&lt;/DIV&gt;&lt;DIV&gt;case STEP_READ_LEN:&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;if (usart_Read(&amp;amp;re-&amp;gt;len)) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;return STEP_READ_DATA;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;}&lt;/DIV&gt;&lt;DIV&gt;break;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;case STEP_READ_DATA:&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;if (re-&amp;gt;pos &amp;lt; re-&amp;gt;len) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;if (usart_Read(&amp;amp;(re-&amp;gt;data[re-&amp;gt;pos]))) {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;re-&amp;gt;pos++;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;}&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 03 Feb 2025 08:32:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/lpc55s16-USART-data-read-related-issue/m-p/2037094#M57613</guid>
      <dc:creator>firmwareteam</dc:creator>
      <dc:date>2025-02-03T08:32:43Z</dc:date>
    </item>
    <item>
      <title>Re: lpc55s16 USART data read related issue</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/lpc55s16-USART-data-read-related-issue/m-p/2038441#M57631</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/75589"&gt;@firmwareteam&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to&amp;nbsp;read 258 bytes in a single loop iteration instead of 9 iterations of 32 bytes each, you need to modify your USART interrupt handling.&lt;/P&gt;
&lt;P&gt;You can change the&amp;nbsp;usart_Read.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;int usart_Read(uint8_t* buf, int max_len) {
   int bytesRead = 0;
   while ((kUSART_RxFifoNotEmptyFlag) &amp;amp; USART_GetStatusFlags(USART1)) {
       if (bytesRead &amp;lt; max_len) {
           buf[bytesRead] = USART_ReadByte(USART1);
           bytesRead++;
       } else {
           break; // Stop reading if buffer is full
       }
   }
   return bytesRead; // Return the number of bytes read
}&lt;/LI-CODE&gt;
&lt;P&gt;And you can update the&amp;nbsp;STEP_READ_DATA case&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;case STEP_READ_DATA:
   if (re-&amp;gt;pos &amp;lt; re-&amp;gt;len) {
       int bytesReceived = usart_Read(&amp;amp;(re-&amp;gt;data[re-&amp;gt;pos]), re-&amp;gt;len - re-&amp;gt;pos);
       re-&amp;gt;pos += bytesReceived;
       // If all 258 bytes are received in one loop, exit
       if (re-&amp;gt;pos &amp;gt;= re-&amp;gt;len) {
           return STEP_PROCESS_DATA;  // Proceed to process data
       }
   }
   break;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Harry&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 09:06:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/lpc55s16-USART-data-read-related-issue/m-p/2038441#M57631</guid>
      <dc:creator>Harry_Zhang</dc:creator>
      <dc:date>2025-02-05T09:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: lpc55s16 USART data read related issue</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/lpc55s16-USART-data-read-related-issue/m-p/2038574#M57634</link>
      <description>&lt;P&gt;Hiii&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;update the&amp;nbsp;STEP_READ_DATA case and&amp;nbsp;change the&amp;nbsp;usart_Read function.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;same problem read data not change,32 bytes data read 9times loop ran then full completed 258 byte data.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 11:24:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/lpc55s16-USART-data-read-related-issue/m-p/2038574#M57634</guid>
      <dc:creator>firmwareteam</dc:creator>
      <dc:date>2025-02-05T11:24:41Z</dc:date>
    </item>
    <item>
      <title>Re: lpc55s16 USART data read related issue</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/lpc55s16-USART-data-read-related-issue/m-p/2040779#M57658</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/75589"&gt;@firmwareteam&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May I ask if updating the code has resolved your issue?&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Harry&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2025 09:12:55 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/lpc55s16-USART-data-read-related-issue/m-p/2040779#M57658</guid>
      <dc:creator>Harry_Zhang</dc:creator>
      <dc:date>2025-02-10T09:12:55Z</dc:date>
    </item>
    <item>
      <title>Re: lpc55s16 USART data read related issue</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/lpc55s16-USART-data-read-related-issue/m-p/2040856#M57659</link>
      <description>&lt;P&gt;hii&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;updating the code not resolved issue.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;same problem.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;problem ask to second rplay.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2025 10:42:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/lpc55s16-USART-data-read-related-issue/m-p/2040856#M57659</guid>
      <dc:creator>firmwareteam</dc:creator>
      <dc:date>2025-02-10T10:42:15Z</dc:date>
    </item>
    <item>
      <title>Re: lpc55s16 USART data read related issue</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/lpc55s16-USART-data-read-related-issue/m-p/2042514#M57669</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/75589"&gt;@firmwareteam&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN data-teams="true"&gt;To read more than 258 bytes in a single loop,&amp;nbsp;I rewrote the relevant code.&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;#define DEMO_BUFFER_SIZE          512  
#define DATA_TO_RECEIVE           258  
.....
uint8_t rxBuffer[DEMO_BUFFER_SIZE];
volatile uint16_t rxCount = 0;
volatile bool dataReceived = false;

void DEMO_USART_IRQHandler(void)
{
   uint8_t data;
   if ((kUSART_RxFifoNotEmptyFlag | kUSART_RxError) &amp;amp; USART_GetStatusFlags(DEMO_USART))
   {
       data = USART_ReadByte(DEMO_USART);
       if (rxCount &amp;lt; DATA_TO_RECEIVE) // Store only up to the required amount
       {
           rxBuffer[rxCount++] = data;
           if (rxCount &amp;gt;= DATA_TO_RECEIVE)
           {
               dataReceived = true;  // Signal that required data has been received
           }
       }
   }

   SDK_ISR_EXIT_BARRIER;
}

.....

int main(void)
{

....

   while (1)
   {
       if (dataReceived)
       {
           /* Process received data */
           USART_WriteBlocking(DEMO_USART, rxBuffer, rxCount);  // Echo received data
           rxCount = 0;  // Reset counter
           dataReceived = false;  // Reset flag
       }
   }
}  &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Harry&lt;/P&gt;</description>
      <pubDate>Wed, 12 Feb 2025 09:54:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/lpc55s16-USART-data-read-related-issue/m-p/2042514#M57669</guid>
      <dc:creator>Harry_Zhang</dc:creator>
      <dc:date>2025-02-12T09:54:53Z</dc:date>
    </item>
  </channel>
</rss>

