<?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 app_timer_cnt_get(), get zero!</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/15158/using-app_timer_cnt_get-get-zero</link><description>Hi there, I have done search and know there are several similar questions, but unfortunately I didn&amp;#39;t find any useful answer after carefully reading through them, thus I decide to post a new question, and wish it could help others in the future. 
 As</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 28 Sep 2016 09:22:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/15158/using-app_timer_cnt_get-get-zero" /><item><title>RE: Using app_timer_cnt_get(), get zero!</title><link>https://devzone.nordicsemi.com/thread/57881?ContentTypeID=1</link><pubDate>Wed, 28 Sep 2016 09:22:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:323f7e2a-46f4-438e-b0c1-a11047aa2ea9</guid><dc:creator>djqtsg</dc:creator><description>&lt;p&gt;Uly, have you figured out solution to make timer work in interrupts? Can you post the code?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using app_timer_cnt_get(), get zero!</title><link>https://devzone.nordicsemi.com/thread/57879?ContentTypeID=1</link><pubDate>Mon, 18 Jul 2016 19:01:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4cabe4c0-95d6-4cac-9014-281a4a61e4e6</guid><dc:creator>uly</dc:creator><description>&lt;p&gt;@Ole Bauck, thanks very much, I made some changes and it works, I put what I did as an answer.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using app_timer_cnt_get(), get zero!</title><link>https://devzone.nordicsemi.com/thread/57880?ContentTypeID=1</link><pubDate>Mon, 18 Jul 2016 18:18:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:281ae90a-7fd6-4f4d-998e-95f7fb7f0bf9</guid><dc:creator>uly</dc:creator><description>&lt;p&gt;I moved the &lt;code&gt;app_timer_cnt_get&lt;/code&gt; functions into the &lt;code&gt;main()&lt;/code&gt; part, then I notice the eclipsed time. Now I somehow understand the explanation of &lt;code&gt;Timer library&lt;/code&gt; in the Nordic Semiconductor Infocenter, i.e.,&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;... The actual timer start/stop
operation is executed by the SWI0
interrupt handler. Since the SWI0
interrupt is running in APP_LOW, if
the application code calling the timer
function is running in APP_LOW or
APP_HIGH, the timer operation will not
be performed until the application
handler has returned. This will be the
case e.g. when stopping a timer from a
timeout handler when not using the
scheduler.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I guess if proper levels are defined, I will make the time to work in the interrupts. I will do some tests on that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using app_timer_cnt_get(), get zero!</title><link>https://devzone.nordicsemi.com/thread/57878?ContentTypeID=1</link><pubDate>Mon, 18 Jul 2016 15:47:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4b6b2f99-6729-4960-8596-f6056e49a2b0</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;Since you are in an interrupt/handler, app_timer will not start until the event handler is done (app_timer operations are done in a software interrupt). You have to check the counter value after the event handler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using app_timer_cnt_get(), get zero!</title><link>https://devzone.nordicsemi.com/thread/57877?ContentTypeID=1</link><pubDate>Mon, 18 Jul 2016 15:33:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f9dab0c8-9922-4503-8953-1ac42ec2e01f</guid><dc:creator>uly</dc:creator><description>&lt;p&gt;Hi, Ole, thanks. I don&amp;#39;t know the timeout handler, there do exist a handler given to &lt;code&gt;app_timer_create()&lt;/code&gt;, but it seems have nothing to do with timeout.
To prevent the value of RTC to be 0, I added a delay before returning &lt;code&gt;app_timer_cur&lt;/code&gt;. but app_timer_cur is still 0.&lt;/p&gt;
&lt;p&gt;I put the main.c file &lt;a href="https://codeshare.io/MLgBV"&gt;https://codeshare.io/MLgBV&lt;/a&gt;, which is basically on the basis of the example from tutorial. I appreciate if you could have a look at part between line 59 to 70.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using app_timer_cnt_get(), get zero!</title><link>https://devzone.nordicsemi.com/thread/57875?ContentTypeID=1</link><pubDate>Mon, 18 Jul 2016 10:43:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d1f5a41-bc7f-426a-88a7-e7e23fe6989f</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;&lt;code&gt;watchdog_timer&lt;/code&gt; will obtain the value of the RTC when you call &lt;code&gt;app_timer_cnt_get(&amp;amp;watchdog_timer);&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Is the timeout handler corresponding to &lt;code&gt;m_led_a_timer_id&lt;/code&gt;  ever called (handler given in app_timer_create function)?&lt;/p&gt;
&lt;p&gt;Right after starting the first timer you may expect that the value of the RTC is 0 (it does not start until the first app_timer_start is called). May this be the issue?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using app_timer_cnt_get(), get zero!</title><link>https://devzone.nordicsemi.com/thread/57874?ContentTypeID=1</link><pubDate>Mon, 18 Jul 2016 06:53:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f9b333aa-8ce9-4478-9d77-d685ce09e1a4</guid><dc:creator>uly</dc:creator><description>&lt;p&gt;One question, after declaring &lt;code&gt;watchdog_timer&lt;/code&gt;, should I do something to let &lt;code&gt;watchdog_timer&lt;/code&gt; obtain the value of RTC before &lt;code&gt;app_timer_cnt_get(&amp;amp;watchdog_timer);&lt;/code&gt; ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using app_timer_cnt_get(), get zero!</title><link>https://devzone.nordicsemi.com/thread/57876?ContentTypeID=1</link><pubDate>Sat, 16 Jul 2016 18:49:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad9eedfb-dd4f-49d3-baf0-584bf9f7675f</guid><dc:creator>uly</dc:creator><description>&lt;p&gt;@Ole Bauck, thanks, I declare &lt;code&gt;watchdog_timer&lt;/code&gt;, &lt;code&gt;app_timer_cur&lt;/code&gt; and &lt;code&gt;app_timer_diff&lt;/code&gt; as global static, but still get ZERO.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using app_timer_cnt_get(), get zero!</title><link>https://devzone.nordicsemi.com/thread/57873?ContentTypeID=1</link><pubDate>Fri, 15 Jul 2016 09:19:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e2436b7b-1aec-4f7d-bf91-6ee835db6d79</guid><dc:creator>Ole Bauck</dc:creator><description>&lt;p&gt;Maybe not the root of your problem, but watchdog_timer should be declared as static to not be placed on the stack and destroyed when the function exits, or else app_timer_diff will always be equal to app_timer_cur.&lt;/p&gt;
&lt;p&gt;But if I understood correct app_timer_cur is equal to zero even after app_timer_cnt_get(&amp;amp;app_timer_cur)?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using app_timer_cnt_get(), get zero!</title><link>https://devzone.nordicsemi.com/thread/57872?ContentTypeID=1</link><pubDate>Fri, 15 Jul 2016 07:15:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e795ba3c-6ed7-471d-97a2-37bcb2835967</guid><dc:creator>uly</dc:creator><description>&lt;p&gt;@RK, thanks. Yes, &lt;code&gt;lfclk_request();&lt;/code&gt; is called in the beginning of main() function. I have added the main() part in the question.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Using app_timer_cnt_get(), get zero!</title><link>https://devzone.nordicsemi.com/thread/57871?ContentTypeID=1</link><pubDate>Thu, 14 Jul 2016 23:55:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1306036f-238c-41b1-bfa2-03a3bfc00382</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Have you started a low frequency clock source?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>