<?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>Regarding nRF51 Timer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/12374/regarding-nrf51-timer</link><description>Hi.
I&amp;#39;m using PCA10028 and SDK10.0.0, S130 v1.0.0.
And &amp;quot;ble_app_hrs_c&amp;quot; example is my reference code. 
 It works well before i add code for timer as below. 
 void start_timer(void)
{ 
 NRF_TIMER2-&amp;gt;MODE = TIMER_MODE_MODE_Timer; // Set the timer in</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 08 Mar 2016 08:09:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/12374/regarding-nrf51-timer" /><item><title>RE: Regarding nRF51 Timer</title><link>https://devzone.nordicsemi.com/thread/46785?ContentTypeID=1</link><pubDate>Tue, 08 Mar 2016 08:09:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0cc586f8-6e48-49cd-aa6f-e1dc4e7cbeac</guid><dc:creator>roger.k</dc:creator><description>&lt;p&gt;Thanks a lot&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding nRF51 Timer</title><link>https://devzone.nordicsemi.com/thread/46784?ContentTypeID=1</link><pubDate>Tue, 08 Mar 2016 07:08:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e8170227-4acc-42f3-9f50-e88a8e2376ee</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Take a look at &lt;a href="https://devzone.nordicsemi.com/question/60125/my-device-is-freezing-and-restarting/"&gt;this&lt;/a&gt; thread, that explain the possible reasons why your code restarts.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding nRF51 Timer</title><link>https://devzone.nordicsemi.com/thread/46783?ContentTypeID=1</link><pubDate>Tue, 08 Mar 2016 00:16:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b038c72d-3a98-4af5-b669-4633fc553d01</guid><dc:creator>roger.k</dc:creator><description>&lt;p&gt;Thanks.
I put your code.
But it still has problem.
As long as I put &amp;quot;scan_start()&amp;quot; function before &amp;quot;start_timer()&amp;quot; function, it reboots continuously.&lt;/p&gt;
&lt;p&gt;int main(void)
{&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;bool erase_bonds;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;uart_init();

scan_start();

	nrf_gpio_cfg_output(GPIO_TOGGLE_PIN);

	nrf_gpio_cfg_output(GPIO_TOGGLE_PIN_1);

	start_timer();
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Regarding nRF51 Timer</title><link>https://devzone.nordicsemi.com/thread/46782?ContentTypeID=1</link><pubDate>Mon, 07 Mar 2016 11:28:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5e8a0d6-86b6-4534-aa29-752978608480</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;You have to clear the generated events in the irq handler&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    NRF_TIMER2-&amp;gt;EVENTS_COMPARE[0] = 0;  
    NRF_TIMER2-&amp;gt;EVENTS_COMPARE[1] = 0;  
    NRF_TIMER2-&amp;gt;EVENTS_COMPARE[2] = 0;  
    NRF_TIMER2-&amp;gt;EVENTS_COMPARE[3] = 0; 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You also need to clear the timer when either COMPARE1 or COMPARE0 event is generated depending on which ever logic you need.&amp;#39;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_TIMER2-&amp;gt;SHORTS |= TIMER_SHORTS_COMPARE0_CLEAR_Msk; 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;or&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_TIMER2-&amp;gt;SHORTS |= TIMER_SHORTS_COMPARE1_CLEAR_Msk;
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>