<?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>Saadc in sample convert</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/51879/saadc-in-sample-convert</link><description>Hi All 
 I&amp;#39;m trying to use the Adc in Sample convert mode: &amp;quot;nrfx_saadc_sample_convert(0,&amp;amp;ADC_Val);&amp;quot; to sequential read two ADC pins . 
 I have used the code below to init the saadc with a single channel. and changing the Analog pin &amp;quot; nrf_saadc_channel_pos_input_set</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 09 Sep 2019 13:21:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/51879/saadc-in-sample-convert" /><item><title>RE: Saadc in sample convert</title><link>https://devzone.nordicsemi.com/thread/208704?ContentTypeID=1</link><pubDate>Mon, 09 Sep 2019 13:21:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5658a53-b2ba-47dc-94f8-5dc3f610f6d7</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;There is no need to use nrf_drv_saadc_is_busy()/nrfx_saadc_is_busy() or similar, since nrf_drv_saadc_sample_convert()/nrfx_saadc_sample_convert() is blocking. You can refer to this code to see a working example of what (I think) you are trying to do (overwrite the existing examples\peripheral\saadc\main.c in SDK 15.3):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;string.h&amp;gt;
#include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;nrf_drv_saadc.h&amp;quot;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;app_util_platform.h&amp;quot;
#include &amp;quot;nrf_pwr_mgmt.h&amp;quot;

#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;

void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
{
    NRF_LOG_INFO(&amp;quot;ADC event&amp;quot;);
}


void saadc_init(void)
{
    ret_code_t err_code;

    err_code = nrf_drv_saadc_init(NULL, saadc_callback);
    APP_ERROR_CHECK(err_code);

    // Configure channel 0
    nrf_saadc_channel_config_t channel_config_0 =
        NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN0); // AIN0 = P0.02

    err_code = nrf_drv_saadc_channel_init(0, &amp;amp;channel_config_0);
    APP_ERROR_CHECK(err_code);

    // Configure channel 1
    nrf_saadc_channel_config_t channel_config_1 =
        NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN1); // AIN1 = P0.03

    err_code = nrf_drv_saadc_channel_init(1, &amp;amp;channel_config_1);
    APP_ERROR_CHECK(err_code);
}


void simple_saadc_demo(void)
{
    ret_code_t err_code;
    nrf_saadc_value_t sample;

    // Sample channel 0
    err_code =nrfx_saadc_sample_convert(0, &amp;amp;sample);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_INFO(&amp;quot;Channel 0 sample: %i&amp;quot;, sample);

    // Sample channel 1
    err_code =nrfx_saadc_sample_convert(1, &amp;amp;sample);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_INFO(&amp;quot;Channel 1 sample: %i&amp;quot;, sample);
}


/**
 * @brief Function for main application entry.
 */
int main(void)
{
    uint32_t err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();

    ret_code_t ret_code = nrf_pwr_mgmt_init();
    APP_ERROR_CHECK(ret_code);

    saadc_init();

    simple_saadc_demo();

    NRF_LOG_INFO(&amp;quot;Simple SAADC demo started.&amp;quot;);

    while (1)
    {
        nrf_pwr_mgmt_run();
        NRF_LOG_FLUSH();
    }
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Note that blocking operations may not be the best for a practical application that also needs to do other things. You can also use the SAADC in scan mode, so that it automatically samples both pins consecutively as fast as possible, and gives you an event when both samples have been collected.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>