<?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>related to timer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/2811/related-to-timer</link><description>Hi All,
please explain me in understanding the following w.r.t to timers. I am novice in this field and
i am trying to understand the 51822 Ble_app_hrs project 
 C:\Keil_v5\ARM\Device\Nordic\nrf51822\Board\pca10001\s110\ble_app_hrs\arm
 
 
 is each</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 16 Jun 2014 12:02:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/2811/related-to-timer" /><item><title>RE: related to timer</title><link>https://devzone.nordicsemi.com/thread/10783?ContentTypeID=1</link><pubDate>Mon, 16 Jun 2014 12:02:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:be15fa61-cdbc-48af-a1a7-f587aa4760c0</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;The app_timer module is a somewhat complex module, which allows the user to add instances/handles (continuous or one-shot) that occur based on the &amp;quot;TICK&amp;quot; (timer increment) of the RTC peripheral. When one instance is expired, the timeout_handler callback is fired.&lt;/p&gt;
&lt;p&gt;This allows you to have several handlers that occur at different ticks (example, 1 ms / 100 ms / 1 second, etc), but they are all based on the RTC peripheral (which is f = 32.768 kHz)&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;It&amp;#39;s a choice from our side not to use dynamic memory allocation, meaning that all instances has to be allocated in compile-time. What you, as the developer, has to configure is:&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;APP_TIMER_MAX_TIMERS, amount of timer instances running in your system&lt;/li&gt;
&lt;li&gt;APP_TIMER_PRESCALER, which is the prescaler setting (0 = ~30.51 us per TICK)&lt;/li&gt;
&lt;li&gt;APP_TIMER_OP_QUEUE_SIZE, which is the queue size. See here for detailed info
&lt;a href="https://devzone.nordicsemi.com/question/723/how-big-should-app_timer_op_queue_size-be/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;ol start="2"&gt;
&lt;li&gt;
&lt;p&gt;The user array (define APP_TIMER_MAX_TIMERS) are the number of instances running in your application.
The operational queue is the number of queued handlers that can be processed at the same time. This is normally only an issue if you&amp;#39;re using different interrupt sources w/ different priority.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;The library is made to be used, not to understand each static function inside the library, but I fully understand why you want to know how the library works in detail.
When you init the module using the APP_TIMER_INIT macro function, you also allocate memory based on the defines set 1).
Then the initialization is done in two steps:&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;ul&gt;
&lt;li&gt;Create&lt;/li&gt;
&lt;li&gt;Start&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;You create the instance, and give it an ID + timeout_handler.
You start the instance with an ID + instance options (repeated/oneshot, and interval in TICKS)&lt;/p&gt;
&lt;p&gt;You have two interrupts in this library:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;RTC IRQHandler&lt;/li&gt;
&lt;li&gt;SWI IRQHandler (Supervisor Call, read: Software triggered interrupt)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The RTC is triggered by the Capture/Compare, and is given by the mathematical formula found in the Reference Manual. The library computes these values for each timeout handler.&lt;/p&gt;
&lt;p&gt;The SWI interrupt is triggered by function &amp;quot;timer_list_handler_sched&amp;quot; (NVIC_SetPending()), which is called in several places in the library.&lt;/p&gt;
&lt;p&gt;The RTC IRQHandler checks the timing of each instance, and if a handler has timed out (callback is to be fired), it fires the specific callback by calling timeout_handler_exec() with p_timer as input.
The SVC/SWI interrupt is triggered when you for instance modify/create/start/stop any instances.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>