<?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>nrf52 with Mynewt multi channel ADC configuration</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/64721/nrf52-with-mynewt-multi-channel-adc-configuration</link><description>Hi all, 
 We are using nrf52 DK (both pca10040 and 10056) to develop a multi-channel ADC sampling module running Mynewt. 
 The example ADC code with Mynewt is a single-channel one and it works. We need to add more channels to include more analog inputs</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 11 Aug 2020 17:05:31 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/64721/nrf52-with-mynewt-multi-channel-adc-configuration" /><item><title>RE: nrf52 with Mynewt multi channel ADC configuration</title><link>https://devzone.nordicsemi.com/thread/264123?ContentTypeID=1</link><pubDate>Tue, 11 Aug 2020 17:05:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b80ec6bc-b08f-46ef-95c2-d1d038f77609</guid><dc:creator>shanyechungu</dc:creator><description>&lt;p&gt;I solved the problem. It was caused by code error in the value readout function:&lt;/p&gt;
&lt;p&gt;below is the correct one which works now.&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint16_t *
adc_read(void *buffer, int buffer_len)
{
    int i;
    int j;
    int adc_result;

    for (j = 0; j &amp;lt; ADC_NUMBER_CHANNELS; j++) {
        for (i = 0; i &amp;lt; ADC_NUMBER_SAMPLES - 1; i++) {
            adc_buf_read(adc, buffer, buffer_len, j, &amp;amp;adc_result);
            adc_buf_release(adc, buffer, buffer_len);
        }
        result_mv[j] = adc_result_mv(adc, j, adc_result); // RESULT = (V(P) – V(N)) * (GAIN/REFERENCE) * 2^RESOLUTION
    }

    return result_mv;
}&lt;/pre&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>