<?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>Using timer how to make 5 sec delay in pca10040 board?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/12470/using-timer-how-to-make-5-sec-delay-in-pca10040-board</link><description>Hi, 
 I am using pca10040 board. i need to toggle a led in 5sec once. I tried to change the prescale value. But im not able to get that much time delay. 
 Can any one help me on this?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 11 Mar 2016 15:26:38 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/12470/using-timer-how-to-make-5-sec-delay-in-pca10040-board" /><item><title>RE: Using timer how to make 5 sec delay in pca10040 board?</title><link>https://devzone.nordicsemi.com/thread/47233?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2016 15:26:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43f702ca-bcce-42e2-b7f8-43db31194003</guid><dc:creator>naveen</dc:creator><description>&lt;p&gt;Hi Ole Bauck,&lt;/p&gt;
&lt;p&gt;Thats Great.. Thank you for your great responses.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using timer how to make 5 sec delay in pca10040 board?</title><link>https://devzone.nordicsemi.com/thread/47232?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2016 09:35:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2bd6e00b-3259-440d-ada2-65c33c9eaa6b</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;You can use shorts:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_TIMER2-&amp;gt;SHORTS = (TIMER_SHORTS_COMPARE0_CLEAR_Enabled &amp;lt;&amp;lt; TIMER_SHORTS_COMPARE0_CLEAR_Pos);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will clear the timer counter value on CC[0] compare. If not doing this the timer will count to the maximum value before it overflows.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using timer how to make 5 sec delay in pca10040 board?</title><link>https://devzone.nordicsemi.com/thread/47231?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2016 04:13:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7f00caa4-eccd-4061-9372-2c7e03a31f34</guid><dc:creator>naveen</dc:creator><description>&lt;p&gt;Hi Ole Bauck,&lt;/p&gt;
&lt;p&gt;If i set prescale value 9 and bitmode is 32 means. The counting will be start in 0 to 4,294,967,296.
For 5 second delay i set cc[0]=156250.
For my requirement i need continuously toggle a led for 5 mins.
At very first time its coming in 5 second [0 - 156250]
but after that its taking more time [156270 - 4,294,967,296]
I dont kw how to do that..&lt;/p&gt;
&lt;p&gt;can u  guide me on thz.. below is my function:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void start_timer(void)
{
        NRF_TIMER2-&amp;gt;MODE = TIMER_MODE_MODE_Timer;
        NRF_TIMER2-&amp;gt;TASKS_CLEAR = 1;
        NRF_TIMER2-&amp;gt;PRESCALER = 9;
        NRF_TIMER2-&amp;gt;BITMODE = TIMER_BITMODE_BITMODE_32Bit;
        NRF_TIMER2-&amp;gt;CC[0] = 156250;
        NRF_TIMER2-&amp;gt;INTENSET = (TIMER_INTENSET_COMPARE0_Enabled &amp;lt;&amp;lt; TIMER_INTENSET_COMPARE0_Pos) ;
        NVIC_EnableIRQ(TIMER2_IRQn);
        NRF_TIMER2-&amp;gt;TASKS_START = 1;
}

void TIMER2_IRQHandler(void)
{
        if ((NRF_TIMER2-&amp;gt;EVENTS_COMPARE[0] != 0))
        {
                NRF_TIMER2-&amp;gt;EVENTS_COMPARE[0] = 0;                                      
                NRF_TIMER2-&amp;gt;CC[0] += 156250;
                nrf_gpio_pin_toggle(GPIO_TOGGLE_PIN);
        }
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using timer how to make 5 sec delay in pca10040 board?</title><link>https://devzone.nordicsemi.com/thread/47230?ContentTypeID=1</link><pubDate>Thu, 10 Mar 2016 13:50:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:761795bf-64ff-4671-82fb-ddd7a0b66e44</guid><dc:creator>naveen</dc:creator><description>&lt;p&gt;Hi Ole Bauck,&lt;/p&gt;
&lt;p&gt;Thank you for your valuable answers. Now i can able to do time delay whatever i need.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using timer how to make 5 sec delay in pca10040 board?</title><link>https://devzone.nordicsemi.com/thread/47229?ContentTypeID=1</link><pubDate>Thu, 10 Mar 2016 12:39:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:973fcbbb-3087-43dd-bf6f-0aaaa06e6288</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;BTW you can use TIMER to get 5 second delay. Using prescaler 9 and 32 bits the overflow value will be 2^32 / 16MHz * 2^9 = 137439 seconds.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using timer how to make 5 sec delay in pca10040 board?</title><link>https://devzone.nordicsemi.com/thread/47228?ContentTypeID=1</link><pubDate>Thu, 10 Mar 2016 12:31:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd7f621f-e4d9-4e48-b2e0-786596ae09d5</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;Have you tried using app_timer? It uses the RTC which will give you overflow at 512 seconds with prescaler 0. The RTC is also much more power efficient than using TIMER. See &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.0/rtc.html?cp=1_2_0_23_1#concept_iwc_1mj_sr"&gt;here&lt;/a&gt; for a tutorial on how to use it. You can also use the RTC directly, but be aware that RTC0 is used by SoftDevice and RTC1 is used by app_timer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>