<?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&amp;#39;t set up timer in couner mode with ppi</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/15666/can-t-set-up-timer-in-couner-mode-with-ppi</link><description>Hi. I am trying to set up timer in counter mode to count up signals from gpio through the ppi module, but it&amp;#39;s not working. In main cycle I am testing the timer using led :) . Code: 
 #define frenq_counter_pin 13
#define test_counter_pin 18
#define</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 18 Nov 2016 16:04:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/15666/can-t-set-up-timer-in-couner-mode-with-ppi" /><item><title>RE: Can't set up timer in couner mode with ppi</title><link>https://devzone.nordicsemi.com/thread/59826?ContentTypeID=1</link><pubDate>Fri, 18 Nov 2016 16:04:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3017f78b-9aa4-4d03-83b2-de304b27f297</guid><dc:creator>DonalHE</dc:creator><description>&lt;p&gt;Thank you for sharing your solution!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't set up timer in couner mode with ppi</title><link>https://devzone.nordicsemi.com/thread/59825?ContentTypeID=1</link><pubDate>Thu, 18 Aug 2016 13:34:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f344c57-510d-4f74-a449-b139a66a828c</guid><dc:creator>Vladimir</dc:creator><description>&lt;p&gt;Thank&amp;#39;s for link.
I solved that problem using drivers:&lt;/p&gt;
&lt;p&gt;Initialisation:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;	nrf_drv_timer_t timer1 = NRF_DRV_TIMER_INSTANCE(2);

	nrf_ppi_channel_t ppi_channel1;

	uint32_t capture_frenq(){
		uint32_t frenq_ = nrf_drv_timer_capture(
					&amp;amp;timer1,
					NRF_TIMER_CC_CHANNEL0
			);
			
		timer1.p_reg-&amp;gt;TASKS_CLEAR = 1;
		timer1.p_reg-&amp;gt;TASKS_START = 1;
		return frenq_;
	}

	// Void handler
	void timer_void_handler(nrf_timer_event_t event_type, void * p_context){}

	void pin_event_void_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action){}


	//Counter only
	void counter_init(void)
	{	
		
		nrf_drv_timer_config_t conf;
		   conf.mode = TIMER_MODE_MODE_Counter;
		   conf.bit_width = TIMER_BITMODE_BITMODE_16Bit;
		   conf.p_context = &amp;amp;timer1;
		   
		APP_ERROR_CHECK(
				   nrf_drv_timer_init(
						   &amp;amp;timer1,
						   &amp;amp;conf,
						   timer_void_handler
		   ));
		   
		nrf_drv_timer_enable(&amp;amp;timer1);
	}

	void gpiote_init(nrf_drv_gpiote_pin_t frenq_counter_pin){
		nrf_drv_gpiote_init();
		
		nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
		config.pull = NRF_GPIO_PIN_PULLUP;
		
		nrf_drv_gpiote_in_init(frenq_counter_pin, &amp;amp;config, pin_event_void_handler);
		nrf_drv_gpiote_in_event_enable(frenq_counter_pin, true);
	}


	void ppi_init(nrf_drv_gpiote_pin_t frenq_counter_pin){
		uint32_t err_code = NRF_SUCCESS;

		err_code = nrf_drv_ppi_init();
		APP_ERROR_CHECK(err_code);

		err_code = nrf_drv_ppi_channel_alloc(&amp;amp;ppi_channel1);
		APP_ERROR_CHECK(err_code);
		err_code = nrf_drv_ppi_channel_assign(ppi_channel1,
							nrf_drv_gpiote_in_event_addr_get(frenq_counter_pin),
							nrf_drv_timer_task_address_get(&amp;amp;timer1, NRF_TIMER_TASK_COUNT));
		APP_ERROR_CHECK(err_code);
		
		nrf_drv_ppi_channel_enable(ppi_channel1);
	}


	void speedometer_init(nrf_drv_gpiote_pin_t pin){
		counter_init();
		gpiote_init(pin);
		ppi_init(pin);
	}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Application timer for frequency capturing:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void timers_init(void)
{
	uint32_t err_code;
	APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);
	
	err_code = app_timer_create(&amp;amp;speed_timer_id,
								APP_TIMER_MODE_REPEATED,
								speed_meas_handler);
	APP_ERROR_CHECK(err_code);

}

void speed_meas_handler(void * p_context){
	freq_ = capture_freq();
	
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't set up timer in couner mode with ppi</title><link>https://devzone.nordicsemi.com/thread/59824?ContentTypeID=1</link><pubDate>Wed, 10 Aug 2016 10:41:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d355f79-e0cf-4fdc-9045-a0f19353f262</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;I haven&amp;#39;t tried it using drivers but &lt;a href="https://devzone.nordicsemi.com/question/50171/measuring-input-gpio-pin-frequency-with-soft-device-running/"&gt;here&lt;/a&gt; is the post that did this without using drivers.
Note that TIMER1 and PPI next to it used to stop the TIMER2 after 1 second. In your case you just need to configure GPIOTE-&amp;gt;PPI-&amp;gt;TIMER2 in counter mode. @adriand has updated the thread with his code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>