<?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>Not enough timers</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/12790/not-enough-timers</link><description>My application uses the Softdevice, app_timer and app_pwm.
So all timers are in use, but I have to measure two more pwm signals on two input pins.
(Those come from HC-SR04 sonar sensors) 
 I have set up interrupt handlers on raising and falling edges</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 04 Apr 2016 08:51:58 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/12790/not-enough-timers" /><item><title>RE: Not enough timers</title><link>https://devzone.nordicsemi.com/thread/48614?ContentTypeID=1</link><pubDate>Mon, 04 Apr 2016 08:51:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:398b573b-6c91-4153-ab96-2c31460f6ef6</guid><dc:creator>cody</dc:creator><description>&lt;p&gt;Very good idea!
I only trigger the sensor if the previous measurement has finished anyway and so I know that the last edge before the trigger signal was a falling edge.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not enough timers</title><link>https://devzone.nordicsemi.com/thread/48613?ContentTypeID=1</link><pubDate>Mon, 04 Apr 2016 08:28:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:22874e29-b0e5-4044-a84a-da45e536e6cc</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;You can setup a pin the trigger an event on any edge (it is called TOGGLE), so then you can do it like this:&lt;/p&gt;
&lt;p&gt;PPI ch 1: Reset timer on any edge on pin X&lt;/p&gt;
&lt;p&gt;PPI ch 2: Capture timer value on any edge on pin X&lt;/p&gt;
&lt;p&gt;The capture will get the value just before the timer is reset to 0. The CC register will then hold the value of the pulse width before the last edge (either the low pulsewidth or the high pulsewidth depending on the polarity of the edge), if the last edge is the falling edge then you are fine. You can ensure this by not triggering the ultrasonic sensor before you have read the CC register. Let me know if I didn&amp;#39;t explain this good enough :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not enough timers</title><link>https://devzone.nordicsemi.com/thread/48611?ContentTypeID=1</link><pubDate>Sun, 03 Apr 2016 16:56:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13c3aa45-8d6d-40fa-bec4-d7425b2aac2b</guid><dc:creator>cody</dc:creator><description>&lt;p&gt;I think there is no other possibility:
&lt;a href="https://devzone.nordicsemi.com/question/35676/gpiote_irqhandler-interrupt-delay-using-s110/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not enough timers</title><link>https://devzone.nordicsemi.com/thread/48612?ContentTypeID=1</link><pubDate>Sun, 03 Apr 2016 16:35:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6992bc1-a272-4370-b9cd-2d1594d3f503</guid><dc:creator>cody</dc:creator><description>&lt;p&gt;Ok, my plan was the following:&lt;/p&gt;
&lt;p&gt;PPI channel 1: Reset timer on raising edge on pin X.&lt;/p&gt;
&lt;p&gt;PPI channel 2: Capture timer value on falling edge on pin X.&lt;/p&gt;
&lt;p&gt;So I get the duration between rasing and falling edge. Brilliant.&lt;/p&gt;
&lt;p&gt;Problem:&lt;/p&gt;
&lt;p&gt;I only have one event per pin. I cant have one event for raising and one for falling edge.
At least that is how I understand nrf_drv_gpiote.c.&lt;/p&gt;
&lt;p&gt;What can I do?&lt;/p&gt;
&lt;p&gt;I could connect the pwm signal to two pins so I can get two events for raising/falling edges, but is there a way without modifying the hardware?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not enough timers</title><link>https://devzone.nordicsemi.com/thread/48605?ContentTypeID=1</link><pubDate>Wed, 30 Mar 2016 08:30:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:35a50455-3b2a-43ef-88a0-3ecedcb3e441</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;With a &amp;quot;normal&amp;quot; timer you can use the capture task. This will store the current value of the timer in one of the four CC registers. For example &lt;code&gt;NRF_TIMER2-&amp;gt;TASK_CAPTURE[0] = 1&lt;/code&gt; will store the timer value in &lt;code&gt;NRF_TIMER2-&amp;gt;CC[0]&lt;/code&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not enough timers</title><link>https://devzone.nordicsemi.com/thread/48604?ContentTypeID=1</link><pubDate>Tue, 29 Mar 2016 20:30:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1e72dafc-a1ed-45a5-92d1-3c39e9b08394</guid><dc:creator>cody</dc:creator><description>&lt;p&gt;You are right, I thought I only have 2 timers. So yeah I will learn about GPIOTE and PPI.
One more thing: I can access the RTC counter register with NRF_RTC1-&amp;gt;COUNTER, but this does not seem to be possible with a &amp;quot;normal&amp;quot; timer?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not enough timers</title><link>https://devzone.nordicsemi.com/thread/48615?ContentTypeID=1</link><pubDate>Tue, 29 Mar 2016 15:26:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c893352b-c0cc-4ae7-99b3-f40b44dfe811</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;With app_pwm you can have two pwm channels per timer. The reason you cannot have three per timer is that the library uses one CC channel to ensure that the pwm signal is not reversed. But enough about that.&lt;/p&gt;
&lt;p&gt;You have 3 timers with nRF51822 and 2 rtc timers. Since you have only used 2 timers you have one left that you can use. Using TIMER, GPIOTE and PPI you can get accurate measurements without worrying about being interrupted by for example the SoftDevice, so I would follow Tasketronds advice and read up on these peripherals.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not enough timers</title><link>https://devzone.nordicsemi.com/thread/48607?ContentTypeID=1</link><pubDate>Mon, 28 Mar 2016 06:17:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:756d463e-2998-4d04-897a-49faa5319b41</guid><dc:creator>wlgrd</dc:creator><description>&lt;p&gt;@AndrewJ, this should not affect flashing the chip at all. Please open a separate question.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not enough timers</title><link>https://devzone.nordicsemi.com/thread/48606?ContentTypeID=1</link><pubDate>Mon, 28 Mar 2016 05:40:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2d43cf8-1156-4680-b6a8-2685fc29ff54</guid><dc:creator>Andrew J.</dc:creator><description>&lt;p&gt;Hey, I think I am having the same problem. Doing bluetooth, S130, nrf51422, SDK 9, and need PWM for Frequency Shift Keying (FSK). What type error message are you getting? I can build my project but when I try to flash, I get a failed to download. Tried timer 1 and 2 but no luck even through the SDK says its doable.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not enough timers</title><link>https://devzone.nordicsemi.com/thread/48610?ContentTypeID=1</link><pubDate>Sat, 26 Mar 2016 20:05:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6879f140-1ced-4297-bc33-9b16ff56f5d4</guid><dc:creator>wlgrd</dc:creator><description>&lt;p&gt;For such a requirement I would advice to read up on GPIOTE and PPI, since they are two modules that are extremely nice to have. I dare to say that PPI is the most awesome module in the nRF chips&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not enough timers</title><link>https://devzone.nordicsemi.com/thread/48609?ContentTypeID=1</link><pubDate>Fri, 25 Mar 2016 23:52:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d20c441e-3d54-4e81-b260-565c46e4f346</guid><dc:creator>cody</dc:creator><description>&lt;p&gt;I dont use them directly. The Softdevice uses one timer and one rtc.
My app also uses one timer and one rtc through app_timer and app_pwm.
As I dont know much about gpiote and ppi I do not know if it would be possible.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Not enough timers</title><link>https://devzone.nordicsemi.com/thread/48608?ContentTypeID=1</link><pubDate>Fri, 25 Mar 2016 18:59:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7aa45e8a-51c0-49bb-ad74-f8b3eb786a8a</guid><dc:creator>wlgrd</dc:creator><description>&lt;p&gt;How are you using your timers? You can create several pwms by using one timer if using gpiote and ppi efficiently. Maybe you use more than you have to?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>