<?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>Capture timer value</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/2173/capture-timer-value</link><description>Hi, 
 i want to start timer 2 and read its value just before the radio gets active. I&amp;#39;ve seen in the nr51 series reference manual i can use task capture to set the current count value in CC register and afterwards set the register value in a variable</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 13 May 2014 11:22:28 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/2173/capture-timer-value" /><item><title>RE: Capture timer value</title><link>https://devzone.nordicsemi.com/thread/9213?ContentTypeID=1</link><pubDate>Tue, 13 May 2014 11:22:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:32b1572e-540b-41b5-bab4-81c6cc8889b1</guid><dc:creator>pascal defesche</dc:creator><description>&lt;p&gt;Ok thanks again for your help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Capture timer value</title><link>https://devzone.nordicsemi.com/thread/9212?ContentTypeID=1</link><pubDate>Tue, 13 May 2014 10:46:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:053912fe-b0a5-4e75-b955-5285aed7079f</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi Pascal,&lt;/p&gt;
&lt;p&gt;I just checked with one of our developers regarding this.
Once the task has been set internally (ie: the TASKS_CAPTURE register has been set) it will be executed in one clock cycle.&lt;/p&gt;
&lt;p&gt;Best regards
Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Capture timer value</title><link>https://devzone.nordicsemi.com/thread/9211?ContentTypeID=1</link><pubDate>Mon, 12 May 2014 08:13:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:33772c5c-fc1a-41f4-8cae-4dfc8368ba58</guid><dc:creator>pascal defesche</dc:creator><description>&lt;p&gt;The nRF51 reference manual chapter 17.1.4 specifies the clear, count and stop task will guarantee to take place within one clock cycle of HFCLK.&lt;/p&gt;
&lt;p&gt;When using capture task how long will it take for the timer value to be available in the register? Within one clock cycle?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Capture timer value</title><link>https://devzone.nordicsemi.com/thread/9210?ContentTypeID=1</link><pubDate>Mon, 28 Apr 2014 15:33:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14823b41-8da7-49f0-a84a-1d6b01c01e83</guid><dc:creator>pascal defesche</dc:creator><description>&lt;p&gt;i have found the problem: the bluetooth stack has higher priority causing tasks_clear to be processed later&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Capture timer value</title><link>https://devzone.nordicsemi.com/thread/9209?ContentTypeID=1</link><pubDate>Mon, 28 Apr 2014 11:23:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a7bb13c0-1dfc-462d-9eab-3f75955682d4</guid><dc:creator>pascal defesche</dc:creator><description>&lt;p&gt;Is it possible to clear the timer at a compare event? I need the timer to reach a maximum value of 31250 and immediately clear the timer. I&amp;#39;ve tried using the following code but it results in a value sometimes over the 31250 because the mcu needs to set clear task.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void TIMER1_IRQHandler(void)
{
//0,125s compare event
if(NRF_TIMER1-&amp;gt;EVENTS_COMPARE[0]) //compare event happened
{
	NRF_TIMER1-&amp;gt;EVENTS_COMPARE[0] = 0;//set compare register again to 0
	NRF_TIMER1-&amp;gt;TASKS_CLEAR = 1;//set count value to 0
	half_sec++;					//value indicating half seconds
	NRF_TIMER1-&amp;gt;CC[0] = 31250; //Need to update the CC[0] with new compare value
	nrf_gpio_pin_toggle(18); //indication for compare event
}
}

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Is it possible implementing this without the timer getting a value above 31250?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Capture timer value</title><link>https://devzone.nordicsemi.com/thread/9208?ContentTypeID=1</link><pubDate>Mon, 14 Apr 2014 09:03:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dc0d2562-e037-4c60-b4c6-f7ecdf2578f2</guid><dc:creator>pascal defesche</dc:creator><description>&lt;p&gt;ah yes ofcourse, thanks!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Capture timer value</title><link>https://devzone.nordicsemi.com/thread/9207?ContentTypeID=1</link><pubDate>Fri, 11 Apr 2014 19:47:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23e3f1ec-4326-4632-abfa-4abb794084e4</guid><dc:creator>Nikita</dc:creator><description>&lt;p&gt;You are already using CC[0] register for COMPARE0 event interrupt, so if you want to read current timer counter value you need to trigger CAPTURE task for another channel i.e.:
NRF_TIMER2-&amp;gt;TASKS_CAPTURE[1] = 1;
u_sec = (NRF_TIMER2-&amp;gt;CC[1]);&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Capture timer value</title><link>https://devzone.nordicsemi.com/thread/9206?ContentTypeID=1</link><pubDate>Fri, 11 Apr 2014 14:16:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20eee97d-1d42-4b6c-8867-77408e9412d2</guid><dc:creator>pascal defesche</dc:creator><description>&lt;p&gt;I have one more question regarding the timers:&lt;/p&gt;
&lt;p&gt;In my case im initialising the timer to tick with 8 u sec and im generating an compare event each 20ms (so  2500 ticks). This works and is located in my IRQ handler, but now in the main (for loop) i want to read the current value in the count register is this just simply possible with the following code?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;for (;;)
    {
    	//NRF_TIMER2-&amp;gt;TASKS_CAPTURE[0] = 1;
    	u_sec = (NRF_TIMER2-&amp;gt;CC[0]); //value in us with 8us resolution
    	if (m_do_update)
    	        {
    				nrf_gpio_pin_set(LED_6);
    	            advertising_init();
    	            m_do_update = false;
    	            nrf_gpio_pin_clear(LED_6);
    	        }

    }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Writing tasks_capture[0]=1 will stop the timer event, thats why i commented it.&lt;/p&gt;
&lt;p&gt;Regards,
Pascal&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Capture timer value</title><link>https://devzone.nordicsemi.com/thread/9205?ContentTypeID=1</link><pubDate>Thu, 10 Apr 2014 07:40:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2957f1f7-d289-49f1-9ea9-f217d4f2ee8e</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;It&amp;#39;s true that the register is 4 bit, however the valid range for PRESCALER is from 0 to 9.&lt;/p&gt;
&lt;p&gt;BR
Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Capture timer value</title><link>https://devzone.nordicsemi.com/thread/9204?ContentTypeID=1</link><pubDate>Wed, 09 Apr 2014 15:04:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb0515a6-ae8c-4b3c-a281-3cd84d5d1641</guid><dc:creator>pascal defesche</dc:creator><description>&lt;p&gt;Thanks, after setting NRF_TIMER2-&amp;gt;TASKS_CAPTURE[0] = 1;
i can read its value. Why prescaler 14 is not valid? Thought max = 2^4(16)??&lt;/p&gt;
&lt;p&gt;Cheers&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Capture timer value</title><link>https://devzone.nordicsemi.com/thread/9203?ContentTypeID=1</link><pubDate>Wed, 09 Apr 2014 14:47:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:16b6cafb-6ff9-4286-9dc1-583510ecf0cd</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Setting NRF_TIMERx-&amp;gt;PRESCALER = 14 is not valid.
It&amp;#39;s only valid from 0 to 9.
Note that you should write &lt;code&gt;NRF_TIMER2-&amp;gt;TASKS_CAPTURE[0] = 1;&lt;/code&gt; to start the task.&lt;/p&gt;
&lt;p&gt;BR
Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>