<?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>PPI Configuration to Count Pulses</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/34547/ppi-configuration-to-count-pulses</link><description>I have been reading the nRF52840 product specification guide and find the PPI an interesting feature potential to use in my application. I&amp;#39;m would like if possible to connect an RTC and 2nd timer in count mode to be triggered by the same GPIO input. I</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 29 Nov 2021 06:43:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/34547/ppi-configuration-to-count-pulses" /><item><title>RE: PPI Configuration to Count Pulses</title><link>https://devzone.nordicsemi.com/thread/340986?ContentTypeID=1</link><pubDate>Mon, 29 Nov 2021 06:43:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cf536866-412a-4e8e-9f1c-296721c7ca03</guid><dc:creator>Senchoi</dc:creator><description>&lt;p&gt;would you give me some advice on &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/80654/good-way-to-measure-distance-between-two-falling-edges-on-one-input-pin"&gt;this thread&lt;/a&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PPI Configuration to Count Pulses</title><link>https://devzone.nordicsemi.com/thread/334120?ContentTypeID=1</link><pubDate>Thu, 14 Oct 2021 11:36:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b0a2de0-5314-419b-883e-da7a5809cc60</guid><dc:creator>Senchoi</dc:creator><description>&lt;p&gt;Can I ask a question about timer handler?&lt;/p&gt;
&lt;p&gt;i see when timer handler is used,&amp;nbsp;&lt;span&gt;nrf_drv_timer_extended_compare is getting used on pretty much every single example.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;But I don&amp;#39;t think I need this function for my project. does the timer handler run without this function?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What triggers timer handler?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;does it run constantly without trigger? if so that&amp;#39;s what I need at the moment.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PPI Configuration to Count Pulses</title><link>https://devzone.nordicsemi.com/thread/333858?ContentTypeID=1</link><pubDate>Wed, 13 Oct 2021 08:47:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51fb7f1f-1885-4bd7-9688-6bc9113483a9</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi, &lt;span&gt;in_pin_handler()&amp;nbsp;&lt;/span&gt;does nothing because there is no interrupts enabled for the input pin (second parameter to nrf_drv_gpiote_in_event_enable() set to false), so the handler will never be called. The code works as it is, by using HW resources like GPIOTE, PPI and TIMERs.&lt;/p&gt;
&lt;p&gt;When the input pin state changes from low to high, the GPIOTE peripheral will trigger an event, which will be sent over a PPI channel to trigger the COUNT task in one timer. A second timer is setup to read the count value of the first timer at a regular interval (defined by COUNT_READ_INTERVAL).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;To sum up, the second timer will read the number OF&amp;nbsp;&lt;em&gt;rising&amp;nbsp;&lt;/em&gt;flanks on the input pin in the past interval.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PPI Configuration to Count Pulses</title><link>https://devzone.nordicsemi.com/thread/333826?ContentTypeID=1</link><pubDate>Wed, 13 Oct 2021 06:11:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:13e93fb3-a71a-463b-b066-5825022e94c8</guid><dc:creator>Senchoi</dc:creator><description>&lt;p&gt;In the first example, why does in_pin_handler do nothing? does the code work as it is? and could you clarify whether it is counting the number OF falling flanks or the timer number AT falling flanks? It seems&amp;nbsp;nrf_drv_timer_capture_get returns captured value, which looks like it is returning the timer number AT falling flanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PPI Configuration to Count Pulses</title><link>https://devzone.nordicsemi.com/thread/208700?ContentTypeID=1</link><pubDate>Mon, 09 Sep 2019 13:12:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:21f60bc5-80c2-4ef0-8e9b-b2450364aa76</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Looks like you ar missing some config in your sdk_config.h file (possibly&amp;nbsp;TIMER1_ENABLED). How did you integrate it into the softdevice project? Which SDK version are you using?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PPI Configuration to Count Pulses</title><link>https://devzone.nordicsemi.com/thread/208018?ContentTypeID=1</link><pubDate>Wed, 04 Sep 2019 16:02:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e228025-ea0f-4595-9348-59081545a62a</guid><dc:creator>MPH</dc:creator><description>&lt;p&gt;Hi Jorgen&lt;/p&gt;
&lt;p&gt;Thanks for this example.&lt;/p&gt;
&lt;p&gt;This is pretty much what I need in my application but also to integrate with the softdevice. I&amp;nbsp;copied the code into my project but the compiler is unhappy as follows. Can you give me some clues on this error please?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;BR Martin&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/960x720/__key/communityserver-discussions-components-files/4/pastedimage1567613453223v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;Building ‘ble_app_blinky_pca10040_s132’ from solution ‘ble_app_blinky_pca10040_s132’ in configuration ‘Release’
  Compiling ‘main.c’
    nrfx.h
    nrf_gpio.h
    boards.h
    main.c
    &amp;#39;NRFX_TIMER1_INST_IDX&amp;#39; undeclared here (not in a function); did you mean &amp;#39;NRFX_TIMER_INSTANCE&amp;#39;?
    in definition of macro &amp;#39;NRFX_CONCAT_3_&amp;#39;
    in expansion of macro &amp;#39;NRFX_CONCAT_3&amp;#39;
    in expansion of macro &amp;#39;NRFX_TIMER_INSTANCE&amp;#39;
    in expansion of macro &amp;#39;NRF_DRV_TIMER_INSTANCE&amp;#39;
    &amp;#39;NRFX_TIMER2_INST_IDX&amp;#39; undeclared here (not in a function); did you mean &amp;#39;NRFX_TIMER_INSTANCE&amp;#39;?
    in definition of macro &amp;#39;NRFX_CONCAT_3_&amp;#39;
    in expansion of macro &amp;#39;NRFX_CONCAT_3&amp;#39;
    in expansion of macro &amp;#39;NRFX_TIMER_INSTANCE&amp;#39;
    in expansion of macro &amp;#39;NRF_DRV_TIMER_INSTANCE&amp;#39;
    initialization of &amp;#39;void (*)(uint8_t,  uint8_t)&amp;#39; {aka &amp;#39;void (*)(unsigned char,  unsigned char)&amp;#39;} from incompatible pointer type &amp;#39;void (*)(uint8_t,  uint8_t,  compound_type_t)&amp;#39; {aka &amp;#39;void (*)(unsigned char,  unsigned char,  struct &amp;lt;anonymous&amp;gt;)&amp;#39;} [-Wincompatible-pointer-types]
    (near initialization for &amp;#39;buttons[0].button_handler&amp;#39;)
    initialization of &amp;#39;void (*)(uint8_t,  uint8_t)&amp;#39; {aka &amp;#39;void (*)(unsigned char,  unsigned char)&amp;#39;} from incompatible pointer type &amp;#39;void (*)(uint8_t,  uint8_t,  compound_type_t)&amp;#39; {aka &amp;#39;void (*)(unsigned char,  unsigned char,  struct &amp;lt;anonymous&amp;gt;)&amp;#39;} [-Wincompatible-pointer-types]
    (near initialization for &amp;#39;buttons[1].button_handler&amp;#39;)
    initialization of &amp;#39;void (*)(uint8_t,  uint8_t)&amp;#39; {aka &amp;#39;void (*)(unsigned char,  unsigned char)&amp;#39;} from incompatible pointer type &amp;#39;void (*)(uint8_t,  uint8_t,  compound_type_t)&amp;#39; {aka &amp;#39;void (*)(unsigned char,  unsigned char,  struct &amp;lt;anonymous&amp;gt;)&amp;#39;} [-Wincompatible-pointer-types]
    (near initialization for &amp;#39;buttons[2].button_handler&amp;#39;)
    initialization of &amp;#39;void (*)(uint8_t,  uint8_t)&amp;#39; {aka &amp;#39;void (*)(unsigned char,  unsigned char)&amp;#39;} from incompatible pointer type &amp;#39;void (*)(uint8_t,  uint8_t,  compound_type_t)&amp;#39; {aka &amp;#39;void (*)(unsigned char,  unsigned char,  struct &amp;lt;anonymous&amp;gt;)&amp;#39;} [-Wincompatible-pointer-types]
    (near initialization for &amp;#39;buttons[3].button_handler&amp;#39;)
Build failed&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PPI Configuration to Count Pulses</title><link>https://devzone.nordicsemi.com/thread/133136?ContentTypeID=1</link><pubDate>Thu, 24 May 2018 07:17:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4722c4b2-e246-413a-908d-03525c3d6480</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I have attached two examples that should be usefull for implementing the behavior you want.&lt;/p&gt;
&lt;p&gt;The first example,&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-c773e2ef366a42d58b7dfb63d8276fc8/pin_5F00_rise_5F00_count_5F00_ppi_5F00_gpiote_5F00_timers.zip"&gt;devzone.nordicsemi.com/.../pin_5F00_rise_5F00_count_5F00_ppi_5F00_gpiote_5F00_timers.zip&lt;/a&gt;, shows how to count the number of falling flanks on a GPIO. One timer is used in count mode, while another timer is used in timer mode to capture and print the number counted by the first timer every 10 ms.&lt;/p&gt;
&lt;p&gt;The second example, &lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-c773e2ef366a42d58b7dfb63d8276fc8/second_5F00_count_5F00_ppi_5F00_rtc_5F00_timers.zip"&gt;devzone.nordicsemi.com/.../second_5F00_count_5F00_ppi_5F00_rtc_5F00_timers.zip&lt;/a&gt;, use a timer in count mode to count number of seconds. This example use a RTC to trigger the count task of the timer every 1 second.&lt;/p&gt;
&lt;p&gt;It should not be too big of a task to combine the functionality of these two examples into your own desired behavior.&lt;/p&gt;
&lt;p&gt;You should setup a GPIOTE interrupt on high to low change on the GPIO, and connect this to three TASKS (note that this might require multiple PPI channels): &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/rtc.html?cp=2_1_0_24_9#topic"&gt;RTC-&amp;gt;TASKS_START&lt;/a&gt; + &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/rtc.html?cp=2_1_0_24_9#topic"&gt;RTC-&amp;gt;TASKS_CLEAR&lt;/a&gt; + &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/timer.html?cp=2_1_0_23_4#topic"&gt;TIMER_TASKS_COUNT&lt;/a&gt;. Then you need to connect the event when the RTC times out (&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/rtc.html?cp=2_1_0_24_9#topic"&gt;RTC-&amp;gt;EVENTS_COMPARE[x]&lt;/a&gt;), to the capture task of the timer (&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/timer.html?cp=2_1_0_23_4#topic"&gt;TIMER-&amp;gt;TASKS_CAPTURE[x]&lt;/a&gt;). This will store the count value in &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/timer.html?cp=2_1_0_23_4_6#register.CC-0"&gt;TIMER-&amp;gt;CC[x]&lt;/a&gt;&amp;nbsp;register. If you setup the RTC to trigger an interrupt on the timeout, you can read back this captured count value from the timer and handle this further. Remember to clear the timer at this point, making it ready for next count task.&lt;/p&gt;
&lt;p&gt;Hope this helps wit implementing your feature!&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>