<?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>Timer scheduler</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/12452/timer-scheduler</link><description>Hello:
I have detected a problem with a timer on my program.
I can solve it, but I would like to understand what is happening exactly. 
 My program starts to scan BLE signal, and, if it find a known advertising signal, it starts a timer inside the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 11 Mar 2016 10:30:22 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/12452/timer-scheduler" /><item><title>RE: Timer scheduler</title><link>https://devzone.nordicsemi.com/thread/47159?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2016 10:30:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d1f4d1ed-b9d8-4725-a267-5c4bdde0b9aa</guid><dc:creator>Shorosky</dc:creator><description>&lt;p&gt;Ok, I will remember it on the future.
Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer scheduler</title><link>https://devzone.nordicsemi.com/thread/47158?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2016 09:47:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60797a6d-4720-4882-97a9-0f2dff0b937b</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;There is no API call for checking how full the queue is. You can always initialize the queue with a slightly higher number than what you know you will need. This will of course impact you RAM usage a bit. You can check if the queue is full by checking if app_timer_start/stop returns NRF_ERROR_NO_MEM (0x4).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer scheduler</title><link>https://devzone.nordicsemi.com/thread/47157?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2016 08:56:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e190de8b-17cf-4654-bc3c-2d473a560f7c</guid><dc:creator>Shorosky</dc:creator><description>&lt;p&gt;Problem is solved. I did what you say, and it works even with only value 1 on the APP_TIMER_QUEUE_SIZE. It is probably that I have more problems similar like that on the future, so if could to know how many tasks are pending on scheduler, I would be grateful for it.&lt;/p&gt;
&lt;p&gt;Thank you for helping&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer scheduler</title><link>https://devzone.nordicsemi.com/thread/47156?ContentTypeID=1</link><pubDate>Fri, 11 Mar 2016 08:45:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:29075775-e3ee-4a86-85f1-f789b8df79ab</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;The best solution is to avoid the problem completely. Raise a flag (set a variable) when you find the correct advertisement. When you get back to main(), check the flag. Then you reset the timer accordingly.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer scheduler</title><link>https://devzone.nordicsemi.com/thread/47155?ContentTypeID=1</link><pubDate>Thu, 10 Mar 2016 15:40:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7bc456bd-4e55-4411-a879-f3f313efc3ee</guid><dc:creator>Shorosky</dc:creator><description>&lt;p&gt;I do this only on &amp;quot;good packets&amp;quot; but I will have to work, sometimes with 4 different signals, so I have to solve the problem of priorities.
There is a way to know how many tasks are queued on the timer scheduler?&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer scheduler</title><link>https://devzone.nordicsemi.com/thread/47154?ContentTypeID=1</link><pubDate>Thu, 10 Mar 2016 12:38:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:52a39e5e-48f4-42a3-9ba3-55853accd45c</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;Are you doing this on every received advertising event, or are you checking the advertisement packet before you start/stop the timers? If it is the first, you will be doing this very often if there is a couple of BLE devices advertising around you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer scheduler</title><link>https://devzone.nordicsemi.com/thread/47153?ContentTypeID=1</link><pubDate>Thu, 10 Mar 2016 10:47:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:29fe8a1d-7940-4854-be5e-f1fe5ee6fe52</guid><dc:creator>Shorosky</dc:creator><description>&lt;p&gt;Hi, Anders.
Thank you for answering.
I readed the documentation, but I was not sure if queue is to start and stop timers, or while micro was attending an interruption of timer and another more priority interruption is comming.
I think that the problem comes when I queue the two operations (start and stop), the program finish the on_ble_evt, and before to execute the instructions queued, it recives a new ble interruption.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll try to start and stop the timer on main function, and watch what happens.&lt;/p&gt;
&lt;p&gt;Thank you.
Regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer scheduler</title><link>https://devzone.nordicsemi.com/thread/47152?ContentTypeID=1</link><pubDate>Thu, 10 Mar 2016 10:33:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:873e7de4-34b9-454f-ac90-3ee9d964f3b2</guid><dc:creator>Anders Strand</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;From the app_timer &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk51.v10.0.0/lib_timer.html?resultof=%22%61%70%70%5f%74%69%6d%65%72%22%20"&gt;documentation&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;When calling app_timer_start() or
app_timer_stop(), the timer operation
is just queued, and the software
interrupt is triggered. 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.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This means that both the call to app_timer_stop and app_timer_start is queued, and then executed when you exit the on_ble_evt function.&lt;/p&gt;
&lt;p&gt;If you get the error with queue size = 2, it is probably because an app_timer is being used somewhere else in your code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>