<?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>How to process the data from UART?</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/17715/how-to-process-the-data-from-uart</link><description> Hi all . 
In one way ,all the messages is following a standard format ,like:&amp;quot;SOH,MSG ID, CMPL ID,MSG DATA LENGTH, MSG DATA ,CHECKSUM&amp;quot;,so this format can be embed in UART_ISR to receive the message wanted.But,if have some different kinds of message which</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: How to process the data from UART?</title><link>https://community.arm.com/thread/138013?ContentTypeID=1</link><pubDate>Sun, 27 Mar 2005 00:49:05 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:d2d6892c-c8d5-4c0e-982a-beb755418553</guid><dc:creator>Nantian Gumo</dc:creator><description>&lt;p&gt;I rewrite the source code as following:&lt;br /&gt;
&lt;pre&gt;
//Serial ISR:
void serial0(void) interrupt 4
{
    ES0 = 0;
    if (TI0) TI0 =0;
    if (RI0)
    {
        r_buf[r_in&amp;0x7ff]=SBUF0;
        RI0 = 0;
        r_in=r_in+1;
    }
    ES0 = 1;
}
//Main_Loop:
void main()
{
...
while(1)
{
    if ((r_in-r_out)&amp;gt;128)
    {
        serial0Flag = 1;
    }
    if(serial0Flag==1)
    {
        if (r_buf[r_out&amp;0x7ff] ==&amp;#39;$&amp;#39;)
        {
            memcpy(sHeadFlag,&amp;amp;r_buf[(r_out+1)&amp;0x7ff],5);
            if (memcmp(sHeadFlag,sGpgs[0],5)==0)
            {
                GpgsvSol(&amp;amp;r_buf[r_out&amp;0x7ff]);
            }
            if (memcmp(sHeadFlag,sGpgs[1],5)==0)
            {
                GpgsaSol(&amp;amp;r_buf[r_out&amp;0x7ff]);
                atelliteLocked=Gpgsa.cSatInSolTol;
            }
         }
     r_out++;
     }
}
}
&lt;/pre&gt;
&lt;br /&gt;
How can i correct it well?&lt;br /&gt;
Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to process the data from UART?</title><link>https://community.arm.com/thread/134528?ContentTypeID=1</link><pubDate>Sat, 26 Mar 2005 13:46:03 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ac38466b-9801-4900-bcc8-af9bf330502a</guid><dc:creator>Karl Hamsher</dc:creator><description>&lt;p&gt;Once serial0Flag has been set to 1, your main loop will scan r_buf[] continuously without any synchronization to the incoming data and without checking whether it&amp;#39;s looking at old data after wrapping.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to process the data from UART?</title><link>https://community.arm.com/thread/148736?ContentTypeID=1</link><pubDate>Sat, 26 Mar 2005 01:55:05 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:37e6b4b2-736c-46bc-8c57-343c0e9ac778</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;Your code is illegible because it&amp;#39;s lost all its latout/formatting.&lt;br /&gt;
This is because you didn&amp;#39;t follow the instruction about posting code.&lt;br /&gt;
&lt;br /&gt;
Please follow the instructions on how to post code - it&amp;#39;s right there immediately above the box where you type your message!&lt;br /&gt;
&lt;a href="http://www.keil.com/forum/tips.asp"&gt;http://www.keil.com/forum/tips.asp&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to process the data from UART?</title><link>https://community.arm.com/thread/122732?ContentTypeID=1</link><pubDate>Sat, 26 Mar 2005 01:28:41 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ca2f8879-a083-4d29-b62c-5752c2124fd0</guid><dc:creator>Nantian Gumo</dc:creator><description>&lt;p&gt;Hi all,&lt;br /&gt;
when the main_loop&amp;#39;s code shown as following  is running ,lots of messages in buffer couldn&amp;#39;t be detected and lost.can you tell me how to correct it?&lt;br /&gt;
&lt;br /&gt;
Serial ISR:&lt;br /&gt;
void serial0(void) interrupt 4&lt;br /&gt;
{&lt;br /&gt;
ES0 = 0;&lt;br /&gt;
if (TI0) TI0 =0;&lt;br /&gt;
if (RI0)&lt;br /&gt;
	{&lt;br /&gt;
	r_buf[r_in&amp;0x7ff]=SBUF0;&lt;br /&gt;
	RI0 = 0;&lt;br /&gt;
	r_in=r_in+1;&lt;br /&gt;
	}&lt;br /&gt;
ES0 = 1;&lt;br /&gt;
}&lt;br /&gt;
Main_Loop:&lt;br /&gt;
void main()&lt;br /&gt;
{&lt;br /&gt;
...&lt;br /&gt;
while(1)&lt;br /&gt;
{&lt;br /&gt;
if ((r_in-r_out)&amp;gt;128)&lt;br /&gt;
{&lt;br /&gt;
      serial0Flag = 1;&lt;br /&gt;
}&lt;br /&gt;
if(serial0Flag==1)&lt;br /&gt;
{&lt;br /&gt;
      if (r_buf[r_out&amp;0x7ff] ==&amp;#39;$&amp;#39;)&lt;br /&gt;
	{&lt;br /&gt;
	       memcpy(sHeadFlag,&amp;amp;r_buf[(r_out+1)&amp;0x7ff],5);&lt;br /&gt;
	      if (memcmp(sHeadFlag,sGpgs[0],5)==0)&lt;br /&gt;
	      {&lt;br /&gt;
	           GpgsvSol(&amp;amp;r_buf[r_out&amp;0x7ff]);&lt;br /&gt;
	       }&lt;br /&gt;
	       if (memcmp(sHeadFlag,sGpgs[1],5)==0)&lt;br /&gt;
	       {&lt;br /&gt;
	            GpgsaSol(&amp;amp;r_buf[r_out&amp;0x7ff]);&lt;br /&gt;
	            atelliteLocked=Gpgsa.cSatInSolTol;&lt;br /&gt;
	       }&lt;br /&gt;
	   }&lt;br /&gt;
	   r_out++;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to process the data from UART?</title><link>https://community.arm.com/thread/111360?ContentTypeID=1</link><pubDate>Thu, 24 Mar 2005 09:02:58 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:2a08e072-724c-438a-b10e-1122ab7846f0</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;Click &amp;#39;Support&amp;#39; in the blue bar across the top of this screen&lt;br /&gt;
&lt;br /&gt;
Click &amp;#39;Download Files&amp;#39;&lt;br /&gt;
&lt;br /&gt;
Click &amp;#39;C51 Downloas Files&amp;#39;&lt;br /&gt;
&lt;br /&gt;
Look for &amp;quot;Interrupt-Driven Serial I/O&amp;quot;&lt;br /&gt;
(Hint: use your browser&amp;#39;s &amp;#39;Search&amp;#39; facility)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to process the data from UART?</title><link>https://community.arm.com/thread/97017?ContentTypeID=1</link><pubDate>Thu, 24 Mar 2005 08:43:16 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f0c6cc22-b679-4d33-bbe1-eb9c745848df</guid><dc:creator>Nantian Gumo</dc:creator><description>&lt;p&gt;I have tried my best ,but couldn&amp;#39;t find the  code example what you said.Can you tell me which site they are?&lt;br /&gt;
Thanks a lot!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to process the data from UART?</title><link>https://community.arm.com/thread/87142?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2005 07:31:35 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:1a079cb2-5cfd-4662-bcaf-655a527e49f0</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;All the ISR can usefully do is receive the data, a byte at a time, and push it into a circular buffer of adequate size. The main code will pull it out of that, and do whatever needs being done.&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Absolutely.&lt;br /&gt;
Look at the interrupt-driven serial IO sample code on this very site.&lt;br /&gt;
&lt;br /&gt;
I&amp;#39;ve used it almost straight from the can to do exactly the kind of thing you&amp;#39;re talking about.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to process the data from UART?</title><link>https://community.arm.com/thread/50332?ContentTypeID=1</link><pubDate>Mon, 21 Mar 2005 07:21:35 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a92950c3-6a40-4b60-ad50-132b5defbf76</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;It&amp;#39;s quite certainly not a good idea to do any processing like the one you&amp;#39;re talking about inside the ISR.  Let the main code deal with it.  All the ISR can usefully do is receive the data, a byte at a time, and push it into a circular buffer of adequate size.  The main code will pull it out of that, and do whatever needs being done.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>