<?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>High frequency sampling loses IRQ calls</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/4369/high-frequency-sampling-loses-irq-calls</link><description>Hi 
 I&amp;#39;m trying to measure the frequency of a pulse signal that runs at a moderate pace, varying between 50 and 500Hz while the SoftDevice is active. The softdevice needs to be active because I must send that frequency over ANT.
I need to have the exact</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 15 Nov 2014 08:46:11 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/4369/high-frequency-sampling-loses-irq-calls" /><item><title>RE: High frequency sampling loses IRQ calls</title><link>https://devzone.nordicsemi.com/thread/15527?ContentTypeID=1</link><pubDate>Sat, 15 Nov 2014 08:46:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4466d1fc-5639-470a-93ab-7e080c97d5e0</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;How frustrating! OK my guess would be that the GPIOTE IN EVENT is triggered and that triggers the COUNT correctly through the PPI, but the EVENT stays triggered (1) until you are able to clear it in the interrupt handler thus STILL missing any toggles. Sorry I should have expected that but didn&amp;#39;t think it far enough through. What you&amp;#39;d really want is for the EVENT not-only to trigger the counter (which you have) but also then self-clear. I just scanned the manual again and I don&amp;#39;t think you can do that.  A couple of the other boards I have at home (not nordic) let you connect a pin directly to a counter, but I don&amp;#39;t see that option either.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m now somewhat out of ideas but I&amp;#39;ll think on it a little more see if there is anything else.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High frequency sampling loses IRQ calls</title><link>https://devzone.nordicsemi.com/thread/15523?ContentTypeID=1</link><pubDate>Fri, 14 Nov 2014 16:25:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f9b0a53-946b-4e25-9de2-e87a959c6168</guid><dc:creator>Nestor Matas</dc:creator><description>&lt;p&gt;I started the timer as stated in the manual and now the timer counts. But I&amp;#39;m seeing that the original problem stays the same. Each time the IRQ is serviced the counter has a value of 1, but the time elapsed is not always the same at a constant input rate. So inputs are being lost.&lt;br /&gt;
how can it be?
The only workaround I&amp;#39;ve found is to check if the latest time is way bigger than the last one and in that case try to calculate how many input ticks may have been lost based on the last time stored.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High frequency sampling loses IRQ calls</title><link>https://devzone.nordicsemi.com/thread/15524?ContentTypeID=1</link><pubDate>Thu, 13 Nov 2014 02:21:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d79eb2a9-a49d-42f9-802c-ccf3a43d1430</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;This from the reference manual ...&lt;/p&gt;
&lt;p&gt;&amp;quot;The TIMER can operate in two modes, Timer mode and Counter mode. In both modes the TIMER is started by triggering the START task, and stopped by triggering the STOP task. After the timer is stopped the timer can resume timing/counting by triggering the START task again. When timing/counting is resumed the timer will continue from the value it had prior to being stopped.&amp;quot;&lt;/p&gt;
&lt;p&gt;So you need to start it with the START task else it won&amp;#39;t count. This actually makes sense if you think about it, especially in the case we&amp;#39;re trying out here where the COUNT is triggered by a PPI (or hopefully it will be when you start the timer) you&amp;#39;d want a way to quickly and simply turn the counter on and off.&lt;/p&gt;
&lt;p&gt;PRESCALAR is irrelevant in this case, again if you look at the diagram in the reference manual you&amp;#39;ll see the COUNT event is after the scaling.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High frequency sampling loses IRQ calls</title><link>https://devzone.nordicsemi.com/thread/15526?ContentTypeID=1</link><pubDate>Wed, 12 Nov 2014 17:13:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:72ca97c3-24f2-4b93-bc9c-5cc6aac997fd</guid><dc:creator>Nestor Matas</dc:creator><description>&lt;p&gt;Sorry, the prescaler value in the previous code is invalid, must be 0-9, anyway, I have no clue of what value to use, as the timer is a counter.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High frequency sampling loses IRQ calls</title><link>https://devzone.nordicsemi.com/thread/15525?ContentTypeID=1</link><pubDate>Wed, 12 Nov 2014 14:26:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98bbd345-9472-46db-9af2-f536f7e7459c</guid><dc:creator>Nestor Matas</dc:creator><description>&lt;p&gt;Thanks for your suggestion RK&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve tried your appoarch, something like this&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_TIMER1-&amp;gt;MODE           = TIMER_MODE_MODE_Counter;
	NRF_TIMER1-&amp;gt;PRESCALER      = 10;                            
	NRF_TIMER1-&amp;gt;BITMODE        = TIMER_BITMODE_BITMODE_08Bit;	
	NRF_TIMER1-&amp;gt;TASKS_CLEAR    = 1; 	

	// Connect GPIOTE in event to RTC1 count task
	sd_ppi_channel_assign(0, &amp;amp;NRF_GPIOTE-&amp;gt;EVENTS_IN[0], &amp;amp;NRF_TIMER1-&amp;gt;TASKS_COUNT);
	sd_ppi_channel_enable_set(PPI_CHENCLR_CH0_Msk);	
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But I&amp;#39;m not able to make it work.
Every time I read the CC of the timer I get 0, no matter how many in events have occurred in the gpiote&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_TIMER1-&amp;gt;TASKS_CAPTURE[0]=1;
		passes = NRF_TIMER1-&amp;gt;CC[0];
		NRF_TIMER1-&amp;gt;TASKS_CLEAR = 1;	
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;passes is always 0.
I don&amp;#39;t start or stop the timer because I don&amp;#39;t want it to count time, but even if I manually call the NRF_TIMER1-&amp;gt;TASKS_COUNT task, I&amp;#39;m not able to increment the timer counter.&lt;/p&gt;
&lt;p&gt;Any idea what I&amp;#39;m missing?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: High frequency sampling loses IRQ calls</title><link>https://devzone.nordicsemi.com/thread/15522?ContentTypeID=1</link><pubDate>Sat, 08 Nov 2014 05:51:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc10b8bd-feba-4644-905b-bf955a46cd05</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;if you set up a PPI between your GPIO and the COUNT event on one of the available timers then each time you get a pulse it will count. That won&amp;#39;t help you missing interrupts, however when you do get an interrupt you will be able to check the count and see how many pulses you received since the last IRQ you serviced.&lt;/p&gt;
&lt;p&gt;That does mean you will have to use another timer, one in count mode, one in time mode, but as long as you have a spare one that may work for you.&lt;/p&gt;
&lt;p&gt;I believe you can both set up the PPI from GPIOTE-&amp;gt;COUNT and also enable either the GPIOTE or the COUNT event to generate the interrupt you want.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>