<?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>doubt with saadc example from SDK</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/17760/doubt-with-saadc-example-from-sdk</link><description>Hello! 
 I&amp;#39;m learning how to use properly the saadc for knowing muy battery state of discharge. First of all I&amp;#39;m testing the saadc example which is included in the SDK, changing paramenters, understaning the functions...etc. 
 In this function in particular</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 24 Nov 2016 11:19:03 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/17760/doubt-with-saadc-example-from-sdk" /><item><title>RE: doubt with saadc example from SDK</title><link>https://devzone.nordicsemi.com/thread/68394?ContentTypeID=1</link><pubDate>Thu, 24 Nov 2016 11:19:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51499f5d-e5fb-4204-aa66-e8039380413d</guid><dc:creator>andribiotico</dc:creator><description>&lt;p&gt;thnak you!!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: doubt with saadc example from SDK</title><link>https://devzone.nordicsemi.com/thread/68393?ContentTypeID=1</link><pubDate>Wed, 16 Nov 2016 13:42:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef6bba02-7767-47f0-8211-2bd52f1d4d4a</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The default frequency of TIMER0 is 16 MHz. If you have not changed this, the return value of &lt;code&gt;nrf_drv_timer_ms_to_ticks()&lt;/code&gt; will overflow the uint32_t return variable.&lt;/p&gt;
&lt;p&gt;The function calculates the number of ticks using the formula:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(time_ms * 16000 kHz) / (2^prescaler)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;where prescaler is related to frequency like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;f = 16000 kHz / 2^prescaler
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With the timer frequency set to 16 MHz, this will give a prescaler value of 0. For 5 minutes, the formula then return:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;4800000000 &amp;gt; 4294967295
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This overflow of the uint32_t variable will give a return value from &lt;code&gt;nrf_drv_timer_ms_to_ticks()&lt;/code&gt; of 505032704. There is a ASSERT check within the function to avoid this overflow, but this does not seem to fire. I will check this out.&lt;/p&gt;
&lt;p&gt;To run timers for longer time than ~4.48 minutes, you will have to set a lower frequency of the timer. You can do this when configuring your timer with the following lines:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nrf_drv_timer_config_t m_timer_config= NRF_DRV_TIMER_DEFAULT_CONFIG(0);
m_timer_config.frequency = NRF_TIMER_FREQ_8MHz;
err_code = nrf_drv_timer_init(&amp;amp;m_timer, &amp;amp;m_timer_config, timer_handler);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Or you can set the prescaler value directly:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_TIMER0-&amp;gt;PRESCALER = 1;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Notice that you cannot use the &lt;code&gt;nrf_drv_timer_ms_to_ticks()&lt;/code&gt; function for values above (2^32)/16000 ~= 268435ms. You can still do the calculation yourself, or create your own function to do this calculation for larger values.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>