<?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>Measuring elapsed microseconds between 12 successive rising edges on 12 GPIOS on NRF52832 DK</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/25856/measuring-elapsed-microseconds-between-12-successive-rising-edges-on-12-gpios-on-nrf52832-dk</link><description>Hi everyone, 
 I&amp;#39;m new with nrf52832, and I need to measure elapsed time in microsecond between rising edges of 12 different Gpios. I have 12 piezoelectric sensors filtered, amplified, getting a 0V-3.3V Logic level in input. Once one of these senors</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 23 Oct 2017 10:42:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/25856/measuring-elapsed-microseconds-between-12-successive-rising-edges-on-12-gpios-on-nrf52832-dk" /><item><title>RE: Measuring elapsed microseconds between 12 successive rising edges on 12 GPIOS on NRF52832 DK</title><link>https://devzone.nordicsemi.com/thread/101856?ContentTypeID=1</link><pubDate>Mon, 23 Oct 2017 10:42:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f8f4e8f2-dead-45e8-b360-ba03db34ae38</guid><dc:creator>Krzysztof Zaraska</dc:creator><description>&lt;p&gt;Number of pin you want to set/clear on timer event. This was copied from a larger project so some defines may be missing.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Measuring elapsed microseconds between 12 successive rising edges on 12 GPIOS on NRF52832 DK</title><link>https://devzone.nordicsemi.com/thread/101855?ContentTypeID=1</link><pubDate>Sun, 22 Oct 2017 13:02:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e91114bc-5f8d-4a37-b216-d271ddedc885</guid><dc:creator>rusger</dc:creator><description>&lt;p&gt;What is &lt;code&gt;PIN_TIMER&lt;/code&gt;? There is no definition for it in your code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Measuring elapsed microseconds between 12 successive rising edges on 12 GPIOS on NRF52832 DK</title><link>https://devzone.nordicsemi.com/thread/101852?ContentTypeID=1</link><pubDate>Wed, 18 Oct 2017 08:41:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b23ce0f-d428-467a-9eb7-7ad248a0352f</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Yes, I&amp;#39;m afraid you need a different solution. I don&amp;#39;t think this is doable with the timing constraints enforced by the Softdevice and the PPI and GPIOTE resources available on the nRF5 series alone.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Measuring elapsed microseconds between 12 successive rising edges on 12 GPIOS on NRF52832 DK</title><link>https://devzone.nordicsemi.com/thread/101851?ContentTypeID=1</link><pubDate>Wed, 18 Oct 2017 08:35:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5a35c6b-f87d-488c-ab89-b2c173502e3a</guid><dc:creator>Enero</dc:creator><description>&lt;p&gt;Thank you for this comment. I was asking about PPI Groups, because I don&amp;#39;t understand yet how they work.
My 12 sensors are independent indeed. They are listening to the same signal, and I need to measure propagation timings between the first sensor to the 12&amp;#39;st. As I don&amp;#39;t know which sensor will raised first to trigger Timer, I need whole configuration to adapt depending on which of the 12 input will raise first, and all of this in micro-second timing.
Thanks again for your help, I think I should now try to find a chip with 12 GPIOTE channels ?
Have a good day !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Measuring elapsed microseconds between 12 successive rising edges on 12 GPIOS on NRF52832 DK</title><link>https://devzone.nordicsemi.com/thread/101850?ContentTypeID=1</link><pubDate>Mon, 16 Oct 2017 08:03:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a3e9239-a23c-4b58-b2f3-b0469bd3cc97</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;I&amp;#39;m not sure I understand why you would need PPI groups? Is it so that each of the 12 sensors are completely independent from each other and may trigger at random times? I.e. iat is not so that all of them rises at the same time, on a common start signal?&lt;/p&gt;
&lt;p&gt;If it is all random I can&amp;#39;t think of any way of using PPI channels. I don&amp;#39;t think the Timeslot API would be of any use either as it is used to schedule events at deterministic points in time. The systick option would also require the use interrupts at the mercy of the Softdevice.&lt;/p&gt;
&lt;p&gt;I was actually wrong about the number of GPIOTE channels, by the way. nRF52832 has 8 GPIOTE channels and 6 PPI groups as you say.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Measuring elapsed microseconds between 12 successive rising edges on 12 GPIOS on NRF52832 DK</title><link>https://devzone.nordicsemi.com/thread/101848?ContentTypeID=1</link><pubDate>Fri, 13 Oct 2017 12:47:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7fe5bac9-dc9d-4935-9d09-d3582f9697b4</guid><dc:creator>Enero</dc:creator><description>&lt;p&gt;Thanks for your answer.
I was referring to &lt;a href="http://infocenter.nordicsemi.com/pdf/nRF52832_PS_v1.0.pdf"&gt;PPI&lt;/a&gt; page 165 table 30 (6 groups isn&amp;#39;t it ?), Does it mean I can only program 6 gpios over PPI to start timer or capture timer value? Or is this done as 1 group of 6 PPI channels, and another group of 6 others PPI channels (using at total 2 groups of 6 channels each) mixed with 6 GPIOTE as mentionned in your previous comment ?&lt;/p&gt;
&lt;p&gt;I may have missed something, In case I&amp;#39;m using PPI, do I have to use GPIOTE to get peripheral event?&lt;/p&gt;
&lt;p&gt;Thanks for your time :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Measuring elapsed microseconds between 12 successive rising edges on 12 GPIOS on NRF52832 DK</title><link>https://devzone.nordicsemi.com/thread/101849?ContentTypeID=1</link><pubDate>Fri, 13 Oct 2017 10:59:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d0c1f75-cd59-41a9-afe4-77f49685010b</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Happy to help. Apparently I didn&amp;#39;t read your question thoroughly enough. I thought we talked about one GPIO and 12 incoming pulses, not 12 different GPIOs. Although you have 16 PPI channels, you only have 6 GPIOTE channels available (which I think is what you are referring to?). So now I don&amp;#39;t see any obvious workarounds with PPI in your case. I don&amp;#39;t know the details of you use case, but maybe it would be possible to:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Configure the GPIOTE channels to measure a certain set of 6 pins&lt;/li&gt;
&lt;li&gt;Do 6 measurements&lt;/li&gt;
&lt;li&gt;Fire an interrupt routine and reconfigure the GPIOTE channels to use the 6 other pins.&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Measuring elapsed microseconds between 12 successive rising edges on 12 GPIOS on NRF52832 DK</title><link>https://devzone.nordicsemi.com/thread/101854?ContentTypeID=1</link><pubDate>Fri, 13 Oct 2017 07:37:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fba16004-8338-4ee1-bd63-4a8874938c49</guid><dc:creator>Enero</dc:creator><description>&lt;p&gt;Thank you for your help, I&amp;#39;m trying to implement it on my code :) Have a good day !&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Measuring elapsed microseconds between 12 successive rising edges on 12 GPIOS on NRF52832 DK</title><link>https://devzone.nordicsemi.com/thread/101847?ContentTypeID=1</link><pubDate>Fri, 13 Oct 2017 07:35:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aad988dc-24a2-425c-91da-5f06e5d7f22c</guid><dc:creator>Enero</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Thanks for your answer !
I looked at PPI but it seems like there is only 6 configurable groups. It takes me a bit of time to understand all of the concept of this but can I attach 12 inputs to PPI ? I&amp;#39;m working on it ! Thanks for your help :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Measuring elapsed microseconds between 12 successive rising edges on 12 GPIOS on NRF52832 DK</title><link>https://devzone.nordicsemi.com/thread/101853?ContentTypeID=1</link><pubDate>Thu, 12 Oct 2017 12:32:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c45eb23-cac4-41b1-b652-38b6480af265</guid><dc:creator>Krzysztof Zaraska</dc:creator><description>&lt;p&gt;Below is my implementation of a microsecond timer. This is old code (SDK 10 for NRF51), so it will not run right away, but should point you in the right direction.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;nrf_drv_timer.h&amp;quot;
#include &amp;quot;bsp.h&amp;quot;

#include &amp;quot;debug.h&amp;quot;

#include &amp;quot;timer.h&amp;quot;

uint64_t timer_micros = 0;

uint32_t timer_ticks; // set in timer_init()
uint32_t timer_interval = 1000000; // us
uint64_t timer_last = 0;

// COMPARE0 is used for overflow
// COMPARE3 is used for reading the timer

int pin_state = 0;

void timer_event_handler(nrf_timer_event_t event_type, void* p_context)
{
	if ( event_type != NRF_TIMER_EVENT_COMPARE0 )
		return;

	if ( pin_state == 0 ) {
		pin_state = 1;
		nrf_gpio_pin_set(PIN_TIMER);
	} else {
		pin_state = 0;
		nrf_gpio_pin_clear(PIN_TIMER);
	}
	
	timer_micros = timer_micros + timer_ticks;
	
	if ( timer_micros &amp;gt;= timer_last + timer_interval ) {
		timer_last = timer_micros;
		timer_callback();
	}
}

// Run on TIMER1
// Timer must be enabled in nrf_drv_config.h
const nrf_drv_timer_t timer = NRF_DRV_TIMER_INSTANCE(1);
nrf_drv_timer_config_t timer_config;

uint64_t timer_read(void)
{
	uint32_t ticks = nrf_drv_timer_capture(&amp;amp;timer, NRF_TIMER_CC_CHANNEL3);
	uint64_t ret = timer_micros + ticks;
	return ret;
}

void timer_init(void)
{
	// TIMER0 is 32-bit, TIMER1 &amp;amp; 2 are 16-bit
	timer_config.bit_width = NRF_TIMER_BIT_WIDTH_16;
	timer_config.frequency = NRF_TIMER_FREQ_1MHz;
	timer_config.interrupt_priority = 1; // 0 = highest, 3 = lowest
	timer_config.mode = NRF_TIMER_MODE_TIMER;
	
	
	uint32_t err_code = NRF_SUCCESS;
	err_code = nrf_drv_timer_init(&amp;amp;timer, &amp;amp;timer_config, timer_event_handler);
	if ( err_code != NRF_SUCCESS )
		_ERROR(&amp;quot;nrf_drv_timer_init() failed&amp;quot;);
	
	uint32_t time_ms = 50;
	timer_ticks = nrf_drv_timer_ms_to_ticks(&amp;amp;timer, time_ms);
	if ( timer_ticks &amp;gt; 65535 )
		_ERROR(&amp;quot;Timer frequency too high&amp;quot;);
	
	_DEBUG (&amp;quot;Timer: interrupt every %d ms, %d ticks per interrupt\n&amp;quot;, time_ms, timer_ticks);
	
	nrf_drv_timer_extended_compare(
		 &amp;amp;timer, NRF_TIMER_CC_CHANNEL0, timer_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);
	
	nrf_drv_timer_enable(&amp;amp;timer);
	
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Measuring elapsed microseconds between 12 successive rising edges on 12 GPIOS on NRF52832 DK</title><link>https://devzone.nordicsemi.com/thread/101846?ContentTypeID=1</link><pubDate>Thu, 12 Oct 2017 10:21:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:151ebaec-456e-4d8b-8b0b-35dd6ccc76aa</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Have you considered using &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/ppi.html?cp=2_1_0_21#concept_sxf_21l_1s"&gt;PPI&lt;/a&gt;? It is possible to have the Logic level input start a timer and a counter automatically. I&amp;#39;m not sure if I understand your use case, but it is e.g. possible to start a timer on the first Logic level event, then use a counter to count 11 logic level events, and finally stop the timer on the 11th event. All this can be done autonomously without using the CPU, Timeslot API, or sys ticks. The CPU can even be sleeping while you time your events. On the 11th event you can chose to trigger an interrupt to process your timer value. I wrote a little bit more about PPI at the bottom of &lt;a href="https://devzone.nordicsemi.com/question/169866/hardfault-with-gpiote-sd/"&gt;this thread&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>