<?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>anyone having problem with the APP_TIMER in SDK14</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/26884/anyone-having-problem-with-the-app_timer-in-sdk14</link><description>When using the APP_TIMER in SDK14 I am having a problem with the application stopping.
I was using the APP_TIMER to flash LEDs and watch for timeouts in SDK13. when porting the code to SDK14 I am having a problem with the timer functions stopping. I</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 05 Feb 2018 15:11:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/26884/anyone-having-problem-with-the-app_timer-in-sdk14" /><item><title>RE: anyone having problem with the APP_TIMER in SDK14</title><link>https://devzone.nordicsemi.com/thread/119785?ContentTypeID=1</link><pubDate>Mon, 05 Feb 2018 15:11:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:663547ce-4506-4977-b8c6-b2a21221dc72</guid><dc:creator>yacine</dc:creator><description>&lt;p&gt;question continues &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/30110/app_timer-issue-after-migration-to-sdk14-2-from-12-x"&gt;here&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: anyone having problem with the APP_TIMER in SDK14</title><link>https://devzone.nordicsemi.com/thread/119719?ContentTypeID=1</link><pubDate>Mon, 05 Feb 2018 11:29:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5bec99b6-968a-456d-bb58-c8263a2475bc</guid><dc:creator>yacine</dc:creator><description>&lt;p&gt;Hello Sigurd,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks for your reply. I verified: app_timer_create is called, the timer _id is not 0, the callback is not NULL.&lt;/p&gt;
&lt;p&gt;I discovered the following with more tests:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;1) this code works only if the temporary variable timer_data is declared &lt;strong&gt;static&lt;/strong&gt; (just like in APP_TIMER_DEF macro. is not static app-timer_create returns SUCCESS, but app_timer_start will return&amp;nbsp;&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v5.0.0/group__nrf__error.html?cp=2_3_1_1_0_2_0_7_11#gaf0aff2ba7864b34a36b4a96986e1851e"&gt;NRF_ERROR_INVALID_STATE&lt;/a&gt;. see below ths code:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;ret_code_t err_code;
static app_timer_t timer_data = { {0} };
m_timer_id = &amp;amp;timer_data;
err_code = app_timer_create(&amp;amp;m_timer_id, APP_TIMER_MODE_REPEATED, cbk_measure);

(...)
ret_code_t err_code;
err_code = app_timer_start(m_timer_id, APP_TIMER_TICKS(m_probing_interval_ms), (void *) this);

&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;2) now the problem is that m_timer_id is a member of my c++ class and my code breaks when I create a second instance of this class and try to call app_timer_create. it seems like&amp;nbsp;&lt;span&gt;&lt;strong&gt;app_timer_create returns&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v5.0.0/group__nrf__error.html?cp=2_3_1_1_0_2_0_7_11#gaf0aff2ba7864b34a36b4a96986e1851e"&gt;NRF_ERROR_INVALID_STATE&lt;/a&gt; when the timer_id is already used by another app_timer&lt;/strong&gt;.&amp;nbsp;&lt;/span&gt;Actually the timed_id generated in the second instance constructor has the same value of the previous instance and this leads to app_timer create returning&amp;nbsp;&lt;/p&gt;
&lt;p&gt;see below the logs:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// first instance
&amp;lt;debug&amp;gt; FIXME: m_timer_id (before app_timer_create)= 536884956
&amp;lt;debug&amp;gt; FIXME: app_timer_create returns 0
&amp;lt;debug&amp;gt; FIXME: m_timer_id (before app_timer_start) = 536884956
&amp;lt;debug&amp;gt; FIXME: app_timer_start returns 0

// second instance
&amp;lt;debug&amp;gt; FIXME: m_timer_id (before app_timer_create)= 536884956
&amp;lt;debug&amp;gt; FIXME: app_timer_create returns 8

&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I need to geenerate a different m_timer_id for each class instance. how can I do ?!?!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: anyone having problem with the APP_TIMER in SDK14</title><link>https://devzone.nordicsemi.com/thread/119693?ContentTypeID=1</link><pubDate>Mon, 05 Feb 2018 09:39:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cf68e064-8557-4b0c-aba5-fa2970b9d9d9</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;yacine,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Error code 8 is &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v5.0.0/group__nrf__error.html?cp=2_3_1_1_0_2_0_7_11#gaf0aff2ba7864b34a36b4a96986e1851e"&gt;NRF_ERROR_INVALID_STATE&lt;/a&gt;. You will get this error code if have&amp;nbsp;not initialized the timer module(app_timer_init()). You could also get this error code if your&amp;nbsp;&lt;/span&gt;timer_id is 0, or if the timeout_handler function is NULL.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: anyone having problem with the APP_TIMER in SDK14</title><link>https://devzone.nordicsemi.com/thread/119427?ContentTypeID=1</link><pubDate>Thu, 01 Feb 2018 20:18:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:92e041bc-5f02-495b-b509-3fb58cd83ab6</guid><dc:creator>yacine</dc:creator><description>&lt;p&gt;hello&lt;/p&gt;
&lt;p&gt;yes I have problems with my app_timers in SDK14.2 (migration from 12),&lt;/p&gt;
&lt;p&gt;I well noticed that the prototypes of the functions create and start changed from sdk12.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;
	// create timer
	static app_timer_t timer_data = { {0} };
	m_timer_id = &amp;amp;timer_data;
	err_code = app_timer_create(&amp;amp;m_timer_id, APP_TIMER_MODE_REPEATED, cbk_measure);
	APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;this works well&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;ret_code_t err_code;

	err_code = app_timer_start(m_timer_id, APP_TIMER_TICKS(m_probing_interval_ms), (void *) this);

	NRF_LOG_DEBUG(&amp;quot;FIXME: app_timer_start returns %d&amp;quot;, err_code);
	//	APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;but the start returns error code 8 (invalid param if i remember correctly) and I dotn understand why.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BTW my timer_ids are C++ class members. I cannot simply use the APP-TIMER_DEF macro. but it was already the case ion SDK12 and worked AFAIK&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;thx,&lt;/p&gt;
&lt;p&gt;yacine&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: anyone having problem with the APP_TIMER in SDK14</title><link>https://devzone.nordicsemi.com/thread/105667?ContentTypeID=1</link><pubDate>Thu, 16 Nov 2017 16:13:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:83b173ba-30f2-4b13-aa9c-712c4655f934</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;There was no changes in the app timer library between SDK 13 and SDK 14. So it could be something else that is causing the application to stop.&lt;/p&gt;
&lt;p&gt;So if you are having trouble with the application stopping, you should debug and see if you maybe are running in the error-handler? See &lt;a href="https://devzone.nordicsemi.com/question/60125/my-device-is-freezing-and-restarting/"&gt;this post&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>