<?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>GPIOTE Interrupt</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/3982/gpiote-interrupt</link><description>I&amp;#39;m learning about GPIOTE and PPI and looking at an example I come to the following code but now it act incorrectly. So as you can see I&amp;#39;m enabling the interrupt for GPIOTE channel 0: 
 NRF_GPIOTE-&amp;gt;INTENSET = GPIOTE_INTENSET_IN0_Msk;
 
 But when the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 09 Oct 2014 06:33:57 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/3982/gpiote-interrupt" /><item><title>RE: GPIOTE Interrupt</title><link>https://devzone.nordicsemi.com/thread/14319?ContentTypeID=1</link><pubDate>Thu, 09 Oct 2014 06:33:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:48bd56b4-9851-49a1-a652-060151f6deaf</guid><dc:creator>yd</dc:creator><description>&lt;p&gt;It looks like the values are being read after the GPIOTE task 1 has completed. Make sure you don&amp;#39;t put any breakpoints in the GPIOTE_IRQHandler before reading the values of CC[0] / CC[1]. Check below for breakpoint positioning.&lt;/p&gt;
&lt;p&gt;From the documentation of GPIOTE abstraction:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The GPIOTE users are responsible for
configuring all their corresponding
pins, except the SENSE field, which
should be initialized to
GPIO_PIN_CNF_SENSE_Disabled.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Although you are not using the abstraction, it might have to do something with Sense Low. I don&amp;#39;t configure the sense field in my project, so I am not sure about this.&lt;/p&gt;
&lt;p&gt;Try changing:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nrf_gpio_cfg_sense_input(ECHO, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nrf_gpio_cfg_input(ECHO, NRF_GPIO_PIN_NOPULL);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Enable Interrupts on GPIOTE after you have cleared the pending flags like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NVIC_DisableIRQ(GPIOTE_IRQn);
NVIC_ClearPendingIRQ(GPIOTE_IRQn);

NRF_GPIOTE-&amp;gt;INTENSET = 0x00000001;// enable interrupts for config[n] pins, n = 0 in this case so bitmask is 0x01

NVIC_SetPriority(GPIOTE_IRQn, 3); //optional: set priority of interrupt
NVIC_EnableIRQ(GPIOTE_IRQn);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Try to separate GPIOTE events in GPIOTE_IRQHandler and put breakpoints after reading CC values:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;if(NRF_GPIOTE-&amp;gt;EVENTS_IN[0] == 1)
{
	curr_cc0 = NRF_TIMER1-&amp;gt;CC[0];
	curr_cc1 = NRF_TIMER1-&amp;gt;CC[1]; //keep this if you need it
	NRF_GPIOTE-&amp;gt;EVENTS_IN[0] = 0;  //this is where you should set breakpoint to make sure CC[0] and cc[1] don&amp;#39;t change while you are in breakpoint
}

if(NRF_GPIOTE-&amp;gt;EVENTS_IN[1] == 1) //will run only if you intenset event 1
{
	curr_cc0 = NRF_TIMER1-&amp;gt;CC[0]; //keep this if you need it
	curr_cc1 = NRF_TIMER1-&amp;gt;CC[1];
	NRF_GPIOTE-&amp;gt;EVENTS_IN[1] = 0;  //this is where you should set breakpoint to make sure CC[0] and cc[1] don&amp;#39;t change while you are in breakpoint
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIOTE Interrupt</title><link>https://devzone.nordicsemi.com/thread/14318?ContentTypeID=1</link><pubDate>Wed, 08 Oct 2014 09:21:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cff3c335-c1fb-48d1-a6ff-c4e42984249d</guid><dc:creator>Jose Xavier</dc:creator><description>&lt;p&gt;I&amp;#39;m trying to capture the signal that you see in channel 2 of logic analyser screenshot. So I set up a gpiote task to lowtohigh event the save the timer1 count on cc[0] and another gpiote task to hightolow event that save the value on cc[1].&lt;/p&gt;
&lt;p&gt;On the gpiote init I enable an interrupt for the lowtohigh event and debugging the code with a breakpoint on the gpioteirqhandler I would expect to got 0 on the cc[1] instead of the hightolow value.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIOTE Interrupt</title><link>https://devzone.nordicsemi.com/thread/14317?ContentTypeID=1</link><pubDate>Wed, 08 Oct 2014 09:04:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a25ce9db-79ea-49d6-b9f2-faf66bb3aacb</guid><dc:creator>Stefan Birnir Sverrisson</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I suspect that you are trying to build upon the gpiote_example in the nRF51 SDK. For setup of interrupts and interrupt handler, you might also benefit of looking at e.g. the rtc_example in the SDK.&lt;/p&gt;
&lt;p&gt;I am also pretty unsure of what you are trying to achieve, so please clarify your problem.&lt;/p&gt;
&lt;p&gt;You have not shown in your code your Timer configuration. TIMER1-&amp;gt;CC[0] and TIMER1-&amp;gt;CC[1] values should be the same as you set them when you initialize the timer. How it works is that you set a CC[X] compare register and then you start the TIMER. When the TIMER value is equal to the CC[X] value, a timer event is generated. Perhaps &lt;a href="https://github.com/NordicSemiconductor/nrf51-TIMER-examples"&gt;these simple timer examples&lt;/a&gt; will help you if you have doubts about how the TIMER actually works. Timer information is also available in the &lt;a href="https://www.nordicsemi.com/eng/nordic/Products/nRF51822/nRF51-RM/20337"&gt;nRF51 Series Reference Manual&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>