<?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>Issue on nputs capture of two pins simultaneously</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/80769/issue-on-nputs-capture-of-two-pins-simultaneously</link><description>Hi all 
 Thanks in advance for any hints you could give on this. I would like to measure two pwm signals (frequency and duty cycle) on two input pins of the nrf52832. 
 board : PCA10040 
 SDK : nRF5_SDK_17.0.2_d674dde 
 softdevice : s132_nrf52_7.2.0_softdevice</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 25 Oct 2021 10:17:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/80769/issue-on-nputs-capture-of-two-pins-simultaneously" /><item><title>RE: Issue on nputs capture of two pins simultaneously</title><link>https://devzone.nordicsemi.com/thread/335681?ContentTypeID=1</link><pubDate>Mon, 25 Oct 2021 10:17:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77431008-ae69-400c-8652-c7ce5259e578</guid><dc:creator>cristian.anceschi</dc:creator><description>&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;Hi Einar&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;Thanks for your hints.&lt;/span&gt;&lt;/p&gt;
&lt;pre class="tw-data-text tw-text-large XcVN5d tw-ta" dir="ltr"&gt;&lt;span class="Y2IQFc" style="font-family:arial, helvetica, sans-serif;" lang="en"&gt;As you suggested, I moved the clearing EVENT_PORT just after the EVENT_PORT check.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span class="Y2IQFc" style="font-family:arial, helvetica, sans-serif;" lang="en"&gt;Moreover, I tried to leaver the code running inside the interrupt until both EVENT_IN flags are both zero.
This appears to reduce missed readings and any interruptions in measurements.&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void GPIOTE_IRQHandler(void)
{
	bool EvntInRun = true;
	
	if(NRF_GPIOTE-&amp;gt;EVENTS_PORT == 1)
		NRF_GPIOTE-&amp;gt;EVENTS_PORT = 0;
	
	while(EvntInRun)
	{
		//--------------
		if(NRF_GPIOTE-&amp;gt;EVENTS_IN[0] == 1)
		{
			CaptEvent(&amp;amp;SGN_In_1);
			NRF_GPIOTE-&amp;gt;EVENTS_IN[0] = 0;
		}
		//--------------
		if(NRF_GPIOTE-&amp;gt;EVENTS_IN[1] == 1)
		{
			CaptEvent(&amp;amp;SGN_In_2);
			NRF_GPIOTE-&amp;gt;EVENTS_IN[1] = 0;
		}
		//--------------
		//NRF_GPIOTE-&amp;gt;EVENTS_PORT = 0;
		
		if((NRF_GPIOTE-&amp;gt;EVENTS_IN[0] == 0) &amp;amp;&amp;amp; (NRF_GPIOTE-&amp;gt;EVENTS_IN[1] == 0))
			EvntInRun	= false;
	}
}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Kind regards&lt;br /&gt;Cristian&lt;/span&gt;&lt;/pre&gt;
&lt;pre class="tw-data-text tw-text-large XcVN5d tw-ta" id="tw-target-text" dir="ltr"&gt;&lt;span class="Y2IQFc" lang="en"&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Issue on nputs capture of two pins simultaneously</title><link>https://devzone.nordicsemi.com/thread/334628?ContentTypeID=1</link><pubDate>Mon, 18 Oct 2021 13:11:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8013ec72-39bd-49e3-9a0d-db148fcb930a</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I would think you could reduce this issue by clearing&amp;nbsp;EVENTS_PORT before, so that you reduce the risk of missing an&amp;nbsp;interrupt. So something like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void GPIOTE_IRQHandler(void)
{
	if(NRF_GPIOTE-&amp;gt;EVENTS_PORT == 1)
	{
                NRF_GPIOTE-&amp;gt;EVENTS_PORT = 0;
		//--------------
		if(NRF_GPIOTE-&amp;gt;EVENTS_IN[0] == 1)
		{
			CaptEvent(&amp;amp;SGN_In_1);
			NRF_GPIOTE-&amp;gt;EVENTS_IN[0] = 0;
		}
		//--------------
		if(NRF_GPIOTE-&amp;gt;EVENTS_IN[1] == 1)
		{
			CaptEvent(&amp;amp;SGN_In_2);
			NRF_GPIOTE-&amp;gt;EVENTS_IN[1] = 0;
		}
		//--------------
	}
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;That is also how it is done in the SDK driver (see&amp;nbsp;modules\nrfx\drivers\src\nrfx_gpiote.c for reference).&lt;/p&gt;
&lt;p&gt;You may see issue still sometimes though, so it could be that it would make sense to alternate between measuring the two input signals, rather that trying to measure both at the same time.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>