<?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>Best way to sample ADC over 2 channels with 2 different sampling rate while saving power?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/58263/best-way-to-sample-adc-over-2-channels-with-2-different-sampling-rate-while-saving-power</link><description>Hi Devzone: 
 I am working on nRF52840 with latest SDK. 
 I have 1 differential pair and 1 single ended pin I want to sample, single ended samples at every 40ms while differential pair samples at every 5 second. 
 You may already guessed that 40ms sample</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 27 Feb 2020 17:37:24 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/58263/best-way-to-sample-adc-over-2-channels-with-2-different-sampling-rate-while-saving-power" /><item><title>RE: Best way to sample ADC over 2 channels with 2 different sampling rate while saving power?</title><link>https://devzone.nordicsemi.com/thread/236976?ContentTypeID=1</link><pubDate>Thu, 27 Feb 2020 17:37:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4465d19-bb30-4bf3-b4e9-d720fd9561b5</guid><dc:creator>cpeng</dc:creator><description>&lt;p&gt;Thanks!&lt;/p&gt;
&lt;p&gt;One&amp;nbsp;area i am still blurry is:&lt;/p&gt;
&lt;p&gt;What&amp;#39;s the relationship between Low power mode and oversampling/ burst?&lt;/p&gt;
&lt;p&gt;If I want to oversample mutiple channels and have their samples averged out, what should I do?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It seems&amp;nbsp;oversampling+scan will mix up samples from different channels and mess up the value.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;What role does burst mode come into play?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to sample ADC over 2 channels with 2 different sampling rate while saving power?</title><link>https://devzone.nordicsemi.com/thread/236901?ContentTypeID=1</link><pubDate>Thu, 27 Feb 2020 14:13:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b60eee2-530f-466a-9e42-a3a0d7423b55</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user="cpeng"]1. I&amp;nbsp;wonder if you could explain&amp;nbsp;how app timer is used in SAADC project?[/quote]
&lt;p&gt;The &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/lib_timer.html"&gt;app_timer&lt;/a&gt; is not used in the SAADC driver or example project in the SDK. However, it is just a simple library that uses an RTC instance to get callbacks sometime in the future. For (re)configuring and sampling the SAADC regularly at a low frequency, you could set up a repeating timer and to the reconfiguration and sampling.&lt;/p&gt;
[quote user="cpeng"]2. Can you provide code as when and how to unit a channel? I don&amp;#39;t see a &amp;quot;saadc_uninit&amp;quot; function provided with example project.[/quote]
&lt;p&gt;There is no example of un-initing, but essentially you just call the un-init-function(s) as needed after sampling is done. You have the&amp;nbsp;nrf_drv_saadc_channel_uninit() for un-initin channels, and&amp;nbsp;nrf_drv_saadc_uninit() if you want to un-init the driver itself.&lt;/p&gt;
&lt;p&gt;[quote user="cpeng"][/quote]&lt;/p&gt;
&lt;p&gt;In function &amp;quot;&lt;strong&gt;saadc_sampling_event_init&lt;/strong&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;we have&amp;nbsp;&lt;/p&gt;
&lt;p&gt;uint32_t ticks = nrf_drv_timer_ms_to_ticks(&amp;amp;m_timer, 400);&lt;/p&gt;
&lt;p&gt;1. Does this mean&amp;nbsp;&lt;strong&gt;saadc_callback&amp;nbsp;&lt;/strong&gt;will be fired at every 400 ms?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Yes.&lt;/p&gt;
[quote user="cpeng"]2. If we need to sample at under 1ms, say 40 us, how do we write the function? It seems 1ms is the limit.[/quote]
&lt;p&gt;The tick rate of the timer is much higher, so you just need to use another conversion function.&amp;nbsp;nrf_drv_timer_us_to_ticks() is also available and should do the trick in this case.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to sample ADC over 2 channels with 2 different sampling rate while saving power?</title><link>https://devzone.nordicsemi.com/thread/236656?ContentTypeID=1</link><pubDate>Wed, 26 Feb 2020 19:13:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:23b044d5-73d9-4d1b-804d-16f375c5c3c5</guid><dc:creator>cpeng</dc:creator><description>&lt;p&gt;Hi Einar, thanks for reaching out to help.&lt;/p&gt;
&lt;p&gt;&amp;quot;&lt;span&gt;&amp;nbsp;You could use an app timer to handle regular reconfiguration and sampling.&amp;nbsp;&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;1. I&amp;nbsp;wonder if you could explain&amp;nbsp;how app timer is used in SAADC project?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;2. Can you provide code as when and how to unit a channel? I don&amp;#39;t see a &amp;quot;saadc_uninit&amp;quot; function provided with example project.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Also I need help changing sampling rate.&lt;/p&gt;
&lt;p&gt;In function &amp;quot;&lt;strong&gt;saadc_sampling_event_init&lt;/strong&gt;&amp;quot;&lt;/p&gt;
&lt;p&gt;we have&amp;nbsp;&lt;/p&gt;
&lt;p&gt;uint32_t ticks = nrf_drv_timer_ms_to_ticks(&amp;amp;m_timer, 400);&lt;/p&gt;
&lt;p&gt;1. Does this mean&amp;nbsp;&lt;strong&gt;saadc_callback&amp;nbsp;&lt;/strong&gt;will be fired at every 400 ms?&lt;/p&gt;
&lt;p&gt;2. If we need to sample at under 1ms, say 40 us, how do we write the function? It seems 1ms is the limit.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Best way to sample ADC over 2 channels with 2 different sampling rate while saving power?</title><link>https://devzone.nordicsemi.com/thread/236460?ContentTypeID=1</link><pubDate>Wed, 26 Feb 2020 09:28:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10cd899d-9f11-438d-ad4e-ed97a99d012d</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]This is easily achievable with sampling both channels at 40ms and discard samples for voltage. But I am afraid it might be &lt;strong&gt;a wasteful of resources if samples are discarded.&lt;/strong&gt;[/quote]
&lt;p&gt;If you want to avoid reconfiguration, sampling both channels every 40 ms is the only option, as scan mode always samples all channels in sequence.&lt;/p&gt;
&lt;p&gt;[quote user=""][/quote]&lt;/p&gt;
&lt;p&gt;init one channel, sample at 40ms, get samples, unit,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;init another channel, sample at 5 second, unit.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;This seems like the most natural option to me in this case with long sampling intervals. You could use an app timer to handle regular reconfiguration and sampling. This way, the &lt;em&gt;average&lt;/em&gt; sampling interval will be as accurate as the LFCLK. There will be jitter, but that should not matter in such a use case.&lt;/p&gt;
&lt;p&gt;[quote user=""][/quote]&lt;/p&gt;
&lt;p&gt;2. use low power mode + burst mode&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So please recommend the details of what&amp;#39;s the most efficient solution to this problem. I noticed there are many posts on this topic, the problem is that I am not very sure if they are&amp;nbsp;up-to-date.&lt;/p&gt;
&lt;p&gt;Please include detail as:&lt;/p&gt;
&lt;p&gt;How to enable burst mode? In sdk_config I only saw low power mode enabling option.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;To enable burst mode you set the&amp;nbsp;burst field in the configuration struct (nrf_saadc_channel_config_t) to&amp;nbsp;NRF_SAADC_BURST_ENABLED. Note that you typically do not want to combine scan and burst, as described &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/20556/how-does-the-saadc-scan-mode-use-the-burst-1/80141#80141"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>