<?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>Best way to measure time between falling/rising edges (NCS, Zephyr, NRF52840)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/104771/best-way-to-measure-time-between-falling-rising-edges-ncs-zephyr-nrf52840</link><description>Hello everyone, 
 is there a safe way to measure the time between rising and falling edges (accuracy +-1&amp;#181;s, duration of the pulses are 50&amp;#181;s or more) on a GPIO(TE) pin? If so, can you please show me? 
 I am using a custom board with a NRF52840, running</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 02 Nov 2023 13:58:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/104771/best-way-to-measure-time-between-falling-rising-edges-ncs-zephyr-nrf52840" /><item><title>RE: Best way to measure time between falling/rising edges (NCS, Zephyr, NRF52840)</title><link>https://devzone.nordicsemi.com/thread/453757?ContentTypeID=1</link><pubDate>Thu, 02 Nov 2023 13:58:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fc738cdf-c647-46bf-b470-de73d968e11a</guid><dc:creator>Domi471</dc:creator><description>&lt;p&gt;Thank you, have a super nice day too! &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to measure time between falling/rising edges (NCS, Zephyr, NRF52840)</title><link>https://devzone.nordicsemi.com/thread/453749?ContentTypeID=1</link><pubDate>Thu, 02 Nov 2023 13:46:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:402e4f79-d10f-47d7-92cc-56bfb1ad09db</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi Dom,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Glad to hear that the sample was helpful!&lt;/p&gt;
&lt;p&gt;Hope you have a wonderful day!&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to measure time between falling/rising edges (NCS, Zephyr, NRF52840)</title><link>https://devzone.nordicsemi.com/thread/453695?ContentTypeID=1</link><pubDate>Thu, 02 Nov 2023 12:00:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b702327f-0ee9-4518-a0b2-7884387ea675</guid><dc:creator>Domi471</dc:creator><description>&lt;p&gt;Thank you very very much for your extensive answer, that helps a lot :).&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Dom&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to measure time between falling/rising edges (NCS, Zephyr, NRF52840)</title><link>https://devzone.nordicsemi.com/thread/451033?ContentTypeID=1</link><pubDate>Wed, 18 Oct 2023 10:53:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3839fa57-33da-4dcd-bda7-8379ae930278</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user=""]is there a safe way to measure the time between rising and falling edges (accuracy +-1µs, duration of the pulses are 50µs or more) on a GPIO(TE) pin? If so, can you please show me?[/quote]
&lt;p&gt;Yes, it is possible to do this with:&lt;/p&gt;
&lt;p&gt;* 2 * GPIOTE IN channels (one for rising, one for falling)&lt;/p&gt;
&lt;p&gt;* TIMER CC&lt;/p&gt;
&lt;p&gt;* PPI channels&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Since two GPIOTE channels are required here, you should route your signal to two GPIOs.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The algorithm would look something like this:&lt;/p&gt;
&lt;p&gt;* Configure GPIOTE ch #1 as IN low-to-high (ie. rising)&lt;/p&gt;
&lt;p&gt;* Configure GPIOTE ch #2 as IN high-to-low (ie. falling)&lt;/p&gt;
&lt;p&gt;* Setup TIMER in 16M resolution&lt;/p&gt;
&lt;p&gt;* Use PPI to start timer on rising edge&lt;/p&gt;
&lt;p&gt;* Use PPI to capture&amp;nbsp;&lt;strong&gt;and&lt;/strong&gt; stop timer on falling edge&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Now you can read the CC register and get the value in 16M units. Remember to clear the nrfx timer instance on each read.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s an example of such a setup:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/timed_5F00_signals_5F00_ncs240.zip"&gt;devzone.nordicsemi.com/.../timed_5F00_signals_5F00_ncs240.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>