<?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>Zephyr shell ADC reading: Channel 0 not configured</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/110669/zephyr-shell-adc-reading-channel-0-not-configured</link><description>Hi there, 
 I use the ADC in my firmware, which works well, but I also want to use it from the shell. 
 I enabled the CONFIG_ADC_SHELL Kconfig option, which made the &amp;quot;adc&amp;quot; command available in the shell, but I get the following error: 
 
 The relevant</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 06 May 2024 13:16:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/110669/zephyr-shell-adc-reading-channel-0-not-configured" /><item><title>RE: Zephyr shell ADC reading: Channel 0 not configured</title><link>https://devzone.nordicsemi.com/thread/482052?ContentTypeID=1</link><pubDate>Mon, 06 May 2024 13:16:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6716503c-c8d4-4b78-864d-2d4300df4b55</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Laci&lt;/p&gt;
&lt;p&gt;It seems you need to configure the ADC channel through the shell before you can read it. One of the developers shared a snippet showing how they have configured the ADC shell in the past, you can use that for reference:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;adc adc@e000 acq_time 40 us
adc adc@e000 resolution 10
adc adc@e000 reference INTERNAL
adc adc@e000 gain GAIN_1_6
adc adc@e000 channel id 4
adc adc@e000 channel negative 0
adc adc@e000 channel positive 5
adc adc@e000 channel id 5
adc adc@e000 channel negative 0
adc adc@e000 channel positive 6
adc adc@e000 channel id 0
adc adc@e000 channel negative 0
adc adc@e000 channel positive 1
adc adc@e000 channel id 1
adc adc@e000 channel negative 0
adc adc@e000 channel positive 2&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: Zephyr shell ADC reading: Channel 0 not configured</title><link>https://devzone.nordicsemi.com/thread/481854?ContentTypeID=1</link><pubDate>Fri, 03 May 2024 17:37:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d8f2159-d29f-4737-9de2-5d09735bd284</guid><dc:creator>mlac</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Torbj&amp;oslash;rn,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I actually initialize the ADC in my application:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;zephyr/drivers/gpio.h&amp;gt;
#include &amp;lt;zephyr/sys/util.h&amp;gt;

#define DT_SPEC_AND_COMMA(node_id, prop, idx) \
    ADC_DT_SPEC_GET_BY_IDX(node_id, idx),
const struct adc_dt_spec adc_channels[] = {
    DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), io_channels, DT_SPEC_AND_COMMA)
};

void InitCharger(void) {
    for (size_t i = 0U; i &amp;lt; ARRAY_SIZE(adc_channels); i++) {
        if (!device_is_ready(adc_channels[i].dev)) {
            printk(&amp;quot;ADC controller device %s not ready\n&amp;quot;, adc_channels[i].dev-&amp;gt;name);
            return;
        }
        int err;
        err = adc_channel_setup_dt(&amp;amp;adc_channels[i]);
        if (err &amp;lt; 0) {
            printk(&amp;quot;Could not setup channel #%d (%d)\n&amp;quot;, i, err);
            return;
        }
    }
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Afterward, I can read ADC values with&amp;nbsp;adc_sequence_init_dt() followed by&amp;nbsp;adc_read() in my application, so I&amp;#39;d expect the ADC shell module to read the ADC as well.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Zephyr shell ADC reading: Channel 0 not configured</title><link>https://devzone.nordicsemi.com/thread/481571?ContentTypeID=1</link><pubDate>Thu, 02 May 2024 13:31:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f86d2da6-4f63-4624-94be-ec743004af33</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Laci&lt;/p&gt;
&lt;p&gt;I see the same on my side. Most likely the shell module will not initialize the ADC driver for you, and you have to do this in the application.&lt;/p&gt;
&lt;p&gt;Could you try this and see if it works better?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You could use the &lt;a href="https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/boards/nrf/battery"&gt;battery sample&lt;/a&gt; for reference in order to see how ADC initialization is handled.&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>