<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Wrong data on UART2</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/34880/wrong-data-on-uart2</link><description> 
Hi, 

 
I have an STTM32F103C8 MCU (&amp;quot;Blue pill&amp;quot;) board. What I write to
UART1 goes well to he PC. But if I try send data over UART2 only some
of the sent characers appear on the PC. 

 
You can see he code below. Is there anyone who knows, what is
wrong</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Wrong data on UART2</title><link>https://community.arm.com/thread/109026?ContentTypeID=1</link><pubDate>Tue, 17 Jan 2017 22:59:14 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:40e61fa0-f5f7-4262-92b6-5b121817980a</guid><dc:creator>Csaba Katona</dc:creator><description>&lt;p&gt;&lt;p&gt;
OK, now I see...&lt;br /&gt;
Excuse me for my recklessness, and thank you very much for your
paient and help!&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wrong data on UART2</title><link>https://community.arm.com/thread/109018?ContentTypeID=1</link><pubDate>Tue, 17 Jan 2017 13:12:47 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a2b07bd4-5c70-4950-be03-ec5c843f20f0</guid><dc:creator>edPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;quot;Is there anyone who knows why works the USART1 without
delay?&amp;quot;&lt;/p&gt;

&lt;p&gt;
Most definitely.&lt;/p&gt;

&lt;p&gt;
And you have been told in this thread exactly why it works for
USART1 and not for USART2.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wrong data on UART2</title><link>https://community.arm.com/thread/93880?ContentTypeID=1</link><pubDate>Tue, 17 Jan 2017 08:19:42 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b00529ae-d009-4961-b994-c43c3e4e7778</guid><dc:creator>Clive Unspecified</dc:creator><description>&lt;p&gt;&lt;p&gt;
Repeat very slowly to yourself USARTx not USART1 while looking at
this code, keep doing so until you see the issue.&lt;/p&gt;

&lt;pre&gt;
void USART_Send_Char(USART_TypeDef* USARTx, char cData)
{
    while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
    USART_SendData(USARTx, cData);
}

void USART_Send_CharArray(USART_TypeDef* USARTx, char Buffer[]) {
        int i=0;
        while (Buffer[i]) {
                while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
                USART_SendData(USARTx,Buffer[i++]);
        }
}
&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wrong data on UART2</title><link>https://community.arm.com/thread/65265?ContentTypeID=1</link><pubDate>Tue, 17 Jan 2017 06:55:34 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3a0b4da4-48dd-45b6-a507-31142ff9e85f</guid><dc:creator>Csaba Katona</dc:creator><description>&lt;p&gt;&lt;p&gt;
If I insert a 50 usec delay after USART_SendData then each
character get to the PC.&lt;br /&gt;
Is there anyone who knows why works the USART1 without delay?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wrong data on UART2</title><link>https://community.arm.com/thread/120965?ContentTypeID=1</link><pubDate>Tue, 17 Jan 2017 03:23:46 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:afdc8e6d-a2df-484b-b0cc-66862628bfc1</guid><dc:creator>Csaba Katona</dc:creator><description>&lt;p&gt;&lt;p&gt;
I can&amp;#39;t really understand: here I send data and check the port,
don&amp;#39;t I?&lt;/p&gt;

&lt;pre&gt;
//send data to USART1
USART_Send_CharArray(USART1,RXBUFF);
//test for USART1
while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);

//send to USART2
USART_Send_CharArray(USART2,RXBUFF);
//test for USART2
while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET);
&lt;/pre&gt;

&lt;p&gt;
Or which code is broken? Can you explain a bit?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wrong data on UART2</title><link>https://community.arm.com/thread/109025?ContentTypeID=1</link><pubDate>Tue, 17 Jan 2017 00:26:45 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:017ced0f-f63b-4af3-b32b-2dc64bd94bef</guid><dc:creator>edPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Your code is broken. You send to two uart but only test the flags
for one uart.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wrong data on UART2</title><link>https://community.arm.com/thread/83486?ContentTypeID=1</link><pubDate>Tue, 17 Jan 2017 00:03:34 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:18329987-b84e-4128-adcb-ea14a222f5a8</guid><dc:creator>Csaba Katona</dc:creator><description>&lt;p&gt;&lt;p&gt;
I inserted the lines you suggested like this:&lt;/p&gt;

&lt;pre&gt;
USART_Send_CharArray(USART1,RXBUFF);
while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);
USART_Send_CharArray(USART2,RXBUFF);
while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET);
&lt;/pre&gt;

&lt;p&gt;
but there was no change&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wrong data on UART2</title><link>https://community.arm.com/thread/83488?ContentTypeID=1</link><pubDate>Mon, 16 Jan 2017 22:57:18 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ab8f9db7-bc29-4bd0-abc4-91f347208137</guid><dc:creator>Csaba Katona</dc:creator><description>&lt;p&gt;&lt;p&gt;
You are right. So if I try to send these characters:&lt;/p&gt;

&lt;p&gt;
abcdefghijkl&lt;/p&gt;

&lt;p&gt;
only some of the characters get to the PC like&lt;br /&gt;
abdegi&lt;br /&gt;
or&lt;br /&gt;
acdfgi&lt;/p&gt;

&lt;p&gt;
So the exact phrase to this phenomena is missing data, I
think.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wrong data on UART2</title><link>https://community.arm.com/thread/65253?ContentTypeID=1</link><pubDate>Mon, 16 Jan 2017 10:12:18 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b5988dcc-cf5d-4cf9-9b4c-01c6beeed136</guid><dc:creator>Clive Unspecified</dc:creator><description>&lt;p&gt;&lt;p&gt;
Wait on USARTx not USART1 then...&lt;br /&gt;
while(USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET);&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wrong data on UART2</title><link>https://community.arm.com/thread/69761?ContentTypeID=1</link><pubDate>Mon, 16 Jan 2017 08:36:23 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b4730b93-ee0e-45d0-a7e6-5968eddba9fe</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
Your title says, &lt;i&gt;&amp;quot;&lt;b&gt;Wrong&lt;/b&gt; data on UART2&amp;quot;&lt;/i&gt;;&lt;/p&gt;

&lt;p&gt;
But your description says, &lt;i&gt;&amp;quot;only some of the sent characters
appear on the PC&amp;quot;&lt;/i&gt;.&lt;/p&gt;

&lt;p&gt;
So please clarify: is the problem that characters are corrupted
(&amp;quot;wrong&amp;quot;) or that they are missing?&lt;br /&gt;
Or what?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>