<?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>Multiple ADC reading - NCS</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/95171/multiple-adc-reading---ncs</link><description>Hello everyone! 
 I&amp;#39;m trying to read 4 channels of ADC, and for future production, I&amp;#39;d have to read all 8. 
 There is two channels example , yet it isn&amp;#39;t scalable. I&amp;#39;m thinking about building a dynamic setup based on the example, but it doesn&amp;#39;t go so</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 04 Jan 2023 21:10:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/95171/multiple-adc-reading---ncs" /><item><title>RE: Multiple ADC reading - NCS</title><link>https://devzone.nordicsemi.com/thread/403262?ContentTypeID=1</link><pubDate>Wed, 04 Jan 2023 21:10:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3ef640fb-a40d-4e36-abe5-fcdfd573241e</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;You welcome, good to hear you figured it out &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple ADC reading - NCS</title><link>https://devzone.nordicsemi.com/thread/403210?ContentTypeID=1</link><pubDate>Wed, 04 Jan 2023 14:20:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:caf27859-e457-4f23-ae60-52efd9cb5063</guid><dc:creator>Meh</dc:creator><description>&lt;p&gt;I&amp;#39;m not sure what happened, but I&amp;#39;ve upgraded my SDK to v2.2.0 and used the format from the ADC sample, which is now working. Thanks for your help :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple ADC reading - NCS</title><link>https://devzone.nordicsemi.com/thread/402988?ContentTypeID=1</link><pubDate>Tue, 03 Jan 2023 14:03:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:019532b9-9562-402d-a26c-adad43c14dcc</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The MPU fault is caused by the way you assign the device pointer.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you want to provide a pointer back to the caller of the function you should pass a pointer to the pointer to the function. In your code you will simply assign the ADC device pointer to the local dev variable in the function, adc_dev will not be updated.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also, on an error you return the ret variable, which is unassigned. This is also incorrect (but not the problem here).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The code snippet below corrects these issues:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static int adc_setup_meh(const struct device **dev)
{
    //ADC0 setup
    *dev = device_get_binding(ADC_DEVICE_NAME);
	if (!dev) {
        printk(&amp;quot;device_get_binding ADC_0 (=%s) failed\n&amp;quot;, ADC_DEVICE_NAME);
        return -1;
    } 

    return 0;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;And then you need to call the function like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;err = adc_setup_meh(&amp;amp;adc_dev);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple ADC reading - NCS</title><link>https://devzone.nordicsemi.com/thread/402828?ContentTypeID=1</link><pubDate>Mon, 02 Jan 2023 13:49:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d03aa171-d034-4202-8bc9-30ca8767b637</guid><dc:creator>Meh</dc:creator><description>&lt;p&gt;I updated the code, and now it&amp;#39;s compiling well, but when trying to see the nRF Terminal, I&amp;#39;m getting the following logs.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;*** Booting Zephyr OS build v2.7.99-ncs1-1  ***
Device binded to ADC_0
[00:00:00.257,568] &amp;lt;err&amp;gt; os: ***** MPU FAULT *****
[00:00:00.257,568] &amp;lt;err&amp;gt; os:   Instruction Access Violation
[00:00:00.257,568] &amp;lt;err&amp;gt; os: r0/a1:  0x00000000  r1/a2:  0x20001958  r2/a3:  0x54f7fab5
[00:00:00.257,568] &amp;lt;err&amp;gt; os: r3/a4:  0x20001958 r12/ip:  0x00000000 r14/lr:  0x00000407
[00:00:00.257,598] &amp;lt;err&amp;gt; os:  xpsr:  0x61000000
[00:00:00.257,598] &amp;lt;err&amp;gt; os: Faulting instruction address (r15/pc): 0x54f7fab4
[00:00:00.257,598] &amp;lt;err&amp;gt; os: &amp;gt;&amp;gt;&amp;gt; ZEPHYR FATAL ERROR 0: CPU exception on CPU 0
[00:00:00.257,629] &amp;lt;err&amp;gt; os: Current thread: 0x20000420 (main)
[00:00:01.207,336] &amp;lt;err&amp;gt; fatal_error: Resetting system&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;The code now:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/adc_5F00_4_5F00_v3.zip"&gt;devzone.nordicsemi.com/.../adc_5F00_4_5F00_v3.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple ADC reading - NCS</title><link>https://devzone.nordicsemi.com/thread/402768?ContentTypeID=1</link><pubDate>Mon, 02 Jan 2023 09:27:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ed4ad6f-cddc-40ac-8ef0-29dc991fcbf0</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Which NCS version are you using to build it?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I tried in v1.9.1, but it doesn&amp;#39;t build. The .channel_cfgs field in the adc_sequence struct can&amp;#39;t be found.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple ADC reading - NCS</title><link>https://devzone.nordicsemi.com/thread/402711?ContentTypeID=1</link><pubDate>Sat, 31 Dec 2022 02:33:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f80dfe5-3777-4da4-80c8-450f75a7802a</guid><dc:creator>Meh</dc:creator><description>&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/adc_5F00_4.zip"&gt;devzone.nordicsemi.com/.../adc_5F00_4.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So I did some googling. It builds well yet suffers from failure while trying to start channel 0. What did I miss here?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple ADC reading - NCS</title><link>https://devzone.nordicsemi.com/thread/402618?ContentTypeID=1</link><pubDate>Fri, 30 Dec 2022 08:56:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2f3e341e-d5e6-4d35-9794-a33ce0758568</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;This feature was added in v2.1.0 of NCS, and won&amp;#39;t work in v1.9.1 unfortunately.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In v1.9.1 you would have to look at the &lt;a href="https://docs.zephyrproject.org/latest/samples/boards/nrf/battery/README.html"&gt;battery sample&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Alternatively it is possible to forego the Zephyr driver entirely and use the nrfx driver instead. There are some examples showing how to use the nrfx_saadc driver eavailable &lt;a href="https://github.com/zephyrproject-rtos/hal_nordic/tree/master/nrfx/samples/src/nrfx_saadc"&gt;here&lt;/a&gt;. These are also written for a newer NCS version, but the nrfx drivers haven&amp;#39;t changed much in that time API wise so I would expect the samples to run in older versions as well.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple ADC reading - NCS</title><link>https://devzone.nordicsemi.com/thread/402320?ContentTypeID=1</link><pubDate>Tue, 27 Dec 2022 17:19:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:73fd795b-e393-434e-a710-4afd1c9546d8</guid><dc:creator>Meh</dc:creator><description>&lt;p&gt;By trying your method, I&amp;#39;m getting various errors from CMake and a lack of definitions. I&amp;#39;m using NCS V1.9.1.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m attaching the list of errors and my project.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1672161456813v2.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/adc_5F00_extended.zip"&gt;devzone.nordicsemi.com/.../adc_5F00_extended.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Multiple ADC reading - NCS</title><link>https://devzone.nordicsemi.com/thread/402291?ContentTypeID=1</link><pubDate>Tue, 27 Dec 2022 13:24:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e9064da8-de1c-41f0-a900-8c6541f6c9f0</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Tamir&lt;/p&gt;
&lt;p&gt;It sounds a bit odd that the standard example shouldn&amp;#39;t be scalable. The way it works is that it goes through all the channels defined in the device tree and configures each channel as required.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As an example the nrf52840 overlay can be seen &lt;a href="https://github.com/nrfconnect/sdk-zephyr/blob/8fb465f43f6a90ac4c4ce89265047e04f7d5ee5b/samples/drivers/adc/boards/nrf52840dk_nrf52840.overlay"&gt;here&lt;/a&gt;, where 3 different channels are defined with different settings. In order to add more channels all you have to do is update the overlay, and the sample should handle the rest (just make sure to use each index between 0-7 only once).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>