<?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: UART1 Tx issue with more than 16 bytes in LPCXpresso IDE</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/UART1-Tx-issue-with-more-than-16-bytes/m-p/562257#M16645</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Ex-Zero on Thu Mar 07 04:17:01 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: c0deland&lt;/STRONG&gt;&lt;BR /&gt;I tried to send with UART1Send(...)&amp;nbsp; but it always sends only 16 bytes.&lt;BR /&gt;Any ideeas how can I solve this?&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You are filling 16 byte FIFO without reading back its status &lt;SPAN class="lia-unicode-emoji" title=":winking_face:"&gt;&lt;LI-EMOJI id="lia_winking-face" title=":winking_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Easiest way to avoid this is wait until it's empty &lt;SPAN class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;&lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
// ***********************
// Function to send character over UART
void UART0_Sendchar(char c)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; while( ([COLOR=Red]LPC_UART0-&amp;gt;LSR &amp;amp; LSR_THRE) == 0 [/COLOR]);&amp;nbsp;&amp;nbsp;&amp;nbsp; // Block until tx empty
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_UART0-&amp;gt;THR = c;
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 23:39:34 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T23:39:34Z</dc:date>
    <item>
      <title>UART1 Tx issue with more than 16 bytes</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/UART1-Tx-issue-with-more-than-16-bytes/m-p/562256#M16644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by c0deland on Thu Mar 07 03:35:51 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello everybody.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I saw that this topic has been discussed in other threads but still, I couldn't find a solution for this problem. I'm using a LPC176x and I'm trying to send data (more than 16 bytes at once) over uart1. Unfortunately I cant get it work. I'm using an uart driver provided by nxp. Here is the code I'm using for init and send.&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;
Int32U UART1Init( void )
{
&amp;nbsp; PINSEL0_bit.P0_15 = 1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // TxD1
&amp;nbsp; PINSEL1_bit.P0_16 = 1;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // RxD1

&amp;nbsp; U1LCR = 0x83;&amp;nbsp;&amp;nbsp; // 8 bits, no Parity, 1 Stop bit 
&amp;nbsp; U1FDR_bit.DIVADDVAL = 3;
&amp;nbsp; U1FDR_bit.MULVAL = 4;
&amp;nbsp; U1DLM = 0;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Baudrate = 9600 bps
&amp;nbsp; U1DLL = 93;
&amp;nbsp; U1LCR = 0x03;&amp;nbsp;&amp;nbsp; // DLAB = 0 
&amp;nbsp; U1FCR_bit.RTLS = 2;&amp;nbsp;&amp;nbsp; // Trigger level 2 - 8 characters
&amp;nbsp; U1FCR |= 0x07;&amp;nbsp;&amp;nbsp; // Enable and reset TX and RX FIFO. 

&amp;nbsp; U1IER = IER_RBR | IER_RLS | IER_THRE; // Enable UART1 interrupt 

&amp;nbsp; NVIC_IntEnable(NVIC_UART1);

&amp;nbsp; return (TRUE);
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;SPAN&gt;and for send...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
void UART1Send(Int8U *BufferPtr, Int32U len)
{
&amp;nbsp; Int32U i;
&amp;nbsp; UART1RxCount = 0;
&amp;nbsp; for (i=0; i&amp;lt;len; i++)
&amp;nbsp;&amp;nbsp;&amp;nbsp; UART1TxBuffer&lt;I&gt; = BufferPtr&lt;I&gt;;
&amp;nbsp; UART1TxEmpty = 0;&amp;nbsp; 
&amp;nbsp; UART1TxLen = len;
&amp;nbsp; for (i=0; ((i&amp;lt;16) &amp;amp;&amp;amp; (i&amp;lt;len)); i++)
&amp;nbsp;&amp;nbsp;&amp;nbsp; U1THR = UART1TxBuffer&lt;I&gt;;
&amp;nbsp; UART1TxLeft = len-i;
&amp;nbsp; U1IER |= IER_THRE;&amp;nbsp; // Enable UART0 tx interrupt 
&amp;nbsp; while (UART1TxEmpty == 0);
&amp;nbsp; return;
}
&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;SPAN&gt;I tried to send with UART1Send(...)&amp;nbsp; but it always sends only 16 bytes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Any ideeas how can I solve this?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:39:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/UART1-Tx-issue-with-more-than-16-bytes/m-p/562256#M16644</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:39:33Z</dc:date>
    </item>
    <item>
      <title>Re: UART1 Tx issue with more than 16 bytes</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/UART1-Tx-issue-with-more-than-16-bytes/m-p/562257#M16645</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Ex-Zero on Thu Mar 07 04:17:01 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: c0deland&lt;/STRONG&gt;&lt;BR /&gt;I tried to send with UART1Send(...)&amp;nbsp; but it always sends only 16 bytes.&lt;BR /&gt;Any ideeas how can I solve this?&lt;BR /&gt;&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You are filling 16 byte FIFO without reading back its status &lt;SPAN class="lia-unicode-emoji" title=":winking_face:"&gt;&lt;LI-EMOJI id="lia_winking-face" title=":winking_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Easiest way to avoid this is wait until it's empty &lt;SPAN class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;&lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
// ***********************
// Function to send character over UART
void UART0_Sendchar(char c)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; while( ([COLOR=Red]LPC_UART0-&amp;gt;LSR &amp;amp; LSR_THRE) == 0 [/COLOR]);&amp;nbsp;&amp;nbsp;&amp;nbsp; // Block until tx empty
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_UART0-&amp;gt;THR = c;
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:39:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/UART1-Tx-issue-with-more-than-16-bytes/m-p/562257#M16645</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: UART1 Tx issue with more than 16 bytes</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/UART1-Tx-issue-with-more-than-16-bytes/m-p/562258#M16646</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by serge on Thu Mar 07 04:19:38 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;And what is the uart interrupt routine doing? :confused:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway I noticed that you are using UART1 and in your comments i see UART0&lt;/SPAN&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: &lt;/STRONG&gt;&lt;BR /&gt; U1IER |= IER_THRE;&amp;nbsp; // Enable UART[COLOR=red]0[/COLOR] tx interrupt &lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;:rolleyes: Probably a typo? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;And why are you always sending 16 bytes even if len is less? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;And why not using DMA?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:39:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/UART1-Tx-issue-with-more-than-16-bytes/m-p/562258#M16646</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:39:34Z</dc:date>
    </item>
    <item>
      <title>Re: UART1 Tx issue with more than 16 bytes</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/UART1-Tx-issue-with-more-than-16-bytes/m-p/562259#M16647</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by stalisman on Thu Mar 07 04:37:24 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;there is also the slight fact that he only ever sends 16 bytes before returning with len reduced by 16.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Theer is also the question of what happens if he sends only 5 bytes say,&amp;nbsp; what will Len be then?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:39:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/UART1-Tx-issue-with-more-than-16-bytes/m-p/562259#M16647</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: UART1 Tx issue with more than 16 bytes</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/UART1-Tx-issue-with-more-than-16-bytes/m-p/562260#M16648</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by serge on Thu Mar 07 05:26:14 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;My guess is that he will send 11 nonsense bytes...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:39:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/UART1-Tx-issue-with-more-than-16-bytes/m-p/562260#M16648</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: UART1 Tx issue with more than 16 bytes</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/UART1-Tx-issue-with-more-than-16-bytes/m-p/562261#M16649</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by c0deland on Thu Mar 07 09:03:45 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Based on the Sendchar example, I have modified the UART1Send function. Now I have:&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;
&amp;nbsp; int i=0;
&amp;nbsp; while(BufferPtr&lt;I&gt;!=0)
&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; U1THR = BufferPtr&lt;I&gt;;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; U1IER |= IER_THRE;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while ((U1LSR &amp;amp; LSR_THRE) == 0);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i++;
&amp;nbsp;&amp;nbsp; }
&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;SPAN&gt;Seems that it works. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 23:39:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/UART1-Tx-issue-with-more-than-16-bytes/m-p/562261#M16649</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T23:39:36Z</dc:date>
    </item>
  </channel>
</rss>

