<?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>Regarding reception of a frame using asynchronous serial interface</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/16586/regarding-reception-of-a-frame-using-asynchronous-serial-interface</link><description> Hello, 
 
I am using STMicroelectronics, ST10F269 evaluation board that works on Keil environment. I am trying establish communication between the board and the PC through RS232 serial interface. I am able to transmit a byte from board to PC and and</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Regarding reception of a frame using asynchronous serial interface</title><link>https://community.arm.com/thread/96207?ContentTypeID=1</link><pubDate>Tue, 23 Mar 2004 09:27:52 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:45561860-67bd-410b-9692-11e5cad65580</guid><dc:creator>John Donaldson</dc:creator><description>&lt;p&gt;GetChar() returns false if there are no characters available, so ReceiveFrame() will return after one character unless the entire frame has already been received by the serial ISR before ReceiveFrame() is called.&lt;br /&gt;
&lt;br /&gt;
Do you really need to use interrupt driven serial comms? The code you have posted looks as though it is intended to loop polling the receive buffer - that rather negates any benefit of using interrupts.&lt;br /&gt;
&lt;br /&gt;
Stefan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding reception of a frame using asynchronous serial interface</title><link>https://community.arm.com/thread/96208?ContentTypeID=1</link><pubDate>Tue, 23 Mar 2004 09:15:31 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c875d8d3-298f-40d2-8137-8d2d5f14a02c</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;i&gt;&amp;quot;Here is the code&amp;quot;&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Please re-post it, taking care to follow the instructions for posting code!&lt;br /&gt;
(3rd bullet point in the &amp;#39;Notes&amp;#39; - immediately above the &amp;#39;Message&amp;#39; box).&lt;br /&gt;
&lt;br /&gt;
Then your formatting will be preserved &amp;amp; we&amp;#39;ll be able to read it properly!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding reception of a frame using asynchronous serial interface</title><link>https://community.arm.com/thread/72379?ContentTypeID=1</link><pubDate>Tue, 23 Mar 2004 08:06:58 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c68b2006-a81a-4916-9324-52f6e47fa63d</guid><dc:creator>Naina K</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;
&lt;br /&gt;
Here is the code for the Thread 4227. Please give me the solution.&lt;br /&gt;
&lt;br /&gt;
/* Serial initialization */&lt;br /&gt;
&lt;br /&gt;
SerailInitialize()&lt;br /&gt;
{&lt;br /&gt;
P310 = 1;  //set PORT 3.10 output latch (TXD)&lt;br /&gt;
DP310 = 1;            /* set PORT 3.10 direction control (TXD output)  */&lt;br /&gt;
DP311 = 0;            /* reset PORT 3.11 direction control (RXD input)*/&lt;br /&gt;
&lt;br /&gt;
S0TIC = 0x0045;       /* transmit interrupt enable; ILVL = 1; GLVL = 1 ; S0TIE =1; S0TIR=0 */&lt;br /&gt;
&lt;br /&gt;
S0RIC = 0x0046;	/* receive  interrupt enable; ILVL = 1; GLVL = 2 ; S0RIE =1; S0RIR=0 */&lt;br /&gt;
S0BG = 0x0081;	/* Baud rate set to 9600 baud */&lt;br /&gt;
S0CON = 0x8011;	/* set serial mode */&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Code to be executed after receving frame*/&lt;br /&gt;
&lt;br /&gt;
if (ReceiveFrame())&lt;br /&gt;
{&lt;br /&gt;
    NetworkState = CmdComplete;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* State machine to be executed to send a vaid frame after receiving series of bytes from Display*/&lt;br /&gt;
&lt;br /&gt;
bit ReceiveFrame (void)&lt;br /&gt;
{&lt;br /&gt;
bit ValidFrame = FALSE;&lt;br /&gt;
char ReceivedByte;&lt;br /&gt;
bit bMsgComplete = FALSE;&lt;br /&gt;
&lt;br /&gt;
FrameReceiveStatus = WAIT_START;&lt;br /&gt;
while (GetChar(&amp;amp;ReceivedByte)&amp;amp;&amp;amp; !ValidFrame)&lt;br /&gt;
	{&lt;br /&gt;
	switch (FrameReceiveStatus)&lt;br /&gt;
       	{&lt;br /&gt;
	case WAIT_START:  //WAIT_START 1&lt;br /&gt;
      // waiting for the 0x55 start byte&lt;br /&gt;
&lt;br /&gt;
	if (ReceivedByte == 0x55)&lt;br /&gt;
        {&lt;br /&gt;
	Data[0] = ReceivedByte ;		FrameReceiveStatus = WAIT_ADDR;&lt;br /&gt;
	}&lt;br /&gt;
	break;&lt;br /&gt;
&lt;br /&gt;
      case WAIT_ADDR:  // waiting for  address byte&lt;br /&gt;
&lt;br /&gt;
        Data[1] = ReceivedByte;&lt;br /&gt;
        Addr = ReceivedByte;  			ValidFrame = TRUE;&lt;br /&gt;
        FrameReceiveStatus = WAIT_START;&lt;br /&gt;
        bMsgComplete = TRUE;&lt;br /&gt;
        break;&lt;br /&gt;
        }&lt;br /&gt;
       }&lt;br /&gt;
return (ValidFrame);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* GetChar function to fill a receive buffer with incoming bytes */&lt;br /&gt;
&lt;br /&gt;
bit GetChar( char *valptr )&lt;br /&gt;
{&lt;br /&gt;
bit rx_buf_filled =FALSE;&lt;br /&gt;
&lt;br /&gt;
if (rx_buf_rd_ptr != rx_buf_wr_ptr)&lt;br /&gt;
{&lt;br /&gt;
 *valptr = *rx_buf_rd_ptr;&lt;br /&gt;
 if (++rx_buf_rd_ptr &amp;gt;= &amp;amp;rx_buf[RX_BUF_SIZE])&lt;br /&gt;
 rx_buf_rd_ptr = rx_buf;&lt;br /&gt;
 rx_buf_filled =TRUE;&lt;br /&gt;
}&lt;br /&gt;
return( rx_buf_filled );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/* Receive interrupt service routine that writes incoming characters to the buffer */&lt;br /&gt;
&lt;br /&gt;
void serial_recv(void) interrupt 0x2B&lt;br /&gt;
{&lt;br /&gt;
*rx_buf_wr_ptr = (char)S0RBUF;&lt;br /&gt;
rx_buf_wr_ptr++;		//Locate write pointer to next location&lt;br /&gt;
&lt;br /&gt;
if(rx_buf_wr_ptr &amp;gt;= &amp;amp;rx_buf[RX_BUF_SIZE])   rx_buf_wr_ptr = rx_buf;&lt;br /&gt;
&lt;br /&gt;
}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding reception of a frame using asynchronous serial interface</title><link>https://community.arm.com/thread/110806?ContentTypeID=1</link><pubDate>Tue, 23 Mar 2004 08:06:40 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:275b30b1-d28f-410e-aade-348eb4cfbe4e</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;RTX166 shouldn&amp;#39;t be necessary for this - just look at the interrupt-driven ring-buffered serial I/O bit!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding reception of a frame using asynchronous serial interface</title><link>https://community.arm.com/thread/96215?ContentTypeID=1</link><pubDate>Tue, 23 Mar 2004 07:50:37 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:05c3953e-516c-4696-ba1a-3e12d50448f4</guid><dc:creator>Mik Kleshov</dc:creator><description>&lt;p&gt;Keil for C166 includes example program Traffic. It contains an implementation of interrupt-driven ring-buffered serial I/O using RTX166 Tiny.&lt;br /&gt;
&lt;br /&gt;
- mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding reception of a frame using asynchronous serial interface</title><link>https://community.arm.com/thread/86716?ContentTypeID=1</link><pubDate>Tue, 23 Mar 2004 07:46:33 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f9dacb10-1941-4614-b949-e5c0c1d02828</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;Oops - just noticed that it was a C166 question, not C51.&lt;br /&gt;
&lt;br /&gt;
Anyway, all this means is that the specifics of the interrupt-handling will be a little different; the ring-buffer principle remains exactly the same.&lt;br /&gt;
&lt;br /&gt;
I&amp;#39;m sure you can do your own search to see if there&amp;#39;s a ready-made example in the C166 downloads area...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding reception of a frame using asynchronous serial interface</title><link>https://community.arm.com/thread/41906?ContentTypeID=1</link><pubDate>Tue, 23 Mar 2004 07:43:53 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:19b3e8e7-e415-4a21-9f7b-d1ca6c5b4c9f</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;Have you looked at Keil interrupt-driven, ring-buffered serial IO example?&lt;br /&gt;
&lt;br /&gt;
I have used that very code to do several block-oriented&lt;br /&gt;
&lt;br /&gt;
protocols.&lt;a href="http://www.keil.com/download/docs71.asp"&gt;http://www.keil.com/download/docs/intsio.zip.asp&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
You could also try a Search on this forum for &amp;quot;Mark Odell&amp;quot; - as he has also posted an interrupt-driven, ring-buffered UART driver.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding reception of a frame using asynchronous serial interface</title><link>https://community.arm.com/thread/41900?ContentTypeID=1</link><pubDate>Tue, 23 Mar 2004 07:35:45 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:72c42630-ad6b-405a-aac6-3281409fa016</guid><dc:creator>John Donaldson</dc:creator><description>&lt;p&gt;&amp;quot;So the problem is when display sends a frame, board is able to receive only one byte, not the full frame. So could you please give me solution for this.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Probably not, unless you post the code that doesn&amp;#39;t work.&lt;br /&gt;
&lt;br /&gt;
Stefan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>