<?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 with prescaling</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/59429/timer-with-prescaling</link><description>I use sdk 15.3.0 / nrf52832 / SD_132. 
 How to use the prescaler of a timer for an event every 24 hours ? 
 An example will be very explicit. 
 Best regards, Jiemde</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 24 Mar 2020 15:01:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/59429/timer-with-prescaling" /><item><title>RE: Timer with prescaling</title><link>https://devzone.nordicsemi.com/thread/241417?ContentTypeID=1</link><pubDate>Tue, 24 Mar 2020 15:01:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3f7a13e-e2ec-4f25-b484-dc8fd5375807</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Jiemde,&lt;/p&gt;
[quote user="Jiemde"]I&amp;#39;m not yet &amp;quot;comfortable&amp;quot; with sdk.config[/quote]
&lt;p&gt;I completely understand, no problem at all.&lt;br /&gt;&lt;br /&gt;Have you seen the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/group__nrfx__timer.html"&gt;TIMER API Reference&lt;/a&gt;? Particularly, bit_width is set during initialization - see the input parameters to the&amp;nbsp;&lt;em&gt;nrfx_timer_init&lt;/em&gt; function.&lt;br /&gt;I think this is what you are looking for, rather than the sdk_config.h. The lines you are referring to in the sdk_config is the DEFAULT_CONFIG parameters.&lt;br /&gt;&lt;br /&gt;Is this what you were looking for?&lt;br /&gt;Please let me know if you should have more questions or encounter any other issues! :)&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer with prescaling</title><link>https://devzone.nordicsemi.com/thread/241397?ContentTypeID=1</link><pubDate>Tue, 24 Mar 2020 13:55:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c49705e7-bf6b-440b-a8c3-0ef54bc799c8</guid><dc:creator>Jean-marie</dc:creator><description>&lt;p&gt;Hi Karl, Thanks for fast reply.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not yet &amp;quot;comfortable&amp;quot; with sdk.config, so for the &amp;quot;BITMODES&amp;quot;, I suppose you speak about:&lt;/p&gt;
&lt;p&gt;// &amp;lt;o&amp;gt; TIMER_DEFAULT_CONFIG_MODE - Timer mode or operation&lt;br /&gt; &lt;br /&gt;// &amp;lt;0=&amp;gt; Timer &lt;br /&gt;// &amp;lt;1=&amp;gt; Counter&lt;/p&gt;
&lt;p&gt;#ifndef TIMER_DEFAULT_CONFIG_MODE&lt;br /&gt;#define TIMER_DEFAULT_CONFIG_MODE 0&lt;br /&gt;#endif&lt;/p&gt;
&lt;p&gt;// &amp;lt;o&amp;gt; TIMER_DEFAULT_CONFIG_BIT_WIDTH - Timer counter bit width&lt;br /&gt; &lt;br /&gt;// &amp;lt;0=&amp;gt; 16 bit &lt;br /&gt;// &amp;lt;1=&amp;gt; 8 bit &lt;br /&gt;// &amp;lt;2=&amp;gt; 24 bit &lt;br /&gt;// &amp;lt;3=&amp;gt; 32 bit&lt;/p&gt;
&lt;p&gt;#ifndef TIMER_DEFAULT_CONFIG_BIT_WIDTH&lt;br /&gt;#define TIMER_DEFAULT_CONFIG_BIT_WIDTH 3&lt;br /&gt;#endif&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Question: where can I set the timer prescaler ?&lt;/p&gt;
&lt;p&gt;Is there an example for references ?&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;
&lt;p&gt;Jiemde&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer with prescaling</title><link>https://devzone.nordicsemi.com/thread/241314?ContentTypeID=1</link><pubDate>Tue, 24 Mar 2020 10:18:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0ace49b7-6d7f-4fb8-bf95-ce1e3f308d0a</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;Have you seen the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Ftimer.html&amp;amp;anchor=concept_xbd_hqp_sr"&gt;Timer documentation&lt;/a&gt;&amp;nbsp;regarding prescaler options?&lt;br /&gt;&lt;br /&gt;As you see from the prescaler register, you may at most set the timer prescaler to 2^9, which gives you 16M / 512 = 31250 ticks per second.&lt;br /&gt;So, then we need to establish the size of our TIMER. We see that the different BITMODES available ranges from 8 to 32 bit.&lt;br /&gt;Setting it to 32 bit gives us&amp;nbsp;&lt;span&gt;4294967296 ticks til overflow, which with the 512 prescaler gives us ~36 hours till overflow.&lt;br /&gt;&lt;/span&gt;Thus, you may set the timer to compare for the value 2700000000 - which is ticks per second times seconds in 24h.&lt;br /&gt;&lt;br /&gt;You will now receive a COMPARE event every 24h. When this happens, you should remember to also CLEAR your timer - to avoid counting all the way to 36h before restarting at 0.&lt;br /&gt;&lt;br /&gt;Is this what you were looking for?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>