<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/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/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>NRF51822 Interrupt Service Routine handling</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/8636/nrf51822-interrupt-service-routine-handling</link><description>Hello,
I was using wiringPiSPI() to connect via SPI and so i was using wiringPiISR function to create an interupt handler that will do callback to the user suplied function. Now I moved to module with NRF architecture. How can I handle interuptions the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 12 Aug 2015 13:47:12 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/8636/nrf51822-interrupt-service-routine-handling" /><item><title>RE: NRF51822 Interrupt Service Routine handling</title><link>https://devzone.nordicsemi.com/thread/31594?ContentTypeID=1</link><pubDate>Wed, 12 Aug 2015 13:47:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:367a138c-5176-43aa-bea4-343359034553</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;I don&amp;#39;t think it&amp;#39;s a good idea to handle everything in a IRQ handler and stay there until the pin is released. Don&amp;#39;t think you gonna receive the SPI interrupt if you already in a highest level priority context.&lt;/p&gt;
&lt;p&gt;My suggestion for you is to set a flag when in IRQHandler, and execute the SPI transmission when you are back to the main loop.&lt;/p&gt;
&lt;p&gt;When you mentioned you are using APP_IRQ_PRIORITY_LOW and APP_IRQ_PRIORITY_HIGH, do you have the softdevice also running ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF51822 Interrupt Service Routine handling</title><link>https://devzone.nordicsemi.com/thread/31593?ContentTypeID=1</link><pubDate>Wed, 12 Aug 2015 07:51:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7dc52bb0-019f-4153-b6af-1e28a2933f0e</guid><dc:creator>Krzysiek </dc:creator><description>&lt;p&gt;Comment field is a little to small so I will paste it here as a new post.&lt;/p&gt;
&lt;p&gt;I started to use GPIOTE and managed to sucesfully get interupt from external device.
Next problem I have is, that when IRQHandler kicks in, whole system freezes (with APP_IRQ_PRIORITY_HIGH) or program isn&amp;#39;t executed correctly (with APP_IRQ_PRIORITY_LOW)&lt;/p&gt;
&lt;p&gt;isr() function read and write to device through SPI (And here I&amp;#39;m not so sure what happens with concurrent SPI transmission)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void GPIOTE_initirq()
{
	
NVIC_DisableIRQ(GPIOTE_IRQn);
	NVIC_ClearPendingIRQ(GPIOTE_IRQn);
	NVIC_SetPriority(GPIOTE_IRQn, APP_IRQ_PRIORITY_LOW); //Here is the problem


NRF_GPIOTE-&amp;gt;CONFIG[0] =  (GPIOTE_CONFIG_POLARITY_LoToHi &amp;lt;&amp;lt; GPIOTE_CONFIG_POLARITY_Pos)
					   | (0x10 &amp;lt;&amp;lt; GPIOTE_CONFIG_PSEL_Pos)   //
					   | (GPIOTE_CONFIG_MODE_Event &amp;lt;&amp;lt; GPIOTE_CONFIG_MODE_Pos);
NRF_GPIOTE-&amp;gt;INTENSET  = GPIOTE_INTENSET_IN0_Set &amp;lt;&amp;lt; GPIOTE_INTENSET_IN0_Pos;

 __NOP();
 __NOP();
 __NOP();

 NRF_GPIOTE-&amp;gt;EVENTS_IN[0] = 0;
 NRF_GPIOTE-&amp;gt;INTENSET = GPIOTE_INTENSET_IN0_Enabled &amp;lt;&amp;lt; GPIOTE_INTENSET_IN0_Pos;
 NVIC_EnableIRQ(GPIOTE_IRQn);

}

void GPIOTE_IRQHandler(void)
{
		process_irq();
		NRF_GPIOTE-&amp;gt;EVENTS_IN[0] = 0;
}

process_irq()
{
	do
	{
		isr();
	}while(nrf_gpio_pin_read(IRQ) == 1)
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;On Raspberry Pi the following code was executed to handle interruptions:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    //port_EnableIRQ(); 
    //enable ScenSor IRQ before starting
	// set Pin 24 generate an interrupt on high-to-low transitions
	// and attach process_deca_irq() to the interrupt

if ( wiringPiISR (IRQ_PIN, INT_EDGE_RISING, &amp;amp;process_deca_irq) &amp;lt; 0 ) {
  printf(&amp;quot;Unable to setup ISR\r\n&amp;quot;);
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF51822 Interrupt Service Routine handling</title><link>https://devzone.nordicsemi.com/thread/31592?ContentTypeID=1</link><pubDate>Tue, 11 Aug 2015 11:14:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4207c49c-f3b1-47ff-af63-f64a3cb01a47</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Krzysiek: It&amp;#39;s not covered in the SPI protocol, so you would need to either use the SPI Master to poll or implement an extra GPIO interrupt so that the slave can trigger the interrupt when there is data he wants to send. You can think of using the GPIOTE driver.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF51822 Interrupt Service Routine handling</title><link>https://devzone.nordicsemi.com/thread/31591?ContentTypeID=1</link><pubDate>Tue, 11 Aug 2015 09:43:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:238250b9-4bf0-4de5-b2cd-b674cc8cf4cc</guid><dc:creator>Krzysiek </dc:creator><description>&lt;p&gt;I have spi_master.h so I am using your SDK that provide SPI connection. To create my SPI connection i was using the same website as you sent. Yes, master always initiate the data transmission, but slave can make interrupts and I don&amp;#39;t know exactly how coordinate the data transmission. Maybe there are funtions that in SDK that would be helpful to me?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF51822 Interrupt Service Routine handling</title><link>https://devzone.nordicsemi.com/thread/31590?ContentTypeID=1</link><pubDate>Tue, 11 Aug 2015 09:18:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4b2cf55-219d-4693-89a6-e8e4f96a3615</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;@Krzysiek: Have you tried our SDK ? In our SDK we provide the library and driver for SPI. You can have a look &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk51.v9.0.0/hardware_driver_spi_master.html?cp=4_1_0_2_6"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;But I don&amp;#39;t really get it of what you mean by ISR handle, on SPI communication, it&amp;#39;s always the master that initiate the data transmission.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>