<?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>nRF52 Pulse Duration Counter for GPIO - The time between 2 consecutive rising edges</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/104077/nrf52-pulse-duration-counter-for-gpio---the-time-between-2-consecutive-rising-edges</link><description>Im trying to measure the time between 2 consecutive rising endges (Rising and Falling Edge together) on GPIO continuously but I did not find any leads. will appreciate the support.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 28 Sep 2023 12:25:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/104077/nrf52-pulse-duration-counter-for-gpio---the-time-between-2-consecutive-rising-edges" /><item><title>RE: nRF52 Pulse Duration Counter for GPIO - The time between 2 consecutive rising edges</title><link>https://devzone.nordicsemi.com/thread/448155?ContentTypeID=1</link><pubDate>Thu, 28 Sep 2023 12:25:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:42bec91b-2e9d-4417-b6a0-15170ac6814b</guid><dc:creator>Senchoi</dc:creator><description>&lt;p&gt;14ticks with 16MHz timer should do 875ns okay. Still not sure what kind of program you want to make. Would you summarize it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 Pulse Duration Counter for GPIO - The time between 2 consecutive rising edges</title><link>https://devzone.nordicsemi.com/thread/448116?ContentTypeID=1</link><pubDate>Thu, 28 Sep 2023 11:05:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97251d6b-5997-45f8-82c5-b9a3e2c8936e</guid><dc:creator>Khalil Ahmad</dc:creator><description>&lt;p&gt;yes im trying to make it work for 1 input on 1 gpio.&amp;nbsp;&lt;br /&gt;is it confirmed that I can&amp;#39;t get a 3 frequencies on 3 different GPIO&amp;#39;S ???&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 Pulse Duration Counter for GPIO - The time between 2 consecutive rising edges</title><link>https://devzone.nordicsemi.com/thread/448108?ContentTypeID=1</link><pubDate>Thu, 28 Sep 2023 10:10:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1a96c7a9-26e4-4690-b8f3-6a0642f43ebf</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I recommend you start with one input first to see if you can get it to work. You will not be able to sample a high-frequency input continuously or multiple inputs simultaneously anyway.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 Pulse Duration Counter for GPIO - The time between 2 consecutive rising edges</title><link>https://devzone.nordicsemi.com/thread/448098?ContentTypeID=1</link><pubDate>Thu, 28 Sep 2023 09:42:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cfe1855c-33c5-4312-9501-d83f84ac4283</guid><dc:creator>Khalil Ahmad</dc:creator><description>&lt;p&gt;I want to make an addition that I will measure 3 inputs on gpios. I was trying to test for 1, so that I will follow the same steps to implement for 3, but still trying to make it work for single. Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 Pulse Duration Counter for GPIO - The time between 2 consecutive rising edges</title><link>https://devzone.nordicsemi.com/thread/448097?ContentTypeID=1</link><pubDate>Thu, 28 Sep 2023 09:32:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:589b0f1e-9b0a-47a8-967e-3e1902196b2d</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Did you verify that you are feeding the input signal into the correct pin (SIG_INPUT_PIN)? You can also connect SIG_INPUT_PIN to SIG_OUT_PIN externally to measure the frequency of the generated output signal.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 Pulse Duration Counter for GPIO - The time between 2 consecutive rising edges</title><link>https://devzone.nordicsemi.com/thread/448094?ContentTypeID=1</link><pubDate>Thu, 28 Sep 2023 09:17:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:efae0c12-9d57-4c8f-ba83-72c4de0d08e5</guid><dc:creator>Khalil Ahmad</dc:creator><description>&lt;p&gt;Hi Vidar, Thanks for your reply and appreciate.&lt;/p&gt;
&lt;p&gt;I tried this code but not able to see any results on the com port.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;can you please help me to het it work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 Pulse Duration Counter for GPIO - The time between 2 consecutive rising edges</title><link>https://devzone.nordicsemi.com/thread/447895?ContentTypeID=1</link><pubDate>Wed, 27 Sep 2023 09:18:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:330516fb-f1ea-4e08-b69a-dcc9e518eae2</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You may try this code instead:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 *
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 *
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 *
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */

#include &amp;lt;stdint.h&amp;gt;

#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;boards.h&amp;quot;

#include &amp;quot;nrf_drv_ppi.h&amp;quot;
#include &amp;quot;nrf_drv_timer.h&amp;quot;
#include &amp;quot;nrf_drv_gpiote.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;

#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;


/* Signal generator output */
#define SIG_OUT_PIN             26
#define SIG_OUT_INTERVAL_US     1

#define SIG_INPUT_PIN     27


static const nrf_drv_timer_t m_timer1 = NRF_DRV_TIMER_INSTANCE(1);
static const nrf_drv_timer_t m_timer2 = NRF_DRV_TIMER_INSTANCE(2);
static const nrf_drv_timer_t m_timer3 = NRF_DRV_TIMER_INSTANCE(3);

static volatile bool m_sample_pending;

/* Timer event handler. Not used since Timer1 and Timer2 are used only for PPI. */
static void empty_timer_handler(nrf_timer_event_t event_type, void * p_context)
{
}

static void signal_capture_handler(nrf_timer_event_t event_type, void * p_context)
{
    uint32_t err_code;
    uint32_t timer_ticks;

    timer_ticks = nrf_drv_timer_capture(&amp;amp;m_timer3, NRF_TIMER_CC_CHANNEL0);

    NRF_LOG_INFO(&amp;quot;Signal period: &amp;quot; NRF_LOG_FLOAT_MARKER &amp;quot; us&amp;quot;, NRF_LOG_FLOAT((float)timer_ticks/16.0f));

    nrf_drv_timer_clear(&amp;amp;m_timer3);
    nrf_drv_timer_clear(&amp;amp;m_timer2);
    m_sample_pending = false;
    nrf_drv_gpiote_in_event_disable(SIG_INPUT_PIN);
}

void in_pin_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{

}


static void log_init(void)
{
    uint32_t err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();
}

static void hf_clock_start(void)
{
    /* Start HFXO for better accuracy */
    NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1;
    while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0)
      {};
}

static void signal_generator_start(void)
{
    uint32_t err_code; 
    uint32_t out_task_addr;
    uint32_t timer_evt0_addr;
    nrf_ppi_channel_t ppi_channel;
    

    nrf_drv_gpiote_out_config_t signal_out = GPIOTE_CONFIG_OUT_TASK_TOGGLE(true);
    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;

    /* Configure timer and output signal */
    err_code = nrf_drv_timer_init(&amp;amp;m_timer1, &amp;amp;timer_cfg, empty_timer_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_timer_extended_compare(&amp;amp;m_timer1,
                                   NRF_TIMER_CC_CHANNEL0,
                                   nrfx_timer_us_to_ticks(&amp;amp;m_timer1, SIG_OUT_INTERVAL_US),
                                   NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK,
                                   false);

    timer_evt0_addr = nrf_drv_timer_compare_event_address_get(&amp;amp;m_timer1,NRF_TIMER_CC_CHANNEL0);

    /* Configure GPIOTE task */
    err_code = nrf_drv_gpiote_out_init(SIG_OUT_PIN, &amp;amp;signal_out);
    APP_ERROR_CHECK(err_code);

    out_task_addr = nrf_drv_gpiote_out_task_addr_get(SIG_OUT_PIN);

    nrf_drv_gpiote_out_task_enable(SIG_OUT_PIN);
    
    /* Connect timer event to GPIOTE task through PPI */
    err_code = nrf_drv_ppi_channel_alloc(&amp;amp;ppi_channel);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_ppi_channel_assign(ppi_channel, timer_evt0_addr, out_task_addr);
    APP_ERROR_CHECK(err_code);

    nrf_drv_ppi_channel_enable(ppi_channel); 
        
    /* Start signal generation */
    nrf_drv_timer_enable(&amp;amp;m_timer1);                    
}

static void signal_input_sampling_init(void)
{
    uint32_t err_code;
    nrf_ppi_channel_t ppi_channel;
    uint32_t gpiote_evt_addr;
    uint32_t count_task_addr;
    uint32_t timer_start_addr;
    uint32_t timer_stop_addr;
    uint32_t timer_evt0_addr;
    uint32_t timer_evt1_addr;

    nrf_drv_gpiote_in_config_t input_config = GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;

    err_code = nrf_drv_gpiote_in_init(SIG_INPUT_PIN, &amp;amp;input_config, in_pin_handler);
    APP_ERROR_CHECK(err_code);

    gpiote_evt_addr = nrf_drv_gpiote_in_event_addr_get(SIG_INPUT_PIN);

    timer_cfg.mode = NRF_TIMER_MODE_COUNTER;

    err_code = nrf_drv_timer_init(&amp;amp;m_timer2, &amp;amp;timer_cfg, signal_capture_handler);
    APP_ERROR_CHECK(err_code);
    
    nrf_drv_timer_compare(&amp;amp;m_timer2,
                          NRF_TIMER_CC_CHANNEL0,
                          1,
                          false);
   
    nrf_drv_timer_compare(&amp;amp;m_timer2,
                          NRF_TIMER_CC_CHANNEL1,
                          2,
                          true);

    count_task_addr = nrf_drv_timer_task_address_get(&amp;amp;m_timer2, NRF_TIMER_TASK_COUNT);
    timer_evt0_addr = nrf_drv_timer_compare_event_address_get(&amp;amp;m_timer2, NRF_TIMER_CC_CHANNEL0);
    timer_evt1_addr = nrf_drv_timer_compare_event_address_get(&amp;amp;m_timer2, NRF_TIMER_CC_CHANNEL1);
    
    nrf_drv_timer_enable(&amp;amp;m_timer2);

    timer_cfg.mode = NRF_TIMER_MODE_TIMER;

    err_code = nrf_drv_timer_init(&amp;amp;m_timer3, &amp;amp;timer_cfg, empty_timer_handler);
    APP_ERROR_CHECK(err_code);

    timer_start_addr = nrf_drv_timer_task_address_get(&amp;amp;m_timer3, NRF_TIMER_TASK_START);
    timer_stop_addr  = nrf_drv_timer_task_address_get(&amp;amp;m_timer3, NRF_TIMER_TASK_STOP);

    err_code = nrf_drv_ppi_channel_alloc(&amp;amp;ppi_channel);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_ppi_channel_assign(ppi_channel, gpiote_evt_addr, count_task_addr);
    APP_ERROR_CHECK(err_code);

    nrf_drv_ppi_channel_enable(ppi_channel); 

    err_code = nrf_drv_ppi_channel_alloc(&amp;amp;ppi_channel);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_ppi_channel_assign(ppi_channel, timer_evt0_addr, timer_start_addr);
    APP_ERROR_CHECK(err_code);

    nrf_drv_ppi_channel_enable(ppi_channel); 

    err_code = nrf_drv_ppi_channel_alloc(&amp;amp;ppi_channel);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_ppi_channel_assign(ppi_channel, timer_evt1_addr, timer_stop_addr);
    APP_ERROR_CHECK(err_code);

    nrf_drv_ppi_channel_enable(ppi_channel); 
}

static void ppi_init(void)
{
    uint32_t err_code = nrf_drv_ppi_init();
    APP_ERROR_CHECK(err_code);
}

static void gpiote_init(void)
{
    uint32_t err_code = nrf_drv_gpiote_init();
    APP_ERROR_CHECK(err_code);
}

static void signal_input_sample(void)
{
    if (!m_sample_pending)
    {
        nrf_drv_gpiote_in_event_enable(SIG_INPUT_PIN, false);
        m_sample_pending = true;
    }
}
/**
 * @brief Function for application main entry.
 */
void main(void)
{
    hf_clock_start();
    log_init();

    ppi_init();
    gpiote_init();

    signal_generator_start();
    signal_input_sampling_init();

    while (true)
    {
        if (NRF_LOG_PROCESS() == false)
        {
            //__WFE();
            signal_input_sample();
            nrf_delay_ms(1000);

        }
    }
}

/** @} */&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 Pulse Duration Counter for GPIO - The time between 2 consecutive rising edges</title><link>https://devzone.nordicsemi.com/thread/447475?ContentTypeID=1</link><pubDate>Mon, 25 Sep 2023 12:11:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e0be525e-5e0c-4060-b8e8-9b048902eec6</guid><dc:creator>Khalil Ahmad</dc:creator><description>&lt;p&gt;The reson behind to start tick/measure when half edge reached to ignore the smal edges of the noise.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 Pulse Duration Counter for GPIO - The time between 2 consecutive rising edges</title><link>https://devzone.nordicsemi.com/thread/447474?ContentTypeID=1</link><pubDate>Mon, 25 Sep 2023 12:09:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2abb2d2f-7c23-4558-86bd-b3c3bb191e01</guid><dc:creator>Khalil Ahmad</dc:creator><description>&lt;p&gt;&lt;span&gt;I changed the frequency from 31250Hz to 16MHz, but resolution did not get affected. Please check the code and guide me.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 Pulse Duration Counter for GPIO - The time between 2 consecutive rising edges</title><link>https://devzone.nordicsemi.com/thread/447472?ContentTypeID=1</link><pubDate>Mon, 25 Sep 2023 12:07:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:980f8a58-8c1c-44c1-b21f-aaa71aab817e</guid><dc:creator>Khalil Ahmad</dc:creator><description>&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/WhatsApp-Image-2023_2D00_09_2D00_25-at-14.55.55.jpg" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;This what i want to measure. if im able to get t1,t2,t3....... then I can measure the T and Frequency of the signal also. The main goal is to measure the frequency of the input signal at GPIO.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 Pulse Duration Counter for GPIO - The time between 2 consecutive rising edges</title><link>https://devzone.nordicsemi.com/thread/447470?ContentTypeID=1</link><pubDate>Mon, 25 Sep 2023 12:02:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d56bf6e9-ee94-4ef1-bcff-4b93c94f8876</guid><dc:creator>Khalil Ahmad</dc:creator><description>&lt;p&gt;Yes, then I will try to start from 875ns.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 Pulse Duration Counter for GPIO - The time between 2 consecutive rising edges</title><link>https://devzone.nordicsemi.com/thread/447467?ContentTypeID=1</link><pubDate>Mon, 25 Sep 2023 12:01:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c0997023-e8bb-4781-931a-6a42b4531ffd</guid><dc:creator>Khalil Ahmad</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;stdint.h&amp;gt;

#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;

#include &amp;quot;nrf_drv_ppi.h&amp;quot;
#include &amp;quot;nrf_drv_timer.h&amp;quot;

#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;
//nrf_drv_timer_us_to_ticks
#define PPI_EXAMPLE_TIMERS_us_PHASE_SHIFT_DELAY    (1)    // 1s = 10 * 100ms (Timer 0 interrupt)
#define PPI_EXAMPLE_TIMER0_us_INTERVAL             (1)   // Timer interval in milliseconds
#define PPI_EXAMPLE_TIMER1_us_INTERVAL             (1)  // Timer interval in milliseconds
#define PPI_EXAMPLE_TIMER2_us_INTERVAL             (1)  // Timer interval in milliseconds


static const nrf_drv_timer_t m_timer0 = NRF_DRV_TIMER_INSTANCE(0);
static const nrf_drv_timer_t m_timer1 = NRF_DRV_TIMER_INSTANCE(1);
static const nrf_drv_timer_t m_timer2 = NRF_DRV_TIMER_INSTANCE(2);

static nrf_ppi_channel_t m_ppi_channel1;
static nrf_ppi_channel_t m_ppi_channel2;

static volatile uint32_t m_counter;

static void timer0_event_handler(nrf_timer_event_t event_type, void * p_context)
{
    ++m_counter;
}

/* Timer event handler. Not used since Timer1 and Timer2 are used only for PPI. */
static void empty_timer_handler(nrf_timer_event_t event_type, void * p_context)
{
}


/** @brief Function for initializing the PPI peripheral.
*/
static void ppi_init(void)
{
    uint32_t err_code = NRF_SUCCESS;

    err_code = nrf_drv_ppi_init();
    APP_ERROR_CHECK(err_code);

    /* Configure 1st available PPI channel to stop TIMER0 counter on TIMER1 COMPARE[0] match,
     * which is every even number of seconds.
     */
    err_code = nrf_drv_ppi_channel_alloc(&amp;amp;m_ppi_channel1);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_ppi_channel_assign(m_ppi_channel1,
                                          nrf_drv_timer_event_address_get(&amp;amp;m_timer1,
                                                                          NRF_TIMER_EVENT_COMPARE0),
                                          nrf_drv_timer_task_address_get(&amp;amp;m_timer0,
                                                                         NRF_TIMER_TASK_STOP));
    APP_ERROR_CHECK(err_code);

    /* Configure 2nd available PPI channel to start TIMER0 counter at TIMER2 COMPARE[0] match,
     * which is every odd number of seconds.
     */
    err_code = nrf_drv_ppi_channel_alloc(&amp;amp;m_ppi_channel2);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_ppi_channel_assign(m_ppi_channel2,
                                          nrf_drv_timer_event_address_get(&amp;amp;m_timer2,
                                                                          NRF_TIMER_EVENT_COMPARE0),
                                          nrf_drv_timer_task_address_get(&amp;amp;m_timer0,
                                                                         NRF_TIMER_TASK_START));
    APP_ERROR_CHECK(err_code);

    // Enable both configured PPI channels
    err_code = nrf_drv_ppi_channel_enable(m_ppi_channel1);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_ppi_channel_enable(m_ppi_channel2);
    APP_ERROR_CHECK(err_code);
}


/** @brief Function for Timer 0 initialization.
 *  @details Timer 0 will be stopped and started by Timer 1 and Timer 2 respectively using PPI.
 *           It is configured to generate an interrupt every 100ms.
 */
static void timer0_init(void)
{
    // Check TIMER0 configuration for details.
    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
    timer_cfg.frequency = NRF_TIMER_FREQ_16MHz;
    ret_code_t err_code = nrf_drv_timer_init(&amp;amp;m_timer0, &amp;amp;timer_cfg, timer0_event_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_timer_extended_compare(&amp;amp;m_timer0,
                                   NRF_TIMER_CC_CHANNEL0,
                                   nrf_drv_timer_ms_to_ticks(&amp;amp;m_timer0,
                                                             PPI_EXAMPLE_TIMER0_us_INTERVAL),
                                   NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK,
                                   true);
}

/** @brief Function for Timer 1 initialization.
 *  @details Initializes TIMER1 peripheral to generate an event every 2 seconds. The events are
 *           generated at even numbers of seconds after starting the example (2, 4, 6 ...) and they
 *           are used to stop TIMER0 via PPI: TIMER1-&amp;gt;EVENT_COMPARE[0] triggers TIMER0-&amp;gt;TASK_STOP.
 */
static void timer1_init(void)
{
    // Check TIMER1 configuration for details.
    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
    timer_cfg.frequency = NRF_TIMER_FREQ_16MHz;
    ret_code_t err_code = nrf_drv_timer_init(&amp;amp;m_timer1, &amp;amp;timer_cfg, empty_timer_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_timer_extended_compare(&amp;amp;m_timer1,
                                   NRF_TIMER_CC_CHANNEL0,
                                   nrf_drv_timer_ms_to_ticks(&amp;amp;m_timer1,
                                                             PPI_EXAMPLE_TIMER1_us_INTERVAL),
                                   NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK,
                                   false);
}


/** @brief Function for Timer 2 initialization.
 *  @details Initializes TIMER2 peripheral to generate an event every 2 seconds. The events are
 *           generated at odd numbers of seconds after starting the example (3, 5, 7 ...) and they
 *           are used to start TIMER0 via PPI: TIMER2-&amp;gt;EVENT_COMPARE[0] triggers TIMER0-&amp;gt;TASK_START.
 */
static void timer2_init(void)
{
    // Check TIMER2 configuration for details.
    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
    timer_cfg.frequency = NRF_TIMER_FREQ_16MHz;
    ret_code_t err_code = nrf_drv_timer_init(&amp;amp;m_timer2, &amp;amp;timer_cfg, empty_timer_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_timer_extended_compare(&amp;amp;m_timer2,
                                   NRF_TIMER_CC_CHANNEL0,
                                   nrf_drv_timer_ms_to_ticks(&amp;amp;m_timer2,
                                                             PPI_EXAMPLE_TIMER2_us_INTERVAL),
                                   NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK,
                                   false);
}

/**
 * @brief Function for application main entry.
 */
int main(void)
{
    uint32_t old_val = 0;
    uint32_t err_code;

    err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();

    ppi_init();
    timer0_init(); // Timer used to increase m_counter every 100ms.
    timer1_init(); // Timer to generate events on even number of seconds - stopping Timer 0
    timer2_init(); // Timer to generate events on odd number of seconds - starting Timer 0

    NRF_LOG_INFO(&amp;quot;PPI example started.&amp;quot;);

    // Start clock.
    nrf_drv_timer_enable(&amp;amp;m_timer0);

    /* Below delay is implemented to ensure that Timer0 interrupt will execute before PPI action.
     * Please be aware that such solution was tested only in this simple example code. In case
     * of more complex systems with higher level interrupts this may lead to not correct timers
     * synchronization.
     */
    nrf_delay_us(1);
    nrf_drv_timer_enable(&amp;amp;m_timer1);

    m_counter = (uint32_t)-PPI_EXAMPLE_TIMERS_us_PHASE_SHIFT_DELAY;

    // Timer 2 will start one second after Timer 1 (m_counter will equal 0 after 1s)
 //   while (m_counter != 0) 
   // {
        // just wait
    //}
    nrf_drv_timer_enable(&amp;amp;m_timer2);

    while (true)
    {
        uint32_t counter = m_counter;
        if (old_val != counter)
        {
            old_val = counter;

            NRF_LOG_INFO(&amp;quot;Current count: %u&amp;quot;, counter);
            NRF_LOG_FLUSH();
        }
    }
}

/** @} */
#include &amp;lt;stdint.h&amp;gt;

#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;

#include &amp;quot;nrf_drv_ppi.h&amp;quot;
#include &amp;quot;nrf_drv_timer.h&amp;quot;

#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;
//nrf_drv_timer_us_to_ticks
#define PPI_EXAMPLE_TIMERS_us_PHASE_SHIFT_DELAY    (1)    // 1s = 10 * 100ms (Timer 0 interrupt)
#define PPI_EXAMPLE_TIMER0_us_INTERVAL             (1)   // Timer interval in milliseconds
#define PPI_EXAMPLE_TIMER1_us_INTERVAL             (1)  // Timer interval in milliseconds
#define PPI_EXAMPLE_TIMER2_us_INTERVAL             (1)  // Timer interval in milliseconds


static const nrf_drv_timer_t m_timer0 = NRF_DRV_TIMER_INSTANCE(0);
static const nrf_drv_timer_t m_timer1 = NRF_DRV_TIMER_INSTANCE(1);
static const nrf_drv_timer_t m_timer2 = NRF_DRV_TIMER_INSTANCE(2);

static nrf_ppi_channel_t m_ppi_channel1;
static nrf_ppi_channel_t m_ppi_channel2;

static volatile uint32_t m_counter;

static void timer0_event_handler(nrf_timer_event_t event_type, void * p_context)
{
    ++m_counter;
}

/* Timer event handler. Not used since Timer1 and Timer2 are used only for PPI. */
static void empty_timer_handler(nrf_timer_event_t event_type, void * p_context)
{
}


/** @brief Function for initializing the PPI peripheral.
*/
static void ppi_init(void)
{
    uint32_t err_code = NRF_SUCCESS;

    err_code = nrf_drv_ppi_init();
    APP_ERROR_CHECK(err_code);

    /* Configure 1st available PPI channel to stop TIMER0 counter on TIMER1 COMPARE[0] match,
     * which is every even number of seconds.
     */
    err_code = nrf_drv_ppi_channel_alloc(&amp;amp;m_ppi_channel1);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_ppi_channel_assign(m_ppi_channel1,
                                          nrf_drv_timer_event_address_get(&amp;amp;m_timer1,
                                                                          NRF_TIMER_EVENT_COMPARE0),
                                          nrf_drv_timer_task_address_get(&amp;amp;m_timer0,
                                                                         NRF_TIMER_TASK_STOP));
    APP_ERROR_CHECK(err_code);

    /* Configure 2nd available PPI channel to start TIMER0 counter at TIMER2 COMPARE[0] match,
     * which is every odd number of seconds.
     */
    err_code = nrf_drv_ppi_channel_alloc(&amp;amp;m_ppi_channel2);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_ppi_channel_assign(m_ppi_channel2,
                                          nrf_drv_timer_event_address_get(&amp;amp;m_timer2,
                                                                          NRF_TIMER_EVENT_COMPARE0),
                                          nrf_drv_timer_task_address_get(&amp;amp;m_timer0,
                                                                         NRF_TIMER_TASK_START));
    APP_ERROR_CHECK(err_code);

    // Enable both configured PPI channels
    err_code = nrf_drv_ppi_channel_enable(m_ppi_channel1);
    APP_ERROR_CHECK(err_code);
    err_code = nrf_drv_ppi_channel_enable(m_ppi_channel2);
    APP_ERROR_CHECK(err_code);
}


/** @brief Function for Timer 0 initialization.
 *  @details Timer 0 will be stopped and started by Timer 1 and Timer 2 respectively using PPI.
 *           It is configured to generate an interrupt every 100ms.
 */
static void timer0_init(void)
{
    // Check TIMER0 configuration for details.
    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
    timer_cfg.frequency = NRF_TIMER_FREQ_16MHz;
    ret_code_t err_code = nrf_drv_timer_init(&amp;amp;m_timer0, &amp;amp;timer_cfg, timer0_event_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_timer_extended_compare(&amp;amp;m_timer0,
                                   NRF_TIMER_CC_CHANNEL0,
                                   nrf_drv_timer_ms_to_ticks(&amp;amp;m_timer0,
                                                             PPI_EXAMPLE_TIMER0_us_INTERVAL),
                                   NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK,
                                   true);
}

/** @brief Function for Timer 1 initialization.
 *  @details Initializes TIMER1 peripheral to generate an event every 2 seconds. The events are
 *           generated at even numbers of seconds after starting the example (2, 4, 6 ...) and they
 *           are used to stop TIMER0 via PPI: TIMER1-&amp;gt;EVENT_COMPARE[0] triggers TIMER0-&amp;gt;TASK_STOP.
 */
static void timer1_init(void)
{
    // Check TIMER1 configuration for details.
    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
    timer_cfg.frequency = NRF_TIMER_FREQ_16MHz;
    ret_code_t err_code = nrf_drv_timer_init(&amp;amp;m_timer1, &amp;amp;timer_cfg, empty_timer_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_timer_extended_compare(&amp;amp;m_timer1,
                                   NRF_TIMER_CC_CHANNEL0,
                                   nrf_drv_timer_ms_to_ticks(&amp;amp;m_timer1,
                                                             PPI_EXAMPLE_TIMER1_us_INTERVAL),
                                   NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK,
                                   false);
}


/** @brief Function for Timer 2 initialization.
 *  @details Initializes TIMER2 peripheral to generate an event every 2 seconds. The events are
 *           generated at odd numbers of seconds after starting the example (3, 5, 7 ...) and they
 *           are used to start TIMER0 via PPI: TIMER2-&amp;gt;EVENT_COMPARE[0] triggers TIMER0-&amp;gt;TASK_START.
 */
static void timer2_init(void)
{
    // Check TIMER2 configuration for details.
    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
    timer_cfg.frequency = NRF_TIMER_FREQ_16MHz;
    ret_code_t err_code = nrf_drv_timer_init(&amp;amp;m_timer2, &amp;amp;timer_cfg, empty_timer_handler);
    APP_ERROR_CHECK(err_code);

    nrf_drv_timer_extended_compare(&amp;amp;m_timer2,
                                   NRF_TIMER_CC_CHANNEL0,
                                   nrf_drv_timer_ms_to_ticks(&amp;amp;m_timer2,
                                                             PPI_EXAMPLE_TIMER2_us_INTERVAL),
                                   NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK,
                                   false);
}

/**
 * @brief Function for application main entry.
 */
int main(void)
{
    uint32_t old_val = 0;
    uint32_t err_code;

    err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();

    ppi_init();
    timer0_init(); // Timer used to increase m_counter every 100ms.
    timer1_init(); // Timer to generate events on even number of seconds - stopping Timer 0
    timer2_init(); // Timer to generate events on odd number of seconds - starting Timer 0

    NRF_LOG_INFO(&amp;quot;PPI example started.&amp;quot;);

    // Start clock.
    nrf_drv_timer_enable(&amp;amp;m_timer0);

    /* Below delay is implemented to ensure that Timer0 interrupt will execute before PPI action.
     * Please be aware that such solution was tested only in this simple example code. In case
     * of more complex systems with higher level interrupts this may lead to not correct timers
     * synchronization.
     */
    nrf_delay_us(1);
    nrf_drv_timer_enable(&amp;amp;m_timer1);

    m_counter = (uint32_t)-PPI_EXAMPLE_TIMERS_us_PHASE_SHIFT_DELAY;

    // Timer 2 will start one second after Timer 1 (m_counter will equal 0 after 1s)
 //   while (m_counter != 0) 
   // {
        // just wait
    //}
    nrf_drv_timer_enable(&amp;amp;m_timer2);

    while (true)
    {
        uint32_t counter = m_counter;
        if (old_val != counter)
        {
            old_val = counter;

            NRF_LOG_INFO(&amp;quot;Current count: %u&amp;quot;, counter);
            NRF_LOG_FLUSH();
        }
    }
}

/** @} */
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I changed the frequency from 31250Hz to 16MHz, but resolution did not get affected. The one more thing I did not uses LFCLK (crystal) as this was the optional for custom board.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 Pulse Duration Counter for GPIO - The time between 2 consecutive rising edges</title><link>https://devzone.nordicsemi.com/thread/447433?ContentTypeID=1</link><pubDate>Mon, 25 Sep 2023 10:45:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:992469d2-d185-4776-bb6a-1eee278c0e91</guid><dc:creator>Senchoi</dc:creator><description>&lt;p&gt;If you&amp;rsquo;re trying to detect message signals, I suggest you to look into UART or other protocols. GPIOTE and PPI and TIMER operations are for really simple purposes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 Pulse Duration Counter for GPIO - The time between 2 consecutive rising edges</title><link>https://devzone.nordicsemi.com/thread/447432?ContentTypeID=1</link><pubDate>Mon, 25 Sep 2023 10:35:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c495791-c996-443f-a504-c0ec0c722b21</guid><dc:creator>Senchoi</dc:creator><description>&lt;p&gt;I haven&amp;rsquo;t tried half tall edges accurately but in my vague experience, it doesn&amp;rsquo;t pick up that half tall edges very well. I don&amp;rsquo;t think there&amp;rsquo;s an option to pick up such signal well. So my suggestion for detecting such is to use saadc although it may get complicated.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 Pulse Duration Counter for GPIO - The time between 2 consecutive rising edges</title><link>https://devzone.nordicsemi.com/thread/447429?ContentTypeID=1</link><pubDate>Mon, 25 Sep 2023 10:22:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0496340f-83b2-4fbf-8477-57f497ec9853</guid><dc:creator>Senchoi</dc:creator><description>&lt;p&gt;You can&amp;rsquo;t measure 900ns exactly in 16MHz timer. One tick is 62.5ns. You can only measure 875ns or 937.5ns.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 Pulse Duration Counter for GPIO - The time between 2 consecutive rising edges</title><link>https://devzone.nordicsemi.com/thread/447419?ContentTypeID=1</link><pubDate>Mon, 25 Sep 2023 09:47:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6fd1d6cb-bee2-4c19-84f7-043a006003ee</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;The resolution will be limited by the frequency your TIMER is running at. Can you post the code you&amp;#39;re using for test?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 Pulse Duration Counter for GPIO - The time between 2 consecutive rising edges</title><link>https://devzone.nordicsemi.com/thread/447399?ContentTypeID=1</link><pubDate>Mon, 25 Sep 2023 09:11:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:767e28b3-4be7-4125-aeb3-2c96cb805812</guid><dc:creator>Khalil Ahmad</dc:creator><description>&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1695632993967v1.png" alt=" " /&gt;after implementing the ppi example I start getting these values. But these values are in ms. How can I increase to nano seconds only the output so that i can capture upto 900 nano seconds&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 Pulse Duration Counter for GPIO - The time between 2 consecutive rising edges</title><link>https://devzone.nordicsemi.com/thread/447389?ContentTypeID=1</link><pubDate>Mon, 25 Sep 2023 08:35:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb50c6f0-dcd7-4145-ae71-b9d9a94f813f</guid><dc:creator>Khalil Ahmad</dc:creator><description>[quote userid="103143" url="~/f/nordic-q-a/104077/nrf52-pulse-duration-counter-for-gpio---the-time-between-2-consecutive-rising-edges/447336"]&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;Yes, Im trying to use PPI+GPIOTE to capture the signal period. But i cant get the values in nanoseconds as my requirements are 900ns.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 Pulse Duration Counter for GPIO - The time between 2 consecutive rising edges</title><link>https://devzone.nordicsemi.com/thread/447388?ContentTypeID=1</link><pubDate>Mon, 25 Sep 2023 08:31:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ceeb620-d4d0-43ba-a402-51a9ea2400d0</guid><dc:creator>Khalil Ahmad</dc:creator><description>[quote userid="103143" url="~/f/nordic-q-a/104077/nrf52-pulse-duration-counter-for-gpio---the-time-between-2-consecutive-rising-edges/447336"]&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;[/quote]
&lt;p&gt;Actually I need to measure the time period of the signal (which can start from one rising/falling edge to the next rising/falling edge). in other words i need to measure rising+falling edge and then add both of them. the consecutive means this operation should be carried out untill the last input signal at GPIO present. Actually Im measuring the signal from my other application by using nrf52840 and sending through BLE.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 Pulse Duration Counter for GPIO - The time between 2 consecutive rising edges</title><link>https://devzone.nordicsemi.com/thread/447385?ContentTypeID=1</link><pubDate>Mon, 25 Sep 2023 08:26:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75c0be75-0f4e-445b-8d03-a7c905fc8b90</guid><dc:creator>Khalil Ahmad</dc:creator><description>&lt;p&gt;Dear Senchoi, Thanks for the reply. I also read your other threads regarding this. Actually I have 2 requirements for my application,&lt;/p&gt;
&lt;p&gt;1 - I need to measure the 900ns pulse period (consecutive rising to rising/consecutive falling to falling edges).&lt;/p&gt;
&lt;p&gt;2 - The rising or falling edge should be captured from the 1.65V (if the input signal is 3.3V). below 1.65v (either rising or falling should be ignored because of noise signals)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52 Pulse Duration Counter for GPIO - The time between 2 consecutive rising edges</title><link>https://devzone.nordicsemi.com/thread/447336?ContentTypeID=1</link><pubDate>Mon, 25 Sep 2023 05:17:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2bbf1e10-40b7-4494-95d6-fddf56f9a40f</guid><dc:creator>Senchoi</dc:creator><description>&lt;p&gt;I&amp;#39;m not sure how accurate the measurement has to be. you have&amp;nbsp; a 16MHz option and 32768Hz option. the latter is low power timer(RTC)&lt;br /&gt;&lt;br /&gt;If you want the absolutely punctual timing of the measurement, you also need to use PPI to connect GPIOTE actions and reading the TIMER value.&lt;/p&gt;
&lt;p&gt;The sample code you can look at are the &lt;a href="https://www.nordicsemi.com/Products/Development-software/nrf5-sdk/download"&gt;provided SDK&lt;/a&gt;&amp;#39;s example/peripheral/ppi &lt;span&gt;and&amp;nbsp;&lt;/span&gt;&lt;span&gt;example/peripheral/&lt;/span&gt;&lt;span&gt;gpiote&amp;nbsp;and&amp;nbsp;example/peripheral/timer&lt;/span&gt;.&lt;/p&gt;
&lt;p&gt;Codes are pretty much self explanatory. If you follow the steps written in sample codes,&amp;nbsp; I&amp;#39;m pretty sure you can make up stuff on your own.&lt;/p&gt;
&lt;p&gt;Also&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fstruct_sdk%2Fstruct%2Fsdk_nrf5_latest.html"&gt;infocenter&lt;/a&gt;&amp;nbsp;can help you a a lot on substituting valid codes in your liking.&lt;/p&gt;
&lt;p&gt;A few things you have to know are,&lt;/p&gt;
&lt;p&gt;1. PPI can link the edge actions(GPIOTE) to the action of reading the timer value(TIMER).&lt;/p&gt;
&lt;p&gt;2. PPI can link two actions per channel and action options are in the infocenter or you can right click the codes to go to definitions within IDE to look through options.&lt;/p&gt;
&lt;p&gt;3. If you have to measure really short amount of time less then 1ms, you have to use TIMER instead of RTC.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m sorry to tell you the very little of developing your program but these are pretty much the essence that I can think of.&lt;/p&gt;
&lt;p&gt;When you use PPI, you can link GPIOTE action, a rising action, to two actions of measuring the TIMER value and clearing the TIMER value.&lt;/p&gt;
&lt;p&gt;Then captured value can be&amp;nbsp;obtained with&amp;nbsp;nrfx_timer_capture_get() function and that&amp;#39;s the pulse duration you need. just a caveat: the program doesn&amp;#39;t know which 2 consecutive pulses to measure.&lt;/p&gt;
&lt;p&gt;I guess this way can make the program that you need.&lt;/p&gt;
&lt;p&gt;But I would need more details of your program to help you further.&lt;/p&gt;
&lt;p&gt;Say,&amp;nbsp; what do you mean by &amp;#39;contiuously&amp;#39;? do those pulses have regular intervals? How long is the interval?&lt;/p&gt;
&lt;p&gt;How accurate does the time have to be?&lt;/p&gt;
&lt;p&gt;I guess I can share my code to you. This peripheral code is using 2 TIMERs one for regularly capturing measured TIMER value done by the other TIMER. it creates 10 samples to send them through BLE in every 100ms(10ms per sample).&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/5658.main.c"&gt;devzone.nordicsemi.com/.../5658.main.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Notice it is measuring 2 consecutive falling edges using&amp;nbsp;GPIOTE_CONFIG_IN_SENSE_HITOLO(true); You would need to change it to LOTOHI. But obviously i don&amp;#39;t think you can modify the code above to suit your needs. That program was used for other purpose for my own project.&lt;/p&gt;
&lt;p&gt;Good luck.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>