<?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のトピックLPCopen UART receiving more than 1 Byte</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPCopen-UART-receiving-more-than-1-Byte/m-p/587462#M21637</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Ano on Sun Oct 12 15:48:24 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi guys,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;currently I'm trying to receive more than 1 byte.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The first function I have works. It's pretty much the same, that is in the LPCopen example.&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
char UART_WaitForKeyAndReturnIt(void)
{
char key = 0;

// Wait for a key
while(key == 0)
{
Chip_UART_ReadRB(LPC_USART, &amp;amp;rxring, &amp;amp;key, 1);
}
return key;
}&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I try to read more than 1 key, say 4 for example, the Chip_UART_ReadRB function seems to get stuck.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This function should read 4 Bytes (so 4 ASCII signs) and calculate one 16bit value out of it. So that a user can&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;enter for example "1234", so ASCII sign 1, 2, 3 and 4, and value should then be 1234.&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;uint16_t UART_WaitForValueAndReturnIt(void)
{
uint16_t value = 0;
char key[4];
key[3] = 0;

// Wait for a key
while(key[3] == 0)//0 here is ASCII, so even if entered value is 0, it will be the ASCII sign '0' = 48
{
Chip_UART_ReadRB(LPC_USART, &amp;amp;rxring, &amp;amp;key, 4);
}

value = (key[3] - 48);
value = value + ((key[2] - 48) * 10);
value = value + ((key[1] - 48) * 100);
value = value + ((key[0] - 48) * 1000);

return value;
}&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there some fundamental error in my code that I am just too blind to see?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;/edit: Just found out: If I enter 8 values, not just 4, then it kind of works. But key[0] to key[3] won't have the first 4 values, but the last 4. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Example: I enter '12345678' then the key[] will contain: key[0]=4, key[1]=5, key[2]=6, key[3]=7.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//EDIT2: -----------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Apparently I found the mistake. It was not in this code, but in the terminal program I used. If I send 1234567, there is a delay between the 1, the 2 and the 3. Not between 4567. Don't know why, but this seems to be the problem, so only 4567 will be registered as the one message of 4 digits, the others before are registered as 3 messages with each 1 digit long. Used anther terminal programm without that "bug" and it works now...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 20:26:41 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T20:26:41Z</dc:date>
    <item>
      <title>LPCopen UART receiving more than 1 Byte</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPCopen-UART-receiving-more-than-1-Byte/m-p/587462#M21637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Ano on Sun Oct 12 15:48:24 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi guys,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;currently I'm trying to receive more than 1 byte.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The first function I have works. It's pretty much the same, that is in the LPCopen example.&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
char UART_WaitForKeyAndReturnIt(void)
{
char key = 0;

// Wait for a key
while(key == 0)
{
Chip_UART_ReadRB(LPC_USART, &amp;amp;rxring, &amp;amp;key, 1);
}
return key;
}&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I try to read more than 1 key, say 4 for example, the Chip_UART_ReadRB function seems to get stuck.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;This function should read 4 Bytes (so 4 ASCII signs) and calculate one 16bit value out of it. So that a user can&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;enter for example "1234", so ASCII sign 1, 2, 3 and 4, and value should then be 1234.&lt;/SPAN&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;uint16_t UART_WaitForValueAndReturnIt(void)
{
uint16_t value = 0;
char key[4];
key[3] = 0;

// Wait for a key
while(key[3] == 0)//0 here is ASCII, so even if entered value is 0, it will be the ASCII sign '0' = 48
{
Chip_UART_ReadRB(LPC_USART, &amp;amp;rxring, &amp;amp;key, 4);
}

value = (key[3] - 48);
value = value + ((key[2] - 48) * 10);
value = value + ((key[1] - 48) * 100);
value = value + ((key[0] - 48) * 1000);

return value;
}&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there some fundamental error in my code that I am just too blind to see?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;/edit: Just found out: If I enter 8 values, not just 4, then it kind of works. But key[0] to key[3] won't have the first 4 values, but the last 4. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Example: I enter '12345678' then the key[] will contain: key[0]=4, key[1]=5, key[2]=6, key[3]=7.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//EDIT2: -----------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Apparently I found the mistake. It was not in this code, but in the terminal program I used. If I send 1234567, there is a delay between the 1, the 2 and the 3. Not between 4567. Don't know why, but this seems to be the problem, so only 4567 will be registered as the one message of 4 digits, the others before are registered as 3 messages with each 1 digit long. Used anther terminal programm without that "bug" and it works now...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:26:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPCopen-UART-receiving-more-than-1-Byte/m-p/587462#M21637</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:26:41Z</dc:date>
    </item>
  </channel>
</rss>

