<?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>Selective sampling of ADC channels at run time</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/71658/selective-sampling-of-adc-channels-at-run-time</link><description>I am using a 52810 custom board and the SAADC module. 
 It is used for sampling one analog input through AIN2 and the battery voltage directly by setting the pin to VDD 
 As per the documentation, since more than one channel is configured/enabled, it</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 10 Mar 2021 12:31:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/71658/selective-sampling-of-adc-channels-at-run-time" /><item><title>RE: Selective sampling of ADC channels at run time</title><link>https://devzone.nordicsemi.com/thread/298982?ContentTypeID=1</link><pubDate>Wed, 10 Mar 2021 12:31:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d4786ff6-63e3-4d54-ab1d-d3a09ad6aa3a</guid><dc:creator>SChary</dc:creator><description>&lt;p&gt;Hello Einar,&lt;/p&gt;
&lt;p&gt;i haven&amp;#39;t yet gotten around to making the measurement you suggested. Will revert to you shortly, once i am out of the problem that is currently bothering me.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Chary BS&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Selective sampling of ADC channels at run time</title><link>https://devzone.nordicsemi.com/thread/298103?ContentTypeID=1</link><pubDate>Fri, 05 Mar 2021 13:33:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cbc79fdc-35a1-4741-8483-dfb0dde15269</guid><dc:creator>SChary</dc:creator><description>&lt;p&gt;Hello Patrick,&lt;/p&gt;
&lt;p&gt;Thank you for the reference! I have still not moved to the V2 api, am using the older version itself and am testing to see if there are any quirks....&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Chary BS&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Selective sampling of ADC channels at run time</title><link>https://devzone.nordicsemi.com/thread/296596?ContentTypeID=1</link><pubDate>Fri, 26 Feb 2021 14:48:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ff54eb9-4171-4ccf-ab3d-38d34ce47037</guid><dc:creator>Patrick</dc:creator><description>&lt;p&gt;Take a look at my &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/67040/saadc-v2-sample-values-low"&gt;ticket here&lt;/a&gt;, where I discovered that channel configuration is reset by the driver, causing readings to be incorrect. Channel configuration will need to be applied prior to sampling with the V2 driver due to the way the registers are reset internally to the driver due to a high power consumption workaround.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Selective sampling of ADC channels at run time</title><link>https://devzone.nordicsemi.com/thread/296589?ContentTypeID=1</link><pubDate>Fri, 26 Feb 2021 14:23:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7847e706-6c98-4f9a-8022-4b2b9dfe52d3</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Chary,&lt;/p&gt;
[quote user="SChary"]Only one observation is that the VDD measurement seems to be off by about 0.3V. [/quote]
&lt;p&gt;Using the internal reference you should definitely not see an offset of 0.3 V. Perhaps the issue is related to the nRF drawing more current while sampling, and that it affects the measurement results? Can you check with an oscilloscope probing on the VDD pins on the chip to see if that is the case? How stable is the plot you get on the oscilloscope in this case?&lt;/p&gt;
[quote user="SChary"]For the help regarding calendar implementation using app_timer i have raised a separate ticket.. as it is a different topic and i felt i should not mix the two issues.[/quote]
&lt;p&gt;That makes a lot of sense, so thank you for that.&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Selective sampling of ADC channels at run time</title><link>https://devzone.nordicsemi.com/thread/296492?ContentTypeID=1</link><pubDate>Fri, 26 Feb 2021 11:07:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:69ce461c-69e9-4052-8dfe-a94c8d598b80</guid><dc:creator>SChary</dc:creator><description>&lt;p&gt;Hello Einar,&lt;/p&gt;
&lt;p&gt;I have implemented the saadc_init(0 and saadc_uninit() sequence to switch between AIN2 and VDD as and when required.&lt;/p&gt;
&lt;p&gt;It is working fine, thank you !&lt;/p&gt;
&lt;p&gt;Only one observation is that the VDD measurement seems to be off by about 0.3V. And also, it is taking three measurements to get a stable value - I am taking 10 samples in each measurement and averaging them. The averaged reading&amp;nbsp; starts with a little lower value and keeps rising towards the actual value, after three successive readings it gives a consistent value of Vdd - 0.3V. Any ideas as to how to improve the accuracy ? For a CR2032 battery @3.0V, a deviation of 0.3V makes a big difference when estimating the battery level.....&lt;/p&gt;
&lt;p&gt;My settings are :12bit, internal reference with 1/6 gain and channel input set to VDD.&lt;/p&gt;
&lt;p&gt;For the help regarding calendar implementation using app_timer i have raised a separate ticket.. as it is a different topic and i felt i should not mix the two issues.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Chary BS&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Selective sampling of ADC channels at run time</title><link>https://devzone.nordicsemi.com/thread/295777?ContentTypeID=1</link><pubDate>Tue, 23 Feb 2021 10:06:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2be6dd05-89e7-4b4d-95c4-947a06d9ac39</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Chary,&lt;/p&gt;
&lt;p&gt;1. I cannot say if the SAADC related code is responsible for your high current consumption without knowing more about your application. In general, if you do not need to sample with a very high frequency and very high accuracy (the former would prevent a low power solution anyway), then you can trigger SAADC sampling from SW regularly from an app timer. This makes the SAADC driver low power mode concept irrelevant.&lt;/p&gt;
&lt;p&gt;2. Yes you can do this by basing your calendar clock on the app timer. You may have some jitter, but the average accuracy would be equal to the accuracy of your 32.768 kHz clock source (so if you use a 20 ppm crystal, that is the accuracy you get).&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Selective sampling of ADC channels at run time</title><link>https://devzone.nordicsemi.com/thread/295728?ContentTypeID=1</link><pubDate>Tue, 23 Feb 2021 04:36:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:883f6900-bedf-4221-9ddc-a86642c139cf</guid><dc:creator>SChary</dc:creator><description>&lt;p&gt;Ok, i will do as you said and try to use the V2 API. But before that i have two small queries - &lt;/p&gt;
&lt;p&gt;1. As you know the 52810 has only two RTCs. I am using the soft device so RTC0 is dedicated for that. And RTC1 is used for app_timer.&amp;nbsp; I saw an saadc low power example on the Devzone that uses RTC instead of timer for lower power consumption, however, it is written for the 52832 and uses RTC2, which&amp;nbsp; does not exist on the 52810. Is there a way by which i can implement that on the 52810 ? Because mine is a battery operated device and i find that the battery drains very fast...it must be due to this ?&lt;/p&gt;
&lt;p&gt;2. I need to implement a calendar clock functionality on the 52810 without using any external RTC chip. The accuracy need not be very high, up to seconds level. Even if it is accurate up to a minute it is sufficient... with periodic correction from a smart phone. Is it possible to&amp;nbsp; do this ?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Sreenivasa Chary&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Selective sampling of ADC channels at run time</title><link>https://devzone.nordicsemi.com/thread/295492?ContentTypeID=1</link><pubDate>Mon, 22 Feb 2021 08:25:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2feaea70-901b-4a6b-b646-af524ff3b090</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Chary,&lt;/p&gt;
&lt;p&gt;No, the SAADC driver is completely independent from the SoftDevice. The V2 API is included in SDK 17.x.x.&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Selective sampling of ADC channels at run time</title><link>https://devzone.nordicsemi.com/thread/295469?ContentTypeID=1</link><pubDate>Sun, 21 Feb 2021 23:15:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:205b38e0-d446-4ce5-8b77-ab5730322f64</guid><dc:creator>SChary</dc:creator><description>&lt;p&gt;Thank you Einar for the update. This new API V2, does it have any dependency with the soft device version ?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am using SDK17.0.0_9d13099, S112...&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Chary BS&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Selective sampling of ADC channels at run time</title><link>https://devzone.nordicsemi.com/thread/295346?ContentTypeID=1</link><pubDate>Fri, 19 Feb 2021 13:14:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2fcb79a2-0f5f-4b14-bb62-94a1dcc870d2</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Chary,&lt;/p&gt;
&lt;p&gt;There are no problems initing and uniniting. But you are right you should take care to wait for an ongoing operation to finish before uninitializing as the driver do not handle&lt;/p&gt;
&lt;p&gt;There should not be any resource fragmentation issues. However, if you uninit and re-init then you may se some issues which are solved by the new driver API, nrfx_saadc_v2, as it is more robust. So you may want to start using that. In that case you can refer to the nrfx_saadc_v2.h file for the API, and define&amp;nbsp;NRFX_SAADC_API_V2 for the project. You can refer to the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/migration.html?cp=7_1_1_7#migr_lib_nrfx"&gt;migration document&lt;/a&gt; which links to some official examples and &lt;a href="https://github.com/einarthorsrud/nrfx_saadc_v2_multi_channel_ppi"&gt;this unofficial example&lt;/a&gt; demonstrating regular sampling of multiple channels if you want to consider using the V2 implementation.&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Selective sampling of ADC channels at run time</title><link>https://devzone.nordicsemi.com/thread/295247?ContentTypeID=1</link><pubDate>Fri, 19 Feb 2021 04:49:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c7b151d7-e6cb-44ef-94ef-dc31d9c93774</guid><dc:creator>SChary</dc:creator><description>&lt;p&gt;Hello Einar,&lt;/p&gt;
&lt;p&gt;I see that this ticket is still not closed from your side. Luckily, I had another query about the SAADC usage&lt;/p&gt;
&lt;p&gt;Continuing in the same thread, i wanted to ask how to do the following, in terms of initializing and un-initializing the ADC and its channels&lt;/p&gt;
&lt;p&gt;In my system, as mentioned earlier, i have to capture the signal at AIN2 and the battery voltage, but not simultaneously.&lt;/p&gt;
&lt;p&gt;So can I do nrfx_saadc_channel_init() and nrfx_saadc_channel_uninit() as and when required ? Will there be any resource fragmentation issues with that ?&lt;/p&gt;
&lt;p&gt;Do i have to check for ADC busy or idle state before calling uninit or is it taken care internally?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks in advance&lt;/p&gt;
&lt;p&gt;Chary BS&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Selective sampling of ADC channels at run time</title><link>https://devzone.nordicsemi.com/thread/294734?ContentTypeID=1</link><pubDate>Wed, 17 Feb 2021 00:38:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef44752c-a807-43ea-b3e3-9e333825373e</guid><dc:creator>SChary</dc:creator><description>&lt;p&gt;You may close this ticket :-)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Sreenivasa Chary&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Selective sampling of ADC channels at run time</title><link>https://devzone.nordicsemi.com/thread/294653?ContentTypeID=1</link><pubDate>Tue, 16 Feb 2021 14:22:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6245ffe6-a008-424c-b607-c53eeb19913c</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Chary,&lt;/p&gt;
&lt;p&gt;Good to hear you found it. Essentially it is just the offset in the buffer. So the first channel is at position 0, second enabled channel in position 1 and so on. I will forward your suggestion, though I do not expect any updates in the API any time soon.&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Selective sampling of ADC channels at run time</title><link>https://devzone.nordicsemi.com/thread/294612?ContentTypeID=1</link><pubDate>Tue, 16 Feb 2021 12:05:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a797150-6335-4f95-9ea7-d09ff2c0183c</guid><dc:creator>SChary</dc:creator><description>&lt;p&gt;Hi Einar, &lt;/p&gt;
&lt;p&gt;This example from Nordic confirmed the answer to my question - it seems a trivial question in hind sight :-)&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/NordicPlayground/nRF52-ADC-examples/blob/master/ble_app_uart__saadc_timer_driven__scan_mode/main.c"&gt;https://github.com/NordicPlayground/nRF52-ADC-examples/blob/master/ble_app_uart__saadc_timer_driven__scan_mode/main.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;But it would be good to have a channel index returned along with the callback, so that we can identify the data source and apply any processing logic based on that.... just a suggestion from my side !&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Cheers&lt;/p&gt;
&lt;p&gt;Chary BS&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Selective sampling of ADC channels at run time</title><link>https://devzone.nordicsemi.com/thread/294605?ContentTypeID=1</link><pubDate>Tue, 16 Feb 2021 11:52:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ebbfb1c1-5264-4ca2-a8bd-d8fb041d2fd8</guid><dc:creator>SChary</dc:creator><description>&lt;p&gt;And also, is there a way to know which channel&amp;#39;s readings are being returned in the callback ? OR do we have to maintain a static variable as a flag to toggle or sequence through the number of channels every time the callback is called?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Selective sampling of ADC channels at run time</title><link>https://devzone.nordicsemi.com/thread/294600?ContentTypeID=1</link><pubDate>Tue, 16 Feb 2021 11:50:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f837d446-f898-4c9a-b460-343186df2171</guid><dc:creator>SChary</dc:creator><description>&lt;p&gt;Hello Einar, &lt;/p&gt;
&lt;p&gt;Thanks for the clarification ....&lt;/p&gt;
&lt;p&gt;Is the following code correct in order to add the second channel to the SAADC initial configuration? I just added channel to use VDD as input.. andinitialized it.&lt;/p&gt;
&lt;p&gt;&amp;lt;code&amp;gt;&lt;/p&gt;
&lt;p&gt;void saadc_init(void)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ret_code_t err_code;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; nrf_saadc_channel_config_t channel0_config =&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN2);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; nrf_saadc_channel_config_t channel1_config =&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_VDD);&amp;nbsp;&amp;nbsp; //To measure the battery voltage.&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; err_code = nrf_drv_saadc_init(NULL, saadc_callback);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; APP_ERROR_CHECK(err_code);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; err_code = nrf_drv_saadc_channel_init(0, &amp;amp;channel0_config);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; APP_ERROR_CHECK(err_code);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; err_code = nrf_drv_saadc_channel_init(1, &amp;amp;channel1_config);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; APP_ERROR_CHECK(err_code);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[0], SAMPLES_IN_BUFFER);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; APP_ERROR_CHECK(err_code);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[1], SAMPLES_IN_BUFFER);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; APP_ERROR_CHECK(err_code);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;&amp;lt;/code&amp;gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Chary BS&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Selective sampling of ADC channels at run time</title><link>https://devzone.nordicsemi.com/thread/294579?ContentTypeID=1</link><pubDate>Tue, 16 Feb 2021 11:09:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd243b1c-0b00-4e4d-a500-75cc69f4279d</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi Chary,&lt;/p&gt;
&lt;p&gt;You will always sample all configured channels. So if you&amp;nbsp;only want to sample battery voltage every now and then you need to reconfigure the SAADC. An alternative could be to also sample the battery voltage every time, but ignore the samples most of the time unless when you want to process it.&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>