<?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>&amp;quot;Right way&amp;quot; to oversample+burst multiple SAADC input pins.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/71704/right-way-to-oversample-burst-multiple-saadc-input-pins</link><description>Context: nrf52840DK, s140, SDK 17.0.2 
 Hi, 
 I need to oversample a few ADC pins with burst enabled at roughly the same time periodically: e.g. oversampling 4 separate inputs, every 10 seconds. 
 I&amp;#39;ve been doing my best to follow the advice on this forum</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 19 Feb 2021 13:11:26 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/71704/right-way-to-oversample-burst-multiple-saadc-input-pins" /><item><title>RE: "Right way" to oversample+burst multiple SAADC input pins.</title><link>https://devzone.nordicsemi.com/thread/295345?ContentTypeID=1</link><pubDate>Fri, 19 Feb 2021 13:11:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:24a22e1f-6af8-4a7c-9238-842d6924bad6</guid><dc:creator>Patrick</dc:creator><description>&lt;p&gt;Take a look at the examples in &lt;a href="https://github.com/NordicPlayground/nRF52-ADC-examples/tree/master/nrfx_saadc_simple_low_power_app_timer_multichannel_oversample"&gt;this repository&lt;/a&gt; for the SAADC API V2. I have been using it in a project of mine without issue. I also have a ticket here somewhere discussing a configuration issue that occurs if your channels use different reference voltages that may help you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: "Right way" to oversample+burst multiple SAADC input pins.</title><link>https://devzone.nordicsemi.com/thread/295004?ContentTypeID=1</link><pubDate>Thu, 18 Feb 2021 08:35:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:180eea9e-5fd5-4e3f-ab14-fdd3f380d223</guid><dc:creator>Kenneth</dc:creator><description>[quote user="kalknight"]Seeing as I am using the soft device, am I able to increase the priority level of the SAADC to level 5? Or is that reserved and instead do I need to downgrade the priority of the app_timer to 7?[/quote]
&lt;p&gt;Here you can find an overview of available interrupts for the application:&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/processor_avail_interrupt_latency/exception_mgmt_sd.html"&gt;https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/processor_avail_interrupt_latency/exception_mgmt_sd.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can&amp;#39;t do any softdevice api calls from priority 2 and 3, else&amp;nbsp;you can do what you want.&amp;nbsp;&lt;/p&gt;
[quote user="kalknight"]This is basically what I have been doing, however can I confirm whether I need to also init &amp;amp; uinit the saadc each time I want to&amp;nbsp;init &amp;amp; uninit the channels?[/quote]
&lt;p&gt;It should not be required to unint and init every time no, however I do believe you want to unint (when SAADC is not in use) to save power.&lt;/p&gt;
&lt;p&gt;Make sure you are only calling&amp;nbsp;&lt;span&gt;buffer_convert() one time for each&amp;nbsp;sample().&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: "Right way" to oversample+burst multiple SAADC input pins.</title><link>https://devzone.nordicsemi.com/thread/294969?ContentTypeID=1</link><pubDate>Thu, 18 Feb 2021 00:15:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:09cb4604-7b38-4667-8c93-9efac504c6fa</guid><dc:creator>kalknight</dc:creator><description>&lt;p&gt;Hi Kenneth,&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;span&gt;In such it may make sense that the SAADC callback have higher interrupt priority than the app_timer callback.&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Seeing as I am using the soft device, am I able to increase the priority level of the SAADC to level 5? Or is that reserved and instead do I need to downgrade the priority of the app_timer to 7?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;In any case you typically would need to do the following for each of the 4 inputs:&lt;/p&gt;
&lt;p&gt;saadc_init()&lt;br /&gt;channel0_init() //this will change depending which pin should be oversampled&lt;br /&gt;buffer_convert() //prepare buffer&lt;br /&gt;sample() //execute oversampling on channel0&lt;br /&gt;//wait data is ready&lt;br /&gt;channel0_uninit()&lt;br /&gt;saadc_uninit()&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is basically what I have been doing, however can I confirm whether I need to also init &amp;amp; uinit the saadc each time I want to&amp;nbsp;init &amp;amp; uninit the channels?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So far I have been trying to sample in a non-blocking way but I&amp;#39;ll attempt it with the blocking way to see if I can get it to work.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: "Right way" to oversample+burst multiple SAADC input pins.</title><link>https://devzone.nordicsemi.com/thread/294860?ContentTypeID=1</link><pubDate>Wed, 17 Feb 2021 12:52:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8734f826-4a36-4fc0-9849-74ae289fabca</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;If you are using oversampling, then only 1 saadc channel can be configured. So if you need to oversample 4 inputs, then you would to reconfigure saadc channel0 between each (over)sampling.&lt;/p&gt;
&lt;p&gt;There are many ways this can be solved, you can for instance have an app_timer that initiate sampling every 2.5seconds, the timer callback can use a static counter%4&amp;nbsp;to ensure that you reconfigure channel0 so that every input is sampled.&lt;/p&gt;
&lt;p&gt;Usage of the saadc driver is explained here:&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/hardware_driver_saadc.html#saadc_using"&gt;https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/hardware_driver_saadc.html#saadc_using&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;If you are not using blocking mode, then you need to wait for the saadc callback before the data is ready. In such it may make sense that the SAADC callback have higher interrupt priority than the app_timer callback.&lt;/p&gt;
&lt;p&gt;In any case you typically would need to do the following for each of the 4 inputs:&lt;/p&gt;
&lt;p&gt;saadc_init()&lt;br /&gt;channel0_init() //this will change depending which pin should be oversampled&lt;br /&gt;buffer_convert() //prepare buffer&lt;br /&gt;sample() //execute oversampling on channel0&lt;br /&gt;//wait data is ready&lt;br /&gt;channel0_uninit()&lt;br /&gt;saadc_uninit()&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>