<?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>serial IO interrupt</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/15217/serial-io-interrupt</link><description> I am having a problem with getting a serial port interrupt. The timer 1 &amp;amp; serial port interrupts are being set to the high priority level. Timer1 is being used to create the 9600 baud for my serial IO. I can transmit out by writing to the SBUF register</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: serial IO interrupt</title><link>https://community.arm.com/thread/121809?ContentTypeID=1</link><pubDate>Fri, 04 Oct 2002 01:31:00 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:0be8b5d8-2f14-4e80-9830-2cab538de312</guid><dc:creator>Jon Ward</dc:creator><description>&lt;p&gt;In your original post...&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;TH1=0xfd;&lt;/pre&gt;
&lt;br /&gt;
Well, if you enable the timer 1 interrupt, you will be interrupted every time T1 overflows.  If you are using a divide-by-12 devices, that interrupt is going to happen every 3 instruction cycles.&lt;br /&gt;
&lt;br /&gt;
I doubt that your ISR can actually do anything useful in only 3 instruction cycles.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Jon&lt;/b&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: serial IO interrupt</title><link>https://community.arm.com/thread/85139?ContentTypeID=1</link><pubDate>Thu, 03 Oct 2002 20:32:02 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:0bc71704-f15b-4f7b-8b24-f1cdf497f551</guid><dc:creator>Robert Berkey</dc:creator><description>&lt;p&gt;Dave,&lt;br /&gt;
&lt;br /&gt;
&amp;gt; I measured the occurance of the timer interrupt to be 28.8KHz(every 35us). shouln&amp;#39;t it be closer to 300kHz&lt;br /&gt;
&lt;br /&gt;
Therefore the TF1 interrupt is occurring about 10 times faster than the ISR can process it and is always asserted.  High level code always gets one opcode processed before the next interrupt can interfere, so the high level code still is getting 1-3% of the processor time.  But look at the rules for resolution of simultaneous interrupts of equal priority.  For the 8051, the RI+TI is lower priority than TF1.  Thus, no RI+TI.  &lt;br /&gt;
&lt;br /&gt;
This is a theory to fit the facts, but I&amp;#39;ve never tested simultaneous interrupts.  Actually, I had previously thought that the &amp;quot;polling sequence&amp;quot; meant that each of the simultaneous interrupts would eventually get priority.  Now, I think not.&lt;br /&gt;
&lt;br /&gt;
Thanks,&lt;br /&gt;
Robert&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: serial IO interrupt</title><link>https://community.arm.com/thread/85138?ContentTypeID=1</link><pubDate>Wed, 02 Oct 2002 15:50:09 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:38eaba2c-a752-429f-b85e-656a03f08a2a</guid><dc:creator>Mark Odell</dc:creator><description>&lt;p&gt;&lt;i&gt;I am defining the ISR for timer1, I am using it to update a count variable used and reset elsewhere in main. Here are the ISRs, As you can see I am toggling a port pin in each.&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Very bad idea. I believe you are warned against doing this in the 8051 documenation. Use Timer 0 for timing when Timer 1 is used for BRG.&lt;br /&gt;
&lt;br /&gt;
Don&amp;#39;t disable interrupts inside an interrupt. It&amp;#39;s bad form. If you have a higher priority interrupt enabled either disable that single interrupt or make your UART ISR interrupt safe. You do not need to touch REN after it is set during some init function. This is a real mess, no offense. Good greif just look at my UART example on my web site. Start there and hack away until you get just what you need.&lt;br /&gt;
&lt;br /&gt;
When sharing read and write access to a variable between main loop and ISR code you must make it volatile, e.g. count should be a volatile var.&lt;br /&gt;
&lt;br /&gt;
Boy, those ISR&amp;#39;s sure look like they&amp;#39;re from IAR not Keil.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: serial IO interrupt</title><link>https://community.arm.com/thread/84324?ContentTypeID=1</link><pubDate>Wed, 02 Oct 2002 15:29:59 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:82e8c53f-6f18-47a8-bb82-77cb35444f0c</guid><dc:creator>Dave dufresne</dc:creator><description>&lt;p&gt;I am defining the ISR for timer1, I am using it to update a count variable used and reset elsewhere in main. Here are the ISRs, As you can see I am toggling a port pin in each. &lt;br /&gt;
//ISRs&lt;br /&gt;
void interrupt [0x23] void RITI_int (void)&lt;br /&gt;
{&lt;br /&gt;
P2.0=0;&lt;br /&gt;
P2.0=1;&lt;br /&gt;
EA=0;&lt;br /&gt;
  if (TI != 0)&lt;br /&gt;
	{&lt;br /&gt;
	TI=0;					//clear transmit interrupt bit&lt;br /&gt;
  	REN=1;					//reenable reciever ??auto disabled during Transmit interrupt&lt;br /&gt;
	}&lt;br /&gt;
  	&lt;br /&gt;
 if (RI != 0)&lt;br /&gt;
   {&lt;br /&gt;
      // read in the byte &amp;amp; put the data in the buffer. &lt;br /&gt;
      incoming_msg_buffer[incoming_hdr_ptr++] = SBUF;&lt;br /&gt;
&lt;br /&gt;
      if (incoming_hdr_ptr &amp;gt;= RXBUFFER_SIZE)&lt;br /&gt;
        incoming_hdr_ptr = 0;&lt;br /&gt;
     rx_empty=FALSE;&lt;br /&gt;
      // renable rx interrupt &lt;br /&gt;
      RI = 0;&lt;br /&gt;
    }&lt;br /&gt;
 EA=1;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
interrupt [0x1B] void TF1_int (void)		&lt;br /&gt;
{&lt;br /&gt;
EA=0;&lt;br /&gt;
P2.2=0;&lt;br /&gt;
P2.2=1;&lt;br /&gt;
count++;&lt;br /&gt;
EA=1;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
correct me if I am wrong, the timer overflow bit is reset automaticly when entering the timer ISR. When I transmit data is is going out at the 9600 baud that I intended, but I  measured the occurance of the timer interrupt to be 28.8KHz(every 35us). shouln&amp;#39;t it be closer to 300kHz.&lt;br /&gt;
Since the UART ISR insn&amp;#39;t being initiated, I have the following routine for sending out a message: &lt;br /&gt;
for (i=0;i&amp;lt;=tx_length;i++)&lt;br /&gt;
		{&lt;br /&gt;
		SBUF=message[i];&lt;br /&gt;
		while(TI!=1);	//wait for end of transmission ??to be implemented in ISR&lt;br /&gt;
		TI=0;&lt;br /&gt;
		}&lt;br /&gt;
I would expect that the ISR would be called after the write to SBUF, but it never gets there, so I wait until TI goes HI.&lt;br /&gt;
Mark, I do have ES and EA enabled, however I do set EA low while in the ISR and set back HI when finished.&lt;br /&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: serial IO interrupt</title><link>https://community.arm.com/thread/54696?ContentTypeID=1</link><pubDate>Wed, 02 Oct 2002 14:18:18 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:56131945-0e9e-48a5-9c64-0503c4681f39</guid><dc:creator>Mark Odell</dc:creator><description>&lt;p&gt;Not only is the Timer1 interrupt not needed it would waste huge amounts of CPU time if enabled when generating baud. This assumes you&amp;#39;ve got some default handler at the T1 interrupt vector to return back to your main line code too. Without that you&amp;#39;re off in never never land.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: serial IO interrupt</title><link>https://community.arm.com/thread/39215?ContentTypeID=1</link><pubDate>Wed, 02 Oct 2002 14:14:18 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8003f834-876d-41ec-8482-40b4d961129c</guid><dc:creator>Dan Henry</dc:creator><description>&lt;p&gt;You are using Timer1 as both a baud rate generator and a periodic interrupt source?  Could we get a look at the timer ISR too?  Have you tried running without the Timer1 interrupt enabled (its interrupt capability isn&amp;#39;t needed if you are running it for BRG only)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: serial IO interrupt</title><link>https://community.arm.com/thread/84323?ContentTypeID=1</link><pubDate>Wed, 02 Oct 2002 13:57:34 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:b2ffa527-36e6-4422-bfea-ced46b4eab21</guid><dc:creator>Mark Odell</dc:creator><description>&lt;p&gt;I&amp;#39;ve only seen non-response to enabled interrupts when some ISR is returned from via a simple RET instead of an IRET. If you&amp;#39;re workning in C only this is probably not the case. Are you sure both IE.EA and IE.ES are set?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: serial IO interrupt</title><link>https://community.arm.com/thread/54703?ContentTypeID=1</link><pubDate>Wed, 02 Oct 2002 13:54:19 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:97601e94-89fc-4fde-aed0-6509af8b2f82</guid><dc:creator>Dave dufresne</dc:creator><description>&lt;p&gt;I believe I am doing something similar to the example, except my rxbuffer is setup to hold only 24 bytes and is overwritten on subsequent messages. my SFRs are setup similar: timer1 in mode2 set for 9600 baud rate, SCON in mode 1. The ISR apparently never starts even though my TI &amp;amp; RI bits are being set automatically. &lt;br /&gt;
&lt;br /&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: serial IO interrupt</title><link>https://community.arm.com/thread/54695?ContentTypeID=1</link><pubDate>Wed, 02 Oct 2002 10:53:20 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:05c01ed5-f435-4e4e-a519-5d9f8e673c68</guid><dc:creator>Mark Odell</dc:creator><description>&lt;p&gt;See also:&lt;br /&gt;
&lt;br /&gt;
http:/&lt;a href="http://www.embeddedfw.com" target="_blank"&gt;http://www.embeddedfw.com&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Free production quality UART driver at bottom of page.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: serial IO interrupt</title><link>https://community.arm.com/thread/39217?ContentTypeID=1</link><pubDate>Tue, 01 Oct 2002 18:01:10 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:85c5d3df-70e8-40d1-81b6-8aba9055aea8</guid><dc:creator>Jon Ward</dc:creator><description>&lt;p&gt;Why not compare your code to the interrupt-driven serial I/O code that&amp;#39;s already available?&lt;br /&gt;
&lt;br /&gt;
&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;
&lt;b&gt;Jon&lt;/b&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>