<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://test-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>Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/f/nordic-q-a/71636/continuous-periodic-nrf52840-adc-sampling-with-zephyr</link><description>Hello, guys. 
 We are using Zephyr RTOS (NCS v1.4.2) with nRF52840 development kit. 
 The idea is to have continuous ADC sampling on two ADC channels. So far, I was able to properly initialize the ADC device, and get one single ADC read with the following</description><dc:language>en-US</dc:language><generator>Telligent Community 13 Non-Production</generator><lastBuildDate>Wed, 07 Apr 2021 07:26:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://test-devzone.nordicsemi.com/f/nordic-q-a/71636/continuous-periodic-nrf52840-adc-sampling-with-zephyr" /><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/303366?ContentTypeID=1</link><pubDate>Wed, 07 Apr 2021 07:26:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2c1ddab-2272-4a3e-a634-292fea584bef</guid><dc:creator>user76830</dc:creator><description>&lt;p&gt;Hey, Einar!&lt;/p&gt;
&lt;p&gt;This thread is indeed long and difficult to follow! I preferred to put the ADC-related questions here rather than to open a new ticket because I was not certain this new thread will be given to you! :-)&lt;/p&gt;
&lt;p&gt;All is good for now! Thanks for your time and great support.&lt;/p&gt;
&lt;p&gt;Cheers &lt;span class="emoticon" data-url="https://test-devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f37b.svg" title="Beers"&gt;&amp;#x1f37b;&lt;/span&gt;,&lt;/p&gt;
&lt;p&gt;Bojan.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/303364?ContentTypeID=1</link><pubDate>Wed, 07 Apr 2021 07:13:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3592437-9942-47fc-a680-13672a7b42ab</guid><dc:creator>user7377</dc:creator><description>&lt;p&gt;Hi Bojan,&lt;/p&gt;
&lt;p&gt;Ah, I see. It seems I lost my way around this thread and apparently also my memory over Easter :D Good to hear it is resolved. Thank you for reminding me &lt;span class="emoticon" data-url="https://test-devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/303270?ContentTypeID=1</link><pubDate>Tue, 06 Apr 2021 16:02:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:093a002f-b1ab-4cc7-8656-efdd14834985</guid><dc:creator>user76830</dc:creator><description>&lt;p&gt;Hi, Einar.&lt;/p&gt;
&lt;p&gt;Yes, I believe the issue is resolved now as I described above.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://test-devzone.nordicsemi.com/f/nordic-q-a/63074/buffer-order-swap-of-saadc-used-with-nrf-mesh"&gt;This thread&lt;/a&gt; helped a lot. An additional PPI channel is needed to trigger the START task on END event! All is good for now!&lt;/p&gt;
&lt;p&gt;Thank you very much for your readiness to jump in and help!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Bojan.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/303258?ContentTypeID=1</link><pubDate>Tue, 06 Apr 2021 15:21:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ab74c1ff-4c98-43f7-b136-f55b85d3b982</guid><dc:creator>user7377</dc:creator><description>&lt;p&gt;Hi Bojan,&lt;/p&gt;
&lt;p&gt;I am sorry for the late reply. I have been away&amp;nbsp;during Easter. Have you had any progress in the meantime?&lt;/p&gt;
&lt;p&gt;There have been some issues with inverted SAADC buffers, but I do not immediately see what causes it here so I need to think a bit about it and get back to you.&lt;/p&gt;
&lt;p&gt;Regarding&amp;nbsp;nrfx_saadc_v2.h in NCS the V2 API is the only available there, and is what you find in nrfx_saadc.h in NCS.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/302224?ContentTypeID=1</link><pubDate>Fri, 26 Mar 2021 19:06:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e480af1e-814b-43fa-8d8e-e7ae5c14f6f6</guid><dc:creator>user76830</dc:creator><description>&lt;p&gt;Hey, Einar.&lt;/p&gt;
&lt;p&gt;No worries. I dug deeper today and found a solution. &lt;a href="https://test-devzone.nordicsemi.com/f/nordic-q-a/63074/buffer-order-swap-of-saadc-used-with-nrf-mesh"&gt;This thread&lt;/a&gt; helped a lot. An additional PPI channel is needed to trigger the START task on END event! All is good for now!&lt;/p&gt;
&lt;p&gt;Thank you very much for your readiness to jump in and help!&lt;/p&gt;
&lt;p&gt;Happy Easter! Have a great holiday!&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Bojan.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/302221?ContentTypeID=1</link><pubDate>Fri, 26 Mar 2021 18:15:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1721c1cb-96f9-4f04-8e6e-f9dd92344383</guid><dc:creator>user7377</dc:creator><description>&lt;p&gt;Hi Bojan,&lt;/p&gt;
&lt;p&gt;I did not get a chance to look at this today unfortunately, and I am out of office the whole next week. I can look more at this in one and a half week, but if that is not early enough I suggest you open a new case with this specific issue.&lt;/p&gt;
&lt;p&gt;Regarding not finding nrfx_saadc_v2.h in latest NCS v1.5.0 that is because the V2 API is the only API that is available there, so that is what you have in nrfx_saadc.h.&lt;/p&gt;
&lt;p&gt;Happy Easter!&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/302066?ContentTypeID=1</link><pubDate>Fri, 26 Mar 2021 08:34:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:101ee05c-260f-4c05-abf0-84e64b001ce5</guid><dc:creator>user76830</dc:creator><description>&lt;p&gt;Hello, Einar.&lt;/p&gt;
&lt;p&gt;I hope you are doing well. There is one strange thing I noticed recently while playing with ADC.&lt;/p&gt;
&lt;p&gt;It can happen that the ADC samples in buffer swap the position:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://test-devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1616746214091v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;As you can see above, I am sampling only two ADC channels. My configuration is similar like I found in your &lt;a href="https://github.com/einarthorsrud/nrfx_saadc_v2_multi_channel_ppi"&gt;unofficial SAADC example&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;- There are two sampling buffers, both of size 2 (to store one ADC sample of each channel).&lt;/p&gt;
&lt;p&gt;In my particular use case, I am playing with ADC limits (both HIGH and LOW). This is working fine. For both ADC channels, I was able to set the limits and to get appropriate feedback through &lt;strong&gt;&lt;span style="background-color:#ff99cc;"&gt;NRFX_SAADC_EVT_LIMIT&lt;/span&gt; &lt;/strong&gt;in &lt;strong&gt;&lt;span style="background-color:#ccffff;"&gt;&lt;em&gt;event_handler()&lt;/em&gt;&lt;/span&gt;&lt;/strong&gt; function.&lt;/p&gt;
&lt;p&gt;The trouble sometimes comes when I want to read and process ADC samples. As you can see from the image above, the order of ADC samples in sampling buffer swaps only once, at the very beginning, and remains wrong for the rest of the application runtime.&lt;/p&gt;
&lt;p&gt;ADC sampling frequency when sample swapping occurs is equal to 1KHz. The time my application needs to read and process ADC samples is in order of 10-20us so I would not say this is an issue. The swapping occurs even when I just want to read ADC samples without any further data processing.&lt;/p&gt;
&lt;p&gt;When I slow down ADC sampling rate to 200Hz, let&amp;#39;s say, the swapping of ADC samples does not happen.&lt;/p&gt;
&lt;p&gt;Do you have any idea what I am doing wrong?&lt;/p&gt;
&lt;p&gt;Thanks in advance for your time and efforts!&lt;/p&gt;
&lt;p&gt;Cheers!&lt;/p&gt;
&lt;p&gt;Bojan&lt;/p&gt;
&lt;p&gt;P.S. I did not find &lt;span style="background-color:#ccffcc;"&gt;&lt;em&gt;nrfx_saadc_v2.h&lt;/em&gt;&lt;/span&gt; in latest NCS v1.5.0&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/299039?ContentTypeID=1</link><pubDate>Wed, 10 Mar 2021 14:17:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:063a2ce5-643c-411d-9542-bcbb3e6116d8</guid><dc:creator>user7377</dc:creator><description>&lt;p&gt;Hi Bojan,&lt;/p&gt;
[quote user="bojan"]What is the difference between version 1 and version 2 of nrfx_saadc drivers?[/quote]
&lt;p&gt;The SAADC driver was completely rewritten, so there are a number of differences. Generally, the version 2 SAADC driver includes more workarounds for HW limitations.,&lt;/p&gt;
[quote user="bojan"]Is this version 2 already included in version 1.5.0 of nRF Connect SDK?[/quote]
&lt;p&gt;Yes. nRF Connect SDK includes nrfx 2.4.0.&lt;/p&gt;
[quote user="bojan"]Finally, do you recommend using version 2 for production code?[/quote]
&lt;p&gt;For NCS, you should use the one that tis part of the NCS vision you are using (which will be version 2.x.x these days). For the nRF5 SDK 17.x.x you can choose, but I recommend using the V2 API for the SAADC.&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/298953?ContentTypeID=1</link><pubDate>Wed, 10 Mar 2021 10:17:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d917911a-22bc-4eed-9a0a-ac79af088a86</guid><dc:creator>user76830</dc:creator><description>&lt;p&gt;Thank YOU for the great support!&lt;/p&gt;
&lt;p&gt;By the way, I am using an official version of nrfx_saadc drivers that can be found under:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;ncs/v1.4.2/modules/hal/nordic/nfrx/drivers/include&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You are playing with version 2 of the nrfx_saadc drivers in your repo (&lt;a href="https://github.com/einarthorsrud/nrfx_saadc_v2_multi_channel_ppi" rel="noopener noreferrer" target="_blank"&gt;link&lt;/a&gt;). I noticed that nrfx_saadc_v2 is already included in nRF SDK 17.2 under:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;SDK_ROOT/modules/nrfx/drivers/include&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;What is the difference between version 1 and version 2 of nrfx_saadc drivers? Is this version 2 already included in version 1.5.0 of nRF Connect SDK? Finally, do you recommend using version 2 for production code?&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Bojan.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/298910?ContentTypeID=1</link><pubDate>Wed, 10 Mar 2021 08:12:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:470c66c5-1ace-48a6-aadb-61c7470cb8b1</guid><dc:creator>user7377</dc:creator><description>&lt;p&gt;Ah, of course. I did not catch that the API was changed. Good to hear it works now. Thank you for updating us!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/298840?ContentTypeID=1</link><pubDate>Tue, 09 Mar 2021 19:11:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:99970784-e964-4e5a-8e23-f172de10f007</guid><dc:creator>user76830</dc:creator><description>&lt;p&gt;Hey, Einar. &lt;/p&gt;
&lt;p&gt;I figured it out. In NCS environment, &lt;span style="background-color:#ccffff;"&gt;&lt;em&gt;&lt;strong&gt;nrf_saadc_task_address_get()&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt; function requires two arguments:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * @brief Function for getting the address of the specified SAADC task register.
 *
 * @param[in] p_reg Pointer to the structure of registers of the peripheral.
 * @param[in] task  SAADC task.
 *
 * @return Address of the specified SAADC task.
 */
NRF_STATIC_INLINE uint32_t nrf_saadc_task_address_get(NRF_SAADC_Type const * p_reg,
                                                      nrf_saadc_task_t       task);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Consequently, what I did in the code is:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    err_code = nrfx_ppi_channel_assign(m_timer_saadc_ppi_channel, 
                                       nrfx_timer_event_address_get(&amp;amp;m_sample_timer, NRF_TIMER_EVENT_COMPARE0),
                                       nrf_saadc_task_address_get((NRF_SAADC_Type *)0x40007000, NRF_SAADC_TASK_SAMPLE));&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;and it is now working well.&lt;/p&gt;
&lt;p&gt;Thanks once again, man!&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Bojan.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/298839?ContentTypeID=1</link><pubDate>Tue, 09 Mar 2021 19:04:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c949cfc-c725-425b-bbb3-522a44e057fd</guid><dc:creator>user7377</dc:creator><description>&lt;p&gt;Hi Bojan,&lt;/p&gt;
&lt;p&gt;It seems this is not valid C++ code. Perhaps&amp;nbsp;you can just replace&amp;nbsp;&lt;code&gt;nrf_saadc_task_address_get(NRF_SAADC_TASK_SAMPLE)&lt;/code&gt; with &lt;code&gt;NRF_SAADC-&amp;gt;TASKS_SAMPLE&lt;/code&gt; or just a pointer to&amp;nbsp;0x40007004?&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/298568?ContentTypeID=1</link><pubDate>Tue, 09 Mar 2021 07:40:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:31f8bc46-a066-45d7-8a76-707328d2719a</guid><dc:creator>user76830</dc:creator><description>&lt;p&gt;Hello, Einar.&lt;/p&gt;
&lt;p&gt;I was able to resolve the issue around timer and saadc peripherals (&lt;a href="https://test-devzone.nordicsemi.com/f/nordic-q-a/72487/how-to-use-nrfx-saadc-driver-on-zephyr-rtos" rel="noopener noreferrer" target="_blank"&gt;link&lt;/a&gt;). They are now both properly initialized and running.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;There is one step left in order to successfully port &lt;a href="https://github.com/einarthorsrud/nrfx_saadc_v2_multi_channel_ppi/blob/main/main.c" rel="noopener noreferrer" target="_blank"&gt;your code&lt;/a&gt; into Zephyr environment - to implement PPI functionality and trigger SAADC sampling on timer1 interrupt. I have this error in &lt;span style="background-color:#ccffff;"&gt;&lt;em&gt;&lt;strong&gt;ppi_init()&lt;/strong&gt;&lt;/em&gt;&lt;/span&gt; function:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;../src/main.cpp: In function &amp;#39;void ppi_init()&amp;#39;:
../src/main.cpp:161:67: error: cannot convert &amp;#39;nrf_saadc_task_t&amp;#39; to &amp;#39;const NRF_SAADC_Type*&amp;#39;
  161 |                                        nrf_saadc_task_address_get(NRF_SAADC_TASK_SAMPLE));
      |                                                                   ^~~~~~~~~~~~~~~~~~~~~
      |                                                                   |
      |                                                                   nrf_saadc_task_t
In file included from D:/Users/bojan/ncs/v1.4.2/modules/hal/nordic/nrfx/drivers/include/nrfx_saadc.h:36,
                 from ../src/main.cpp:58:
D:/Users/bojan/ncs/v1.4.2/modules/hal/nordic/nrfx/hal/nrf_saadc.h:639:78: note:   initializing argument 1 of &amp;#39;uint32_t nrf_saadc_task_address_get(const NRF_SAADC_Type*, nrf_saadc_task_t)&amp;#39;
  639 | NRF_STATIC_INLINE uint32_t nrf_saadc_task_address_get(NRF_SAADC_Type const * p_reg,
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Any idea what&amp;#39;s wrong on my side?&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Bojan.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/298315?ContentTypeID=1</link><pubDate>Mon, 08 Mar 2021 10:24:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c41dc684-84b6-45ba-b114-8f00f74f26af</guid><dc:creator>user76830</dc:creator><description>&lt;p&gt;Just figured out that I needed to include:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_ADC=n
CONFIG_NRFX_SAADC=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Instead of:&lt;/p&gt;
&lt;div class="evolution-code-editor theme-clouds"&gt;
&lt;div class=" ace_editor ace-clouds" style="height:28px;width:100%;"&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_ADC=n
CONFIG_ADC_NRFX_SAADC=y&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="evolution-code-editor theme-clouds"&gt;
&lt;div class=" ace_editor ace-clouds" style="height:28px;width:100%;"&gt;
&lt;div style="font:inherit;height:auto;left:0px;overflow:hidden;position:absolute;top:0px;white-space:pre;width:auto;"&gt;
&lt;div style="font:inherit;height:auto;left:0px;overflow:visible;position:absolute;top:0px;white-space:pre;width:auto;"&gt;&lt;/div&gt;
&lt;div style="font-family:inherit;font-size:inherit;font-style:inherit;height:auto;left:0px;line-height:inherit;overflow:visible;position:absolute;top:0px;white-space:pre;width:auto;"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class="content-scrollable-wrapper" style="overflow:auto;"&gt;&lt;/div&gt;
&lt;p&gt;The code now compiles but when I try to debug it I get stuck:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build v2.4.0-ncs2  ***
[00:00:00.345,001] &#x1B;[1;31m&amp;lt;err&amp;gt; os: &amp;gt;&amp;gt;&amp;gt; ZEPHYR FATAL ERROR 1: Unhandled interrupt on CPU 0&#x1B;[0m
[00:00:00.353,698] &#x1B;[1;31m&amp;lt;err&amp;gt; os: Current thread: 0x20002708 (unknown)&#x1B;[0m
[00:00:00.365,783] &#x1B;[1;31m&amp;lt;err&amp;gt; fatal_error: Resetting system&#x1B;[0m&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://test-devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1615200168468v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;The only thing I have in my main() function is adc_configure() with the following content:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void adc_configure(void)
{
    int err_code;

    nrfx_saadc_adv_config_t saadc_adv_config = NRFX_SAADC_DEFAULT_ADV_CONFIG;
    saadc_adv_config.internal_timer_cc = 0;
    saadc_adv_config.start_on_end = true;

    err_code = nrfx_saadc_init(NRFX_SAADC_DEFAULT_CONFIG_IRQ_PRIORITY);
    //APP_ERROR_CHECK(err_code);

    static nrfx_saadc_channel_t channel_configs[ADC_CHANNELS_IN_USE];

    uint8_t channel_mask = 0;
    for(int i = 0; i &amp;lt; ADC_CHANNELS_IN_USE; i++) {
        nrf_saadc_input_t pin = ANALOG_INPUT_MAP[i];
        // Apply default config to each channel
        nrfx_saadc_channel_t config = NRFX_SAADC_DEFAULT_CHANNEL_SE(pin, i);

        // Replace some parameters in default config
        config.channel_config.reference = NRF_SAADC_REFERENCE_VDD4;          
        config.channel_config.gain = NRF_SAADC_GAIN1_4;

        // Copy to list of channel configs
        memcpy(&amp;amp;channel_configs[i], &amp;amp;config, sizeof(config));

        // Update channel mask
        channel_mask |= 1 &amp;lt;&amp;lt; i;
    }

    err_code = nrfx_saadc_channels_config(channel_configs, ADC_CHANNELS_IN_USE);
    //APP_ERROR_CHECK(err_code);

    err_code = nrfx_saadc_advanced_mode_set(channel_mask,
                                            NRF_SAADC_RESOLUTION_14BIT,
                                            &amp;amp;saadc_adv_config,
                                            event_handler);
    //APP_ERROR_CHECK(err_code);
                                            
    // Configure two buffers to ensure double buffering of samples, to avoid data loss when the sampling frequency is high
    err_code = nrfx_saadc_buffer_set(&amp;amp;samples[next_free_buf_index()][0], SAADC_BUF_SIZE);
    //APP_ERROR_CHECK(err_code);

    err_code = nrfx_saadc_buffer_set(&amp;amp;samples[next_free_buf_index()][0], SAADC_BUF_SIZE);
    //APP_ERROR_CHECK(err_code);

    err_code = nrfx_saadc_mode_trigger();
    //APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Please help.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Bojan.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/298207?ContentTypeID=1</link><pubDate>Sat, 06 Mar 2021 11:38:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9dfa7f0a-622a-4a00-befa-336fd4e471a9</guid><dc:creator>user76830</dc:creator><description>&lt;p&gt;Hello, Einar. &lt;/p&gt;
&lt;p&gt;I am trying to port your &lt;a href="https://github.com/einarthorsrud/nrfx_saadc_v2_multi_channel_ppi" rel="noopener noreferrer" target="_blank"&gt;unofficial SAADC example&lt;/a&gt; into Zephyr environment.&lt;/p&gt;
&lt;p&gt;As a first goal, I wanted to test only &lt;em&gt;&lt;span style="background-color:rgba(204, 255, 255, 1);"&gt;adc_configure()&lt;/span&gt;&lt;/em&gt; function. According to &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/samples/boards/nrf/nrfx/README.html?highlight=nrfx#building-and-running"&gt;nrfx use example&lt;/a&gt; that shows how to use nrfx drivers in Zephyr, I did the following in my &lt;span style="background-color:rgba(255, 153, 204, 1);"&gt;&lt;em&gt;prj.config&lt;/em&gt;&lt;/span&gt; file:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_ADC=n
CONFIG_ADC_NRFX_SAADC=y&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I also included nrfx_saadc header file&amp;nbsp; line in my main.cpp file:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;nrfx_saadc.h&amp;gt;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;When I compile the code, the compiler complains about undefined reference to &lt;span style="background-color:rgba(255, 153, 204, 1);"&gt;&lt;em&gt;nrfx_saadc_xxx()&lt;/em&gt;&lt;/span&gt; functions that are all declared in included &lt;em&gt;&lt;span style="background-color:rgba(204, 255, 255, 1);"&gt;nrfx_saadc.h &lt;/span&gt;&lt;/em&gt;file:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;build/../src/main.cpp:187: undefined reference to `nrfx_saadc_channels_config&amp;#39;
build/../src/main.cpp:190: undefined reference to `nrfx_saadc_advanced_mode_set&amp;#39;
build/../src/main.cpp:197: undefined reference to `nrfx_saadc_buffer_set&amp;#39;
build/../src/main.cpp:200: undefined reference to `nrfx_saadc_buffer_set&amp;#39;
build/../src/main.cpp:203: undefined reference to `nrfx_saadc_mode_trigger&amp;#39;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Do you have any idea what I am missing here? Do I need to include something more in my &lt;span style="background-color:rgba(255, 153, 204, 1);"&gt;&lt;em&gt;prj.config&lt;/em&gt;&lt;/span&gt; file that will disable the usage of Zephyr ADC APIs and encourage the usage of NRFX SAADC driver?&lt;/p&gt;
&lt;p&gt;Thanks in advance for your time and efforts.&lt;/p&gt;
&lt;p&gt;Sincerely,&lt;/p&gt;
&lt;p&gt;Bojan.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/294376?ContentTypeID=1</link><pubDate>Mon, 15 Feb 2021 12:36:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f72ce7b-d8b9-4f33-9310-ca4af01043fb</guid><dc:creator>user7377</dc:creator><description>&lt;p&gt;&lt;span&gt;Thank you for the feedback, Bojan. We are happy to help &lt;span class="emoticon" data-url="https://test-devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;I have requested the case to become public but you need to approve it.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Einar&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/294375?ContentTypeID=1</link><pubDate>Mon, 15 Feb 2021 12:18:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dfcda7a3-525d-4925-a6f0-3c1bec8e5c6b</guid><dc:creator>user76830</dc:creator><description>&lt;p&gt;This is what I call great support!&lt;/p&gt;
&lt;p&gt;Thank you very much, Einer!&lt;/p&gt;
&lt;p&gt;No more questions concerning ADC converter! :-)&lt;/p&gt;
&lt;p&gt;By the way, I just noticed that this ticket is private. Can we move it to Public area so that the rest of the people can hopefully benefit from it?&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Bojan.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/294374?ContentTypeID=1</link><pubDate>Mon, 15 Feb 2021 12:09:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cb265adb-d1f9-4c0d-abe8-2ee2ae279723</guid><dc:creator>user7377</dc:creator><description>&lt;p&gt;Hi Bojan,&lt;/p&gt;
&lt;p&gt;The ADC calibration time depends on the previously configured acquisition time. If not yet configured, the default acquisition time of 10 us is used. The total calibration time is a few microseconds more as it includes conversion.&lt;/p&gt;
&lt;p&gt;Calibration is done to sets the correct offset, so that measuring GND will give a sample value of 0. This will normally not change over time unless the temperature changes. So you should calibrate after reset, and either regularly or when there are temperature changes.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/294373?ContentTypeID=1</link><pubDate>Mon, 15 Feb 2021 12:01:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e2b03f7-9b00-46d9-bc27-1b2788f13c98</guid><dc:creator>user76830</dc:creator><description>&lt;p&gt;Thanks, Einar.&lt;/p&gt;
&lt;p&gt;Do you have any idea what is the duration of ADC calibration?&lt;/p&gt;
&lt;p&gt;I thought to perform ADC calibration only once, during the initialization phase rather then to do it every time before taking the sample. Does that make sense?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/294372?ContentTypeID=1</link><pubDate>Mon, 15 Feb 2021 11:21:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74e71cd1-783b-434e-8576-83d88ce74e76</guid><dc:creator>user7377</dc:creator><description>&lt;p&gt;Hi Bojan,&lt;/p&gt;
&lt;p&gt;You can set the&amp;nbsp;calibrate flag in the&amp;nbsp;adc_sequence struct to true to perform calibration before sampling. (You can see form the implementation in adc_nrfx_saadc.c that this triggers&amp;nbsp;NRF_SAADC_TASK_CALIBRATEOFFSET).&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/294371?ContentTypeID=1</link><pubDate>Mon, 15 Feb 2021 11:02:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c16d460-6b76-4522-9096-50478786c28a</guid><dc:creator>user76830</dc:creator><description>&lt;p&gt;Thanks, Einar, for all your help and clarifications.&lt;/p&gt;
&lt;p&gt;One more thing I would like you to help me with concerning ADC converters...&lt;/p&gt;
&lt;p&gt;How can we call nRF52840 ADC calibration function from Zephyr?&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Bojan.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/294370?ContentTypeID=1</link><pubDate>Thu, 11 Feb 2021 13:01:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2105be67-25eb-44ef-b5bf-ca7640ba217d</guid><dc:creator>user7377</dc:creator><description>&lt;p&gt;Hi Bojan,&lt;/p&gt;
&lt;p&gt;Yes, you can trigger sampling using the Zephyr API like that.&lt;/p&gt;
&lt;p&gt;When populating the&amp;nbsp;adc_sequence struct you do not&amp;nbsp;populate&amp;nbsp;a pointer to options (adc_sequence_options). This is where you specify the number of samplings to perform with the&amp;nbsp;extra_samplings field. You can see some examples of this in the test code in&amp;nbsp;zephyr\tests\drivers\adc\adc_api\src\test_adc.c.&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/294369?ContentTypeID=1</link><pubDate>Thu, 11 Feb 2021 12:13:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05e9687a-0e95-4a59-a8d9-9b63c3ebf415</guid><dc:creator>user76830</dc:creator><description>&lt;p&gt;Thanks for your help, Einar.&lt;/p&gt;
&lt;p&gt;Please help me to better understand the following...&lt;/p&gt;
&lt;p&gt;If we use Zephyr OS and Zephyr timer to take the samples at regular intervals, can we tell Zephyr ADC API to take some number of samples from the particular channel, not only one sample?&lt;/p&gt;
&lt;p&gt;This is the sequence I call when the Zephyr timer expires:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;const struct adc_sequence sequence = {
	.channels = BIT(ADC_1ST_CHANNEL_ID),
	.buffer = m_sample_buffer,
	.buffer_size = sizeof(m_sample_buffer),
	.resolution = ADC_RESOLUTION,
};

ret = adc_read(adc_dev, &amp;amp;sequence);
if (ret) {
    printk(&amp;quot;adc_read() failed with code %d\n&amp;quot;, ret);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I selected the channels I want to read as well as where to store the data. However, it seems that only one sample is stored. Can I somehow define the number of samples I want to take from the channel?&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Bojan.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Continuous periodic nRF52840 ADC sampling with Zephyr</title><link>https://test-devzone.nordicsemi.com/thread/294368?ContentTypeID=1</link><pubDate>Thu, 11 Feb 2021 11:35:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa1825c2-d2b4-4126-922a-a72181cdfecc</guid><dc:creator>user7377</dc:creator><description>&lt;p&gt;Hi Bojan,&lt;/p&gt;
&lt;p&gt;You cannot use the Zephyr ADC API if you want to trigger sampling regularly without CPU intervention due to the general nature of the Zephyr APIs. In that case you need to use a TIMER to trigger the SAADC via PPI, and for that you need to use the nrfx drivers directly.&lt;/p&gt;
&lt;p&gt;I do not have an example which does that at hand, but how to use nrfx drivers in general in Zephyr is demonstrated by the &lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/samples/boards/nrf/nrfx/README.html?highlight=nrfx#building-and-running"&gt;nrfx use example&lt;/a&gt;. You can combine that with this &lt;a href="https://github.com/einarthorsrud/nrfx_saadc_v2_multi_channel_ppi"&gt;unofficial SAADC example&lt;/a&gt;, which demonstrates using the latest nrfx API to sample multiple channels regularly based on a timer (it is for the nRF5 SDK, but the nrfx API is the same regardless).&lt;/p&gt;
&lt;p&gt;Referring to the example, note that if you do not want to handle the sample set every time you just need to increase the buffer length, as you will get an interrupt ever time the buffer is filled. Also, you may not need to use double buffering as demonstrated, if you have time to process the buffer on time without it.&lt;/p&gt;
&lt;p&gt;Br,&lt;/p&gt;
&lt;p&gt;Einar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>