<?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>Nested interrupt</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/38006/nested-interrupt</link><description> 
Hi 

 
Im using a timer to generate interrupt based on the match
registers. On one of those interrupt, I would like to start a SPI
data transfer. The SPI transfer is also using vector based interrupt
(for sending 3 bytes). 
But (of cause) the SPI interrupt</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Nested interrupt</title><link>https://community.arm.com/thread/124943?ContentTypeID=1</link><pubDate>Mon, 29 Sep 2008 07:50:08 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5ef96371-d56d-4a28-98fe-c0d476778e2e</guid><dc:creator>Thomas Johansen</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hi&lt;/p&gt;

&lt;p&gt;
I did just that. I just start the SPI transfere in my timer
interrupt. Then when SPI isr is saving the result for future use
:-)&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nested interrupt</title><link>https://community.arm.com/thread/114289?ContentTypeID=1</link><pubDate>Fri, 26 Sep 2008 02:10:00 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:e3fe0e49-07f5-47b9-82b9-597a256825b5</guid><dc:creator>edPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
If you are going to busy-wait for the SPI transfer, then you
should not run the SPI interface with interrupts.&lt;/p&gt;

&lt;p&gt;
Instead, you should select the fastest working baudrate and then
poll for your results. Interrupts are used when you do not want to
poll. If you are going to poll anyway, then it is more efficient to
just poll instead of having an interrupt receive the data and other
code busy-waiting for the interrupt to report that the transfer is
done.&lt;/p&gt;

&lt;p&gt;
But the question is: Why do one interrupt handler need to send a
number of bytes and then hang, waiting for the result? Why can&amp;#39;t the
results be stored by the SPI interrupt into a receive buffer and then
consumed by a main loop?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nested interrupt</title><link>https://community.arm.com/thread/101124?ContentTypeID=1</link><pubDate>Fri, 26 Sep 2008 01:50:47 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f7520e22-7c49-4ae2-9046-6c6962a7306f</guid><dc:creator>Thomas Johansen</dc:creator><description>&lt;p&gt;&lt;p&gt;
I just have to add, that the call to SPI_Read is blocking until
the 3 bytes are send.&lt;br /&gt;
I guess I cant get the SPI interrupts before the timer ISR has ack&amp;#39;ed
the interrupt?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nested interrupt</title><link>https://community.arm.com/thread/76721?ContentTypeID=1</link><pubDate>Fri, 26 Sep 2008 01:40:33 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:474d679f-a36d-4dd9-92e3-a796a6219222</guid><dc:creator>Thomas Johansen</dc:creator><description>&lt;p&gt;&lt;p&gt;
I see...&lt;/p&gt;

&lt;p&gt;
But I cant get the SPI interrupt to fire if I start the transfer
within my timer interrupt. Is it because I call a function from my
timer ISR thats start the SPI transfer? Se code below.&lt;/p&gt;

&lt;pre&gt;
// Timer ISR
void tc1ISR(void) __irq // Timer interrupts
{
  // Check interrupt cause
  if( (T1IR&amp;amp;0x01) == 0x01 )
  {
    // Match register 0
    PINSEL0 &amp;amp;= ~0x00000400;
    IODIR0 &amp;amp;= ~RDY_PIN; // P0.5 defined as input
    // CS low --&amp;gt; starting the converion
    IOCLR0 = 0x00000080;
    VICVectAddr = 0;
    T1IR  |=0x01;
  }
  else if((T1IR&amp;amp;0x02) == 0x02 )
  {
     // Start SPI transfeer... 3 bytes send
     SPI_Read(m_byAnalogData, 3); // &amp;lt;-- This start the SPI transfer
     // Clear interrupt flag
     VICVectAddr = 0;
     T1IR  |=0x02;
  }
}

// SPI isr never reached if i start the transfere within the timer ISR
void SPI_Isr(void) __irq
{
  // Read the SPI status register
  if ((S0SPSR &amp;amp; 0xF8) == 0x80)
  {
     // Switch on state
     switch(bySPIState)
     {
       case 0:
       {
        lConversionData = (S0SPDR);// &amp;amp; 0x3F);
         bySPIState = 1;
       }
       break;
       case 1:
       {
          lConversionData = lConversionData&amp;lt;&amp;lt;8;
          lConversionData |= S0SPDR;
          bySPIState = 2;
       }
       break;
       case 2:
       {
          lConversionData = lConversionData&amp;lt;&amp;lt;8;
          lConversionData |= S0SPDR;
          bySPIState = 0;
       }
       break;
    }
    // Still more data to send?
    if (--count &amp;gt; 0)
    {
       // sent next byte
       S0SPDR = *msg;
    }
    else
    {
       state = SPI_OK; // transfer completed
    }
  }
  // Reset  SPI interrupt flag
  S0SPINT = 0x01;
  // ACK the interrupt
  VICVectAddr = 0;
}
&lt;/pre&gt;

&lt;p&gt;
But if I instead just sets and flag in the timer ISR, and then
start the SPI transfer when this flag gets true, the SPI interrupts
works fine. But that just take the point away of using IRQ, if I have
to poll a flag!!&lt;/p&gt;

&lt;p&gt;
/Thomas&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Nested interrupt</title><link>https://community.arm.com/thread/52524?ContentTypeID=1</link><pubDate>Fri, 26 Sep 2008 01:13:12 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f1661392-78f7-439b-b0e7-61ede6972631</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
There is no problem starting an SPI transfer from your interrupt
handler - no need for nested interrupts for that.&lt;/p&gt;

&lt;p&gt;
Nested interrupts is just if you want one interrupt handler to be
able to interrupt another interrupt handler.&lt;/p&gt;

&lt;p&gt;
If you need to service the SPI interrupt before leaving the timer
interrupt, or if you need to service the timer interrupt before
ending the SPI interrupt.&lt;/p&gt;

&lt;p&gt;
But both SPI and timer interrupts should normally (as almost all
interrupts) be very short and quick, in which case you can run the
two interrupts after each other - something the processor will manage
by itself.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>