<?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>How do I use an external interrupt?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/5358/how-do-i-use-an-external-interrupt</link><description>Have tried to use an external interrupt coding. 
 /*------------------------------------------------------------------------------------------------------------*/
#define Record 28
#define Play 26

static void gpio_init(void)
{
nrf_gpio_cfg_input</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 09 Feb 2015 09:31:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/5358/how-do-i-use-an-external-interrupt" /><item><title>RE: How do I use an external interrupt?</title><link>https://devzone.nordicsemi.com/thread/18739?ContentTypeID=1</link><pubDate>Mon, 09 Feb 2015 09:31:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:464a4806-ef53-4f59-82c4-62969f1d72af</guid><dc:creator>GunMin</dc:creator><description>&lt;p&gt;Thank you, Action is well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I use an external interrupt?</title><link>https://devzone.nordicsemi.com/thread/18738?ContentTypeID=1</link><pubDate>Mon, 02 Feb 2015 21:32:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98edadb3-56c2-425d-8e16-80acced33ab1</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;Well, does it work?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I use an external interrupt?</title><link>https://devzone.nordicsemi.com/thread/18737?ContentTypeID=1</link><pubDate>Mon, 02 Feb 2015 17:39:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7fb97ed3-83a1-4778-bea5-885e3e0da9c6</guid><dc:creator>GunMin</dc:creator><description>&lt;p&gt;I&amp;#39;m doing this? Is that right?&lt;/p&gt;
&lt;p&gt;static void gpio_init(void)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  nrf_gpio_cfg_input(Record, NRF_GPIO_PIN_PULLUP);
      nrf_gpio_cfg_input(Play, NRF_GPIO_PIN_PULLUP);
  nrf_gpio_cfg_input(Menu_Dw, NRF_GPIO_PIN_PULLUP);

      NVIC_DisableIRQ(GPIOTE_IRQn);
      NVIC_ClearPendingIRQ(GPIOTE_IRQn);

       NRF_GPIOTE-&amp;gt;CONFIG[0] =  (GPIOTE_CONFIG_POLARITY_HiToLo &amp;lt;&amp;lt; GPIOTE_CONFIG_POLARITY_Pos)
                   | (0x1C &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;

       NRF_GPIOTE-&amp;gt;CONFIG[0] =  (GPIOTE_CONFIG_POLARITY_HiToLo &amp;lt;&amp;lt;                          
                           GPIOTE_CONFIG_POLARITY_Pos)
                   | (0x1D &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_IN1_Set &amp;lt;&amp;lt; GPIOTE_INTENSET_IN1_Pos;

  	  __NOP();
      __NOP();
      __NOP();
 
				/* Clear the event that appears in some cases */
				NRF_GPIOTE-&amp;gt;EVENTS_IN[0] = 0; 
				NRF_GPIOTE-&amp;gt;EVENTS_IN[1] = 0; 

      NRF_GPIOTE-&amp;gt;INTENSET = GPIOTE_INTENSET_IN0_Enabled &amp;lt;&amp;lt; GPIOTE_INTENSET_IN0_Pos;
	NRF_GPIOTE-&amp;gt;INTENSET = GPIOTE_INTENSET_IN1_Enabled &amp;lt;&amp;lt; GPIOTE_INTENSET_IN1_Pos;
        NVIC_EnableIRQ(GPIOTE_IRQn);
														  			
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;void GPIOTE_IRQHandler(void)&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;p&gt;if ((NRF_GPIOTE-&amp;gt;EVENTS_IN[0] != 0))&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;     Record_Start = (!Record_Start) ;
     NRF_GPIOTE-&amp;gt;EVENTS_IN[0] = 0;
 }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;if ((NRF_GPIOTE-&amp;gt;EVENTS_IN[1] != 0))&lt;/p&gt;
&lt;p&gt;{&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    Record_Play = (!Record_Play) ;
    NRF_GPIOTE-&amp;gt;EVENTS_IN[1] = 0;
}	
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How do I use an external interrupt?</title><link>https://devzone.nordicsemi.com/thread/18736?ContentTypeID=1</link><pubDate>Mon, 02 Feb 2015 13:37:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4040ff68-bdbf-4d78-9582-2bb7839b2404</guid><dc:creator>Stian R&amp;#248;ed Hafskjold</dc:creator><description>&lt;p&gt;This line,&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_GPIOTE-&amp;gt;CONFIG[0] =  (GPIOTE_CONFIG_POLARITY_Toggle &amp;lt;&amp;lt; GPIOTE_CONFIG_POLARITY_Pos)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;will cause the interrupt to trigger both when you push the button and when you release it. In order to only trigger the interrupt when you push the button, change it to:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_GPIOTE-&amp;gt;CONFIG[0] =  (GPIOTE_CONFIG_POLARITY_HiToLo&amp;lt;&amp;lt; GPIOTE_CONFIG_POLARITY_Pos)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Also, you can not read the pin state when the GPIOTE module is configured to operate on it, as you do in the interrupt handler:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;if (nrf_gpio_pin_read(Record) == 0) {Record_Start = (!Record_Start);}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But, since the GPIOTE channel is now configured to only trigger on a hi to low transition, the pin will of course be low, and you can just write:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Record_Start = (!Record_Start);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>