<?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>inner and outer application timers, is it a problem?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/28547/inner-and-outer-application-timers-is-it-a-problem</link><description>Hi everyone, 
 I have one problem with the application timer. When I change the state of characteristic to the value of 1, the following code is executed: 
 err_code = app_timer_stop(m_mass_timer_id); 
 p_mass-&amp;gt;load_cell_calibration.flag_offset = 1;</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 05 Jan 2018 13:31:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/28547/inner-and-outer-application-timers-is-it-a-problem" /><item><title>RE: inner and outer application timers, is it a problem?</title><link>https://devzone.nordicsemi.com/thread/113088?ContentTypeID=1</link><pubDate>Fri, 05 Jan 2018 13:31:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fa6c1ed1-2103-41a9-ae87-b9517811cead</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;I noticed that you are using some flags in your handlers. &lt;a href="https://barrgroup.com/Embedded-Systems/How-To/C-Volatile-Keyword"&gt;Have you declared these volatile&lt;/a&gt;? It is not completely clear to me how all your timers are connected, but since you are starting and stopping timers in your handlers based on the status of these flags maybe the timings get skewed if the flags aren&amp;#39;t handled properly by the compiler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: inner and outer application timers, is it a problem?</title><link>https://devzone.nordicsemi.com/thread/113087?ContentTypeID=1</link><pubDate>Sun, 24 Dec 2017 23:19:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e6c24ed-836c-41c4-812e-ca3dcde1ffed</guid><dc:creator>control</dc:creator><description>&lt;p&gt;I was researching a little bit more why the timer is not instantly executed and I came across that if I put the function timer start into schedule then the timer is executed immediately otherwise timer has a pause a few seconds even though the timer has to be executed in a few ms. The test was done by using only one timer which works all the time. If the user changes the state of the characteristic, the timer is stopped and started again. I really do not understand why the timer is not executed immediately after state of the characteristic is changed.  Thanks for help in advance&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: inner and outer application timers, is it a problem?</title><link>https://devzone.nordicsemi.com/thread/113086?ContentTypeID=1</link><pubDate>Mon, 18 Dec 2017 12:21:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d0161216-02b1-407b-afbc-9953a4c8f516</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;I&amp;#39;m not sure if I understand. Are there any downsides of option 1 compared to option 2 at all? You are in the main context anyway and it sounds to me like option 1 will get the job done faster and with less code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: inner and outer application timers, is it a problem?</title><link>https://devzone.nordicsemi.com/thread/113085?ContentTypeID=1</link><pubDate>Sun, 17 Dec 2017 12:55:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:991c5b6f-2cfe-4668-aed7-a2d9c24033c3</guid><dc:creator>control</dc:creator><description>&lt;p&gt;Thanks for this useful information. It makes sense now. I have one additional question which is somehow related to this topic. As I already mentioned I use the scheduler for softdevice and timers. It means that the timers are executed in the main loop. The code in timer usually ends with calling a pstorage function in which the calculated variables are stored.  I do not know which of the following solutions are better one: 1) pstorage function is called directly from the timer (it is possible to do because the timer is executed in the main loop) or 2) to call the function app_sched_event_put() in timer and thus additional event is generated in the scheduler.&lt;/p&gt;
&lt;p&gt;Thanks for help in advance Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: inner and outer application timers, is it a problem?</title><link>https://devzone.nordicsemi.com/thread/113083?ContentTypeID=1</link><pubDate>Thu, 14 Dec 2017 10:26:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8a437877-d03c-4fdf-b0be-0d0439c2dd6b</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;You can try to call app_timer_stop() before you start it again.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: inner and outer application timers, is it a problem?</title><link>https://devzone.nordicsemi.com/thread/113084?ContentTypeID=1</link><pubDate>Thu, 14 Dec 2017 10:25:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:84c69024-01a5-45c7-86b8-1537b14fa7b4</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Not entirely sure if it is relevant, but restarting m_mass_timer_id inside its own handler like that could lead to troubles. As you can see here, &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.2.0/group__app__timer.html#gaa2e52b98d7c4030d5e283ddfe50c81c7"&gt;app_timer_start()&lt;/a&gt;, if you call this method on a timer that is already running, the second start operation is ignored.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: inner and outer application timers, is it a problem?</title><link>https://devzone.nordicsemi.com/thread/113082?ContentTypeID=1</link><pubDate>Tue, 12 Dec 2017 22:37:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2db4a143-236c-4af5-aa8a-e36c2339facf</guid><dc:creator>control</dc:creator><description>&lt;p&gt;I found the solution but I do not know why it works now.  As presented in code above I used the scheduler for both timers. But this setting was not enough I also added the softdevice to scheduler ( SOFTDEVICE_HANDLER_APPSH_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, true);) and now everything works fine. I am wondering why I have to add the softdevice to schedurer. I will be really appreciated for any kind of explanation.&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>