<?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>Can we implment PWM Analyzer on SDK 11?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/12146/can-we-implment-pwm-analyzer-on-sdk-11</link><description>I need to implement a PWM analyzer. I looked at the example in SDK 6 and it&amp;#39;s fairly easy to follow. When I tried it, it doesn&amp;#39;t look like GPIOTE handler gets called frequently enough. Is there a better recommendation to calculate duty cycle other than</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 04 Mar 2016 08:59:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/12146/can-we-implment-pwm-analyzer-on-sdk-11" /><item><title>RE: Can we implment PWM Analyzer on SDK 11?</title><link>https://devzone.nordicsemi.com/thread/45948?ContentTypeID=1</link><pubDate>Fri, 04 Mar 2016 08:59:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a56a4e6c-dd32-4152-a7a1-0a57d90f5f08</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;You are right, you cannot get events for both low-to-high and high-to-low transitions on one GPIO pin using GPIOTE. What you can do is to use one pin with the comparator instead, as there you have separate events for low-to-high and high-to-low transitions. Alternatively you can use two GPIO pins. Using GPIOTE  with polarity toggle can be a problem, as you cannot be certain about the polarity.&lt;/p&gt;
&lt;p&gt;Of course if you are happy with doing parts of the measurements in software, as the example in SDK 6, this is less of an issue. However you will have less accurate measurements, particularly when higher priority interrupts occur while measuring (as discussed earlier in this thread).&lt;/p&gt;
&lt;p&gt;There may be a smarter way of doing this that has not come to my mind. It will be interesting to see how you solve it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can we implment PWM Analyzer on SDK 11?</title><link>https://devzone.nordicsemi.com/thread/45947?ContentTypeID=1</link><pubDate>Thu, 03 Mar 2016 21:31:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68004487-d234-4e81-ab9a-8e8c5efa7e73</guid><dc:creator>Ron</dc:creator><description>&lt;p&gt;Great, things looking well on my side. When it comes to sense rises and drops, I&amp;#39;ll have to use NRF_GPIOTE_POLARITY_TOGGLE right? There is no way where I can use 2 events, hi to lo and lo to hi, on one pin? My concern would be identifying if it is a rise or if it&amp;#39;s a drop when using toggle.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can we implment PWM Analyzer on SDK 11?</title><link>https://devzone.nordicsemi.com/thread/45946?ContentTypeID=1</link><pubDate>Thu, 03 Mar 2016 07:04:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7a2e8423-ff7c-4473-97c8-2ea6110fc6e9</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Yes, there should be a timer. You will use the timer and GPIOTE (or COMP) and connect them together using PPI.&lt;/p&gt;
&lt;p&gt;With a frequency of 25 kHz it should not be a problem to time two consecutive transitions. However you may not be able to do so if your interrupt routine cannot run fast enough, which may be the case if there are other higher priority interrupts executing at the same time. Given that you will have enough time most of the time you could probably take a few measurements close in time and process them, to see if the measurement is bogus or valid.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can we implment PWM Analyzer on SDK 11?</title><link>https://devzone.nordicsemi.com/thread/45945?ContentTypeID=1</link><pubDate>Wed, 02 Mar 2016 20:27:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3532ff4b-072f-4ff8-b072-7fe81f9adfd1</guid><dc:creator>Ron</dc:creator><description>&lt;p&gt;Thanks for the last tidbit. I will be needing to add bluetooth events at some point. Just to be clear, when you say measuring with gpiote using PPI, there should also be a timer, right? You were saying that the two consecutive transitions could give problems. Are there other ways to do it other than that?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can we implment PWM Analyzer on SDK 11?</title><link>https://devzone.nordicsemi.com/thread/45944?ContentTypeID=1</link><pubDate>Mon, 29 Feb 2016 06:54:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b80602d5-919d-43db-a7d8-ead42fa69fcc</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;You should have no problem measuring frequencies of up to 25 kHz using a timer together with a comparator or gpiote using PPI. This way, connecting the peripherals with PPI, the actual measurement will be done in hardware, and you only need software to configure and process the measurements.&lt;/p&gt;
&lt;p&gt;One thing I can think of that can give problems is that the way it is implemented in the example in SDK 6, you need to sample two &lt;em&gt;consecutive&lt;/em&gt; low-to-high (or opposite) transitions in order to determine the duty cycle. While you should have more than enough time, this may not be the case if there is something else happening, such as higher priority interrupts of SoftDevice activity. One way around this is to ensure that the &lt;code&gt;GPIOTE_IRQHandler()&lt;/code&gt; has the highest application interrupt priority. If you are using the SoftDevice you should make sure it will not interrupt either, which you can do using for example the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.sds.v0.5/dita/softdevices/s130/concurrent_multiprotocol_tsl_api/concurrent_multiprotocol_tsl_api.html"&gt;timeslot API&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can we implment PWM Analyzer on SDK 11?</title><link>https://devzone.nordicsemi.com/thread/45943?ContentTypeID=1</link><pubDate>Fri, 26 Feb 2016 14:57:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc9197fa-a95d-4138-b5e5-d9c26bf65ded</guid><dc:creator>Ron</dc:creator><description>&lt;p&gt;I&amp;#39;ve been told max frequency will be around 25 khz and I&amp;#39;m using nRF51.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can we implment PWM Analyzer on SDK 11?</title><link>https://devzone.nordicsemi.com/thread/45942?ContentTypeID=1</link><pubDate>Fri, 26 Feb 2016 07:59:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9717978-7a98-4f69-91be-fb472270d1e0</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;The peripherals use a 16 MHz clock, which is a limiting factor when measurements are performed using PPI. Using GPIOTE and a timer connected via PPI as the pwm_analyzer example in SDK 6 is a sensible way of doing the measurements. You can also use a comparator instead of GPIOTE.&lt;/p&gt;
&lt;p&gt;If the frequency of the PWM signal you are analyzing is too high compared to what you are measuring with, you could consider low pass filtering the PWM signal and using the ADC. This will have a few disadvantages, though. It will require an external RC filter and will have lower accuracy.&lt;/p&gt;
&lt;p&gt;A few questions:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What is the maximum frequency of the PWM signal you need to analyze?&lt;/li&gt;
&lt;li&gt;Are you using nRF52 or nRF51?&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>