<?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>app_timer_cnt_get() always returns 0x0018000 (SDK12.1.0)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/19045/app_timer_cnt_get-always-returns-0x0018000-sdk12-1-0</link><description>I&amp;#39;m trying to use app_timer_cnt_get() to implement an RTC Calendar system on a Gigawit module (nRF51822). 
 I have a test app_timer that has presacler=0 and period=3 seconds. The callback works as I toggle a LED, and it toggles every 3 seconds. 
 The</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 17 Jan 2017 12:19:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/19045/app_timer_cnt_get-always-returns-0x0018000-sdk12-1-0" /><item><title>RE: app_timer_cnt_get() always returns 0x0018000 (SDK12.1.0)</title><link>https://devzone.nordicsemi.com/thread/73628?ContentTypeID=1</link><pubDate>Tue, 17 Jan 2017 12:19:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c9968bd-f428-41bb-bb73-f7b9a9f585cc</guid><dc:creator>Brendan S</dc:creator><description>&lt;p&gt;&lt;code&gt;app_timer_cnt_get()&lt;/code&gt; is working ok.  Putting a breakpoint in the handler causes the processor to reset on resumption and RTC1 was being reset/reinitialised.&lt;/p&gt;
&lt;p&gt;Reading the timer count and storing in a global variable, and watching the variable in a live watch window, I could see the variable incrementing by 0x18000 every 3 seconds.&lt;/p&gt;
&lt;p&gt;Thanks Ole for the heads up.&lt;/p&gt;
&lt;p&gt;Brendan.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: app_timer_cnt_get() always returns 0x0018000 (SDK12.1.0)</title><link>https://devzone.nordicsemi.com/thread/73626?ContentTypeID=1</link><pubDate>Tue, 17 Jan 2017 12:17:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:03ecf439-ebe9-4900-8a9e-08617d4b0ad7</guid><dc:creator>Brendan S</dc:creator><description>&lt;p&gt;Yes.  The processor is continually resetting, even using the scheduler.  If I put the global variable &lt;code&gt;last_count&lt;/code&gt; in the live watch window of IAR, then I can see it incrementing by approx 0x18000 each time.
Thanks, Brendan :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: app_timer_cnt_get() always returns 0x0018000 (SDK12.1.0)</title><link>https://devzone.nordicsemi.com/thread/73625?ContentTypeID=1</link><pubDate>Tue, 17 Jan 2017 12:10:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ee86b97-6497-4e39-b0b8-2cd8386fcd3b</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;Maybe it is the way you are checking the value.&lt;/p&gt;
&lt;p&gt;You should be careful when using breakpoints as this will only stop the cpu (the code) from running and not the peripherals like the RTC. This is the reason it is not recommended to use breakpoints and then resume the code execution when doing BLE stuff (advertising/scanning/connection).&lt;/p&gt;
&lt;p&gt;If you get a value of 0x18000 the first time you enter the timer_app callback routine, this is correct (0x18000 is 0x8000 (32768) times 3 -&amp;gt; 3 seconds). When you resume the code execution do you hit the breakpoint again with the same value? If so it might be because the chip is resetting because of an error condition, see &lt;a href="https://devzone.nordicsemi.com/question/60125/my-device-is-freezing-and-restarting/"&gt;here&lt;/a&gt;. You can check this by adding a breakpoint at the very start of main().&lt;/p&gt;
&lt;p&gt;You could try to log the value using UART or RTT instead, this can be done with the log module. Enable logging with the NRF_LOG_ENABLED macro in sdk_config.h. Use NRF_LOG_... functions to print data.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: app_timer_cnt_get() always returns 0x0018000 (SDK12.1.0)</title><link>https://devzone.nordicsemi.com/thread/73627?ContentTypeID=1</link><pubDate>Tue, 17 Jan 2017 06:24:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad214963-4aa3-4b78-bfc0-c2bb3e4dae2e</guid><dc:creator>Brendan S</dc:creator><description>&lt;p&gt;Update: &lt;code&gt;app_timer_cnt_get()&lt;/code&gt; is working if I call it in my &lt;code&gt;main()&lt;/code&gt; function, but not if called in my &lt;code&gt;timer_app&lt;/code&gt; callback routine (which is in a different file).&lt;/p&gt;
&lt;p&gt;Is this because it is executing in an interrupt context ?&lt;/p&gt;
&lt;p&gt;Would using an &lt;code&gt;app_timer&lt;/code&gt; scheduler resolve things?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>