<?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>nrf51822 app timer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/34551/nrf51822-app-timer</link><description>Hi 
 I am trying to broadcast manufacturer data (beacon example) while changing data from second to second. For that I am trying to use timer2 (as timer 0 is used by SD, right). 
 
 
 
 ... 
 void start_timer(void) { NRF_TIMER2-&amp;gt;MODE = TIMER_MODE_MODE_Counter;</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 27 Dec 2018 13:14:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/34551/nrf51822-app-timer" /><item><title>RE: nrf51822 app timer</title><link>https://devzone.nordicsemi.com/thread/163069?ContentTypeID=1</link><pubDate>Thu, 27 Dec 2018 13:14:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6b42b335-0ec7-44b2-b7ee-665aa6084971</guid><dc:creator>claudea159</dc:creator><description>&lt;p&gt;&lt;span&gt;NRF_TIMER2-&amp;gt;MODE = TIMER_MODE_MODE_Counter; // Set the timer in Counter Mode&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You are setting up the timer in counter mode, you need &lt;span style="text-decoration:underline;"&gt;&lt;strong&gt;timer mode:&lt;/strong&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;NRF_TIMER2-&amp;gt;MODE = TIMER_MODE_MODE_Timer; // Set the timer in Timer Mode&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf51822 app timer</title><link>https://devzone.nordicsemi.com/thread/132566?ContentTypeID=1</link><pubDate>Sun, 20 May 2018 19:42:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:150e0c8f-7779-4dc1-9162-b56a62074304</guid><dc:creator>AmbystomaLabs</dc:creator><description>&lt;p&gt;And Ole from Nordic did a nice write up of the app_timer here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/515/app_scheduler-app_timer/2677#2677"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/515/app_scheduler-app_timer/2677#2677&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf51822 app timer</title><link>https://devzone.nordicsemi.com/thread/132564?ContentTypeID=1</link><pubDate>Sun, 20 May 2018 16:19:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97640f61-9000-4dc3-842a-ccc0d3ec5064</guid><dc:creator>AmbystomaLabs</dc:creator><description>&lt;p&gt;Yeah, I know you didn&amp;#39;t literally mean app_timer.&amp;nbsp; That was just my bad attempt at a pun.&lt;/p&gt;
&lt;p&gt;This is based on SDK11, but I think it is similar for all. Everything can be put in main.c if you wish.&lt;/p&gt;
&lt;p&gt;#include &amp;quot;app_timer.h&amp;quot;&lt;/p&gt;
&lt;p&gt;APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false);&lt;/p&gt;
&lt;p&gt;APP_TIMER_DEF(m_your_timer_id);&lt;br /&gt;err_code = app_timer_create(&amp;amp;m_your_timer_id, APP_TIMER_MODE_REPEATED, your_timer_handler);&lt;br /&gt;APP_ERROR_CHECK(err_code);&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;err_code = app_timer_start(m_your_timer_id, APP_TIMER_TICKS(3630000, APP_TIMER_PRESCALER), NULL);&lt;br /&gt;APP_ERROR_CHECK(err_code);&lt;/p&gt;
&lt;p&gt;static void your_timer_handler(void * p_context)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; Your code goes here;&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Most of the examples utilize the app_timer so you may not be able to change the prescaler.&amp;nbsp; But basically you can use the app_timer to make as many timers as you wish with different attributes and different handlers.&amp;nbsp; The prescaler sets the basic resolution of the timer or systick. Then you are always creating a timer based on how many ticks it requires. You can always change advertising data on the fly since you are just changing the info in the data structure it points to.&lt;/p&gt;
&lt;p&gt;Depending on the type of device you are creating (eg, beacon), you could also approach your solution using Radio Notification. With radio notification a system event generates an interrupt for getting ready to transmit and also for finished transmitting.&amp;nbsp; I find radio notification very handy since I know the state of the radio when I wish to modify something.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf51822 app timer</title><link>https://devzone.nordicsemi.com/thread/132549?ContentTypeID=1</link><pubDate>Sat, 19 May 2018 15:51:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab3b224e-fbf2-4de0-aef9-4412535b9884</guid><dc:creator>Alex Co</dc:creator><description>&lt;p&gt;Thanks for your explanation. Very clear!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;PS: I called app timer on the subject due to &amp;quot;app layer&amp;quot;&amp;nbsp;timer creation but it seems that there is an code class to address it with the same name. Thanks! I am going to read about it&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf51822 app timer</title><link>https://devzone.nordicsemi.com/thread/132548?ContentTypeID=1</link><pubDate>Sat, 19 May 2018 15:02:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55979eaf-b972-4f6e-ac1b-04cdff82ca3a</guid><dc:creator>AmbystomaLabs</dc:creator><description>&lt;p&gt;Your subject line mentions &amp;quot;app_timer&amp;quot; and indeed that is how you should be doing this.&amp;nbsp; The app_timer module in the SDK is a really easy and reliable way to create general purpose timers.&amp;nbsp; It can keep you from making all manner of mistakes with the general timers.&lt;/p&gt;
&lt;p&gt;In your example you make the mistake of setting timer 2 as a counter, instead of timer. Counters count, timers time.&lt;/p&gt;
&lt;p&gt;Also, using timer 2 for this function is kind of overkill since it runs on HF_clk and not the RTC. HF_clk uses substantially more power than the RTC.&lt;/p&gt;
&lt;p&gt;Make your life easier and read up on the app_timer in the SDK.&amp;nbsp; There are a lot of examples on how to use it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>