<?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 Configuration</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/64867/saadc-configuration</link><description>Hi All, 
 I am developing one project and there we are using ADC (i.e., SAADC in nRF). I have designed the hardware where I am using Capacitor ( C14, 2.2&amp;#181;F) which is connected to Analog pin and my requirement is I have to read the voltage level. 
 Here</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 13 Oct 2020 09:10:25 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/64867/saadc-configuration" /><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/274536?ContentTypeID=1</link><pubDate>Tue, 13 Oct 2020 09:10:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e1d9143-b623-4f3a-88e6-93af7fc6ea9f</guid><dc:creator>Karl Ylvisaker</dc:creator><description>[quote user="Rohit Rajapure"]Thanks for the response,[/quote]
&lt;p&gt;No problem at all, Rohit!&lt;/p&gt;
[quote user="Rohit Rajapure"]I will check and get back to you.[/quote]
&lt;p&gt;Great, I look forward to hearing&amp;nbsp;if this fulfills your applications requirements!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/274532?ContentTypeID=1</link><pubDate>Tue, 13 Oct 2020 09:04:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26bbe763-7546-4186-8d7f-13ff2ca62223</guid><dc:creator>Rohit Rajapure</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;Thanks for the response,&lt;/p&gt;
&lt;p&gt;I will check and get back to you.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks and Regards&lt;/p&gt;
&lt;p&gt;Rohit R&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/274530?ContentTypeID=1</link><pubDate>Tue, 13 Oct 2020 09:00:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e09297e6-ac2c-42ce-a506-9bb6a3be33a0</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Rohit R,&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote user="Rohit Rajapure"]- I do not want to use timer or PPI channels, I need just a normal operation of SAADC operation.[/quote]
&lt;p&gt;Understood. All I can do here is to emphasize my recommendation of the timer + PPI combination, due to all the aforementioned advantages of this approach - but at the same time I do not know all the requirements and constraints of your project, so you may very well ignore this unsolicited recommendation, of course.&lt;/p&gt;
[quote user="Rohit Rajapure"]My requirement for SAADC previously was read single sample so I have configured and in attached code I am able to get that. But in my final project, requirement case is increased, means in 1 case I need single sample and in 2 case I need multiple samples (as in my first statement). So I want keeping same configuration how I can achieve my both requirement (case 1 and case 2).[/quote]
&lt;p&gt;To avoid any confusion for future forum-goers readings this thread; &lt;em&gt;I can not recommend the following approach for periodic sampling&lt;/em&gt;, but the following is how you may go about using inserted delay in combination with nrfx_saadc_sample_convert to achieve the functionality described above:&lt;br /&gt;&lt;br /&gt;Change the contents of your main while-loop to be a for-loop that calls nrfx_saadc_sample_convert for the required number of samples ( either 1 or multiple ), then delay the next execution of the for-loop by &lt;em&gt;around&amp;nbsp;6 ms&lt;/em&gt;.&lt;br /&gt;&lt;br /&gt;Please keep in mind that delay is not an accurate timing mechanism - the delay function will just calculate the rough number of NOP cycles it will take to&amp;nbsp;delay the given time, and queue them for execution. If the execution of these NOP cycles are in any way interrupted - such as by the SoftDevice - then the delay will be extended by the total time of the interruption.&lt;br /&gt;The approach above could also quickly be made less power consuming by the addition of a timer and nrf_pwr_mngmt_run.&lt;br /&gt;&lt;br /&gt;Please try the above, and let me know if it achieves the functionality you seek to implement.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/274516?ContentTypeID=1</link><pubDate>Tue, 13 Oct 2020 08:41:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c8db8b02-562c-4e1c-8bb3-a5e702efbdff</guid><dc:creator>Rohit Rajapure</dc:creator><description>&lt;p&gt;Hi Karl, &lt;/p&gt;
&lt;p&gt;Thanks for the feedback,&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/64867/saadc-configuration/274506#274506"]What are your requirements for the SAADC - do you intend to perform a sampling ( or multiple samples ? ) each second, have I understood this correct?[/quote]
&lt;p&gt;- yes, I want multiple sample in around 6msec. &lt;/p&gt;
&lt;p&gt;- I do not want to use timer or PPI channels, I need just a normal operation of SAADC operation.&lt;/p&gt;
&lt;p&gt;- I had gone through the SDK example so with reference to that example I have modified my program without using timer or PPI.&lt;/p&gt;
&lt;p&gt;- My requirement for SAADC previously was read single sample so I have configured and in attached code I am able to get that. But in my final project, requirement case is increased, means in 1 case I need single sample and in 2 case I need multiple samples (as in my first statement). So I want keeping same configuration how I can achieve my both requirement (case 1 and case 2).&lt;/p&gt;
&lt;p&gt;Thanks and Regards&lt;/p&gt;
&lt;p&gt;Rohit R&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/274506?ContentTypeID=1</link><pubDate>Tue, 13 Oct 2020 08:22:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:83f48e3d-680d-44cf-807b-5cf7ae276560</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Rohit R,&lt;/p&gt;
[quote user="Rohit Rajapure"]&lt;p&gt;I am using&amp;nbsp;saadc_sampling_trigger(); trigger the ADC samples. But I am getting 1 sample.&lt;/p&gt;
&lt;p&gt;I have tried by changing the buffer size than my code not working.&lt;/p&gt;[/quote]
&lt;p&gt;&lt;span&gt;The&amp;nbsp;nrfx_saadc_sample() function triggers the START task or SAMPLE task register, depending on weather the driver is configured in low power mode or not. If you want to use a timer to trigger ADC sampling yo could trigger&amp;nbsp;the task directly via PPI instead. This way you get precise timing, as it happens in HW and won&amp;#39;t be delayed by a potential high priority interrupt.&lt;br /&gt;If I have misunderstood you, and you would just like to get a single sample by calling a single function, you should instead use the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v16.0.0%2Fgroup__nrfx__saadc.html&amp;amp;anchor=gab71a209892aedc84800887de200c5857"&gt;nrfx_saadc_sample_convert&lt;/a&gt;&amp;nbsp;function for this.&lt;/span&gt;&lt;/p&gt;
[quote user="Rohit Rajapure"]What I need is, I want to read multiple samples when I trigger ADC?[/quote]
&lt;p&gt;Have you seen &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/nrf_dev_saadc_example.html"&gt;the SAADC example from the SDK&lt;/a&gt;? It demonstrates how to set up the SAADC&amp;#39;s sampling to trigger by a timer through PPI.&lt;br /&gt;What are your requirements for the SAADC - do you intend to perform a sampling ( or multiple samples ? ) each second, have I understood this correct?&lt;br /&gt;If you are doing a periodic sampling, I would highly recommend setting it to trigger by a timer through PPI, as demonstrated in the SDK example.&lt;br /&gt;&lt;br /&gt;On a general note, I would also recommend that you do some power management in your main while loop, so as to reduce power consumption.&lt;br /&gt;In most examples - including the SAADC peripheral example - you can see this implemented as the&amp;nbsp;&lt;em&gt;idle_state_handler&lt;/em&gt; function.&lt;br /&gt;Currently, it seems that you are using a 1000 ms delay in the main loop to time your measurements - this is not recommended, as the delay NOP CPU instructions are wasted, and the delay function will not give you an exact delay, if you intend to add BLE communication to your project later on.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/274461?ContentTypeID=1</link><pubDate>Tue, 13 Oct 2020 06:40:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c2c5a47-bf85-4181-bc9f-e8a288209af6</guid><dc:creator>Rohit Rajapure</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;I need one help,&lt;/p&gt;
&lt;p&gt;I am using&amp;nbsp;saadc_sampling_trigger(); trigger the ADC samples. But I am getting 1 sample.&lt;/p&gt;
&lt;p&gt;I have tried by changing the buffer size than my code not working.&lt;/p&gt;
&lt;p&gt;What I need is, I want to read multiple samples when I trigger ADC?&lt;/p&gt;
&lt;p&gt;Can you please help how to do that? below is my code let me know what I did wrong.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;/**
 * Copyright (c) 2014 - 2019, Nordic Semiconductor ASA
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 *
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 *
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 *
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
/** @file
 * @defgroup nrf_adc_example main.c
 * @{
 * @ingroup nrf_adc_example
 * @brief ADC Example Application main file.
 *
 * This file contains the source code for a sample application using ADC.
 *
 * @image html example_board_setup_a.jpg &amp;quot;Use board setup A for this example.&amp;quot;
 */

#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;nrf_drv_ppi.h&amp;quot;
#include &amp;quot;nrf_drv_timer.h&amp;quot;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;app_error.h&amp;quot;
#include &amp;quot;nrf_delay.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;


#define SAMPLES_IN_BUFFER 1

volatile uint8_t state = 1;

static const nrf_drv_timer_t m_timer = NRF_DRV_TIMER_INSTANCE(0);
static nrf_saadc_value_t     m_buffer_pool[1][SAMPLES_IN_BUFFER];
static nrf_ppi_channel_t     m_ppi_channel;
static uint32_t              m_adc_evt_counter;

bool boolEventHandled = true;

void saadc_callback(nrf_drv_saadc_evt_t const * p_event)
{
    if (p_event-&amp;gt;type == NRF_DRV_SAADC_EVT_DONE)
    {
        ret_code_t err_code;
        //ui16CurrentADCValue = p_event-&amp;gt;data.done.p_buffer[0]; 
         
        err_code = nrf_drv_saadc_buffer_convert(p_event-&amp;gt;data.done.p_buffer, SAMPLES_IN_BUFFER);
        APP_ERROR_CHECK(err_code);

        int i;
        NRF_LOG_INFO(&amp;quot;ADC event number: %d&amp;quot;, (int)m_adc_evt_counter);

        for (i = 0; i &amp;lt; SAMPLES_IN_BUFFER; i++)
        {
            NRF_LOG_INFO(&amp;quot;%d&amp;quot;,p_event-&amp;gt;data.done.p_buffer[i]);
        }
        m_adc_evt_counter++;

        boolEventHandled = true;
    }

}


void saadc_init(void)
{
        ret_code_t err_code;
    nrf_drv_saadc_config_t saadc_config;
    saadc_config.resolution = NRF_SAADC_RESOLUTION_8BIT;   //8 bit resolution
    saadc_config.interrupt_priority = APP_IRQ_PRIORITY_LOW;
    
    err_code = nrf_drv_saadc_init(&amp;amp;saadc_config, saadc_callback);
    APP_ERROR_CHECK(err_code);
    
   //singale shot and channel config 
   nrf_saadc_channel_config_t channel_config;
   channel_config.reference = NRF_SAADC_REFERENCE_INTERNAL;
   channel_config.gain = NRF_SAADC_GAIN1_4;
   channel_config.acq_time = NRF_SAADC_ACQTIME_10US;
   channel_config.mode = NRF_SAADC_MODE_SINGLE_ENDED;
   channel_config.pin_n = NRF_SAADC_INPUT_DISABLED; 
   channel_config.pin_p = NRF_SAADC_INPUT_AIN2;
   channel_config.resistor_n = NRF_SAADC_RESISTOR_DISABLED;
   channel_config.resistor_p = NRF_SAADC_RESISTOR_DISABLED;

    err_code = nrf_drv_saadc_channel_init(2, &amp;amp;channel_config);
    APP_ERROR_CHECK(err_code);

    err_code = nrf_drv_saadc_buffer_convert(&amp;amp;m_buffer_pool[0], SAMPLES_IN_BUFFER);
    APP_ERROR_CHECK(err_code);
   
}

void saadc_sampling_trigger(void)
{
    ret_code_t err_code;
    err_code = nrf_drv_saadc_sample(); // Check error
    APP_ERROR_CHECK(err_code);
    boolEventHandled = false;
}

/**
 * @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();

    saadc_init();

    NRF_LOG_INFO(&amp;quot;SAADC HAL simple example started.&amp;quot;);


    while (1)
    {   
        if(boolEventHandled)
        {
          saadc_sampling_trigger();
        }
        nrf_delay_ms(1000);
        NRF_LOG_FLUSH();
    }
}


/** @} */
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks and Regards&lt;/p&gt;
&lt;p&gt;Rohit R&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/267268?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 13:34:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:85889447-90b0-4dff-bf25-76ece16a36a5</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Rohit,&lt;/p&gt;
[quote user="Rohit Rajapure"]Yes, I am able to read all resolution values.[/quote]
&lt;p&gt;Great, I am glad to hear that!&amp;nbsp;&lt;/p&gt;
[quote user="Rohit Rajapure"]8bit resolution is sufficient for me so I am going ahead with an 8bit resolution.[/quote]
&lt;p&gt;All right, that is great! Please keep in mind that you might loose some LSB to noise in your measurements.&lt;br /&gt;So, if you need 8 NOEB, then I would suggest that you use 10 bit resolution.&lt;/p&gt;
[quote user="Rohit Rajapure"]Thank you so much for your constant help.[/quote]
&lt;p&gt;It is no problem at all, I am happy to help!&lt;br /&gt;&lt;br /&gt;Please do not hesitate to open a new ticket if you should encounter any issues or questions in the future.&lt;br /&gt;&lt;br /&gt;Good luck with your development!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/267263?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 13:22:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a0c1e63-767c-4e82-8ba8-902a1910706e</guid><dc:creator>Rohit Rajapure</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;Yes, I am able to read all resolution values.&lt;/p&gt;
&lt;p&gt;8bit resolution is sufficient for me so I am going ahead with an 8bit resolution.&lt;/p&gt;
&lt;p&gt;Thank you so much for your constant help.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks and Regards&lt;/p&gt;
&lt;p&gt;Rohit R&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/267215?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 11:50:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75e82add-4bd5-48d3-815f-fbc599475d16</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Rohit,&lt;/p&gt;
[quote user="Rohit Rajapure"]I have resolved the resolution issue.[/quote]
&lt;p&gt;I am happy to hear that you were able to resolve your issue!&lt;/p&gt;
[quote user="Rohit Rajapure"]I am getting 8bit raw values and able to print on putty.[/quote]
&lt;p&gt;As I had understood it, you needed 12 bit resolution. Are you able to reconfigure to 12 bit resolution now?&lt;/p&gt;
[quote user="Rohit Rajapure"]- I have forgot to call saadc_config parameter in init function. I kept it NULL.[/quote]
&lt;p&gt;I see. To avoid this in the future, I would advise that you remove obsolete code from your project instead of commenting it out - this increases readability tenfold.&lt;br /&gt;If you are worried that you will need the commented out code later, place it in a temporary work file.&lt;br /&gt;&lt;br /&gt;Please do not hesitate to open a new ticket if you should encounter any other issues or questions in the future.&lt;br /&gt;&lt;br /&gt;Good luck with your development!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/267174?ContentTypeID=1</link><pubDate>Mon, 31 Aug 2020 10:17:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78d26289-a773-4055-b056-229cecf4b593</guid><dc:creator>Rohit Rajapure</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;It&amp;#39;s my fault. I have resolved the resolution issue.&lt;/p&gt;
&lt;p&gt;I am getting 8bit raw values and able to print on putty.&lt;/p&gt;
&lt;p&gt;Now, my next step is to convert&amp;nbsp; into voltage range.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    err_code = nrf_drv_saadc_init(&amp;amp;saadc_config, saadc_callback);
    APP_ERROR_CHECK(err_code);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;- I have forgot to call saadc_config parameter in init function. I kept it NULL.&lt;/p&gt;
&lt;p&gt;it&amp;#39;s my fault.&lt;/p&gt;
&lt;p&gt;Thanks and Regards&lt;/p&gt;
&lt;p&gt;Rohit R&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/267059?ContentTypeID=1</link><pubDate>Sat, 29 Aug 2020 06:50:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5cd17709-65d1-4ba4-8e3b-e3ed3fbc10c8</guid><dc:creator>Rohit Rajapure</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/64867/saadc-configuration/266899"]Be advised that the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.0%2Fgroup__nrfx__saadc.html&amp;amp;anchor=gad0786760626db89142b8216320f223c8"&gt;NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE&lt;/a&gt; is a macro for setting up the default channel configurations. You may then change those that you do not want to be default. In your case, you are changing some things to the value that they already hold, which is why I am mentioning this.[/quote]
&lt;p&gt;- I did configuration as below,&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;  nrf_saadc_channel_config_t channel_config;     
   channel_config.gain = NRF_SAADC_GAIN1_4;
   channel_config.reference = NRF_SAADC_REFERENCE_VDD4;
   channel_config.mode = NRF_SAADC_MODE_SINGLE_ENDED;
   channel_config.pin_n = NRF_SAADC_INPUT_DISABLED; 
   channel_config.pin_p = NRF_SAADC_INPUT_AIN2;
   channel_config.resistor_n = NRF_SAADC_RESISTOR_DISABLED;
   channel_config.resistor_p = NRF_SAADC_RESISTOR_DISABLED;
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/64867/saadc-configuration/266899"]&amp;nbsp;The SAADC example is using 10 bit resolution as default. Could you show me where you have changed this to 12 bit? Also, this is not done as part of the channel configuration, but rather as part of the SAADC configuration.[/quote]
&lt;p&gt;- I set resolution here and in sdk_config.h file to&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    nrf_drv_saadc_config_t saadc_config;
    saadc_config.resolution = NRF_SAADC_RESOLUTION_12BIT;   //12 bit resolution&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// &amp;lt;0=&amp;gt; 8 bit 
// &amp;lt;1=&amp;gt; 10 bit 
// &amp;lt;2=&amp;gt; 12 bit 
// &amp;lt;3=&amp;gt; 14 bit 

#ifndef NRFX_SAADC_CONFIG_RESOLUTION
#define NRFX_SAADC_CONFIG_RESOLUTION 2
#endif
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/64867/saadc-configuration/266899"]What specifically would you like me to take a look at in your schematics / in your other ticket?&lt;br /&gt;It seems to me that you are getting good help by my colleague Jørgen in the other ticket.[/quote]
&lt;p&gt;- In the previous post, you had asked for the powering procedure of the device. So I shared this ticket and asked to go through the schematic more clear picture about powering MCU and ADC input pin related details.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/64867/saadc-configuration/266899"]As for the SAADC configuration, you still have not told me what your required resolution for the project is, and what your intended sampling frequency is.[/quote]
&lt;p&gt;- What I was informed is by a customer about capacitor voltage should be as below,&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;&amp;quot;a voltage of capacitor&amp;lt;100V&amp;nbsp; (This corresponds to a voltage of 0.72V on&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;strong&gt;&amp;nbsp; Analog input of the nRF528)&amp;quot;&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;- &lt;/em&gt;So I need an 8bit resolution sufficient for me but I was trying with 12bit and sampling frequency 50Hz.&lt;/p&gt;
&lt;p&gt;- In both 8bit and 12bit resolution also I am getting 10bit values 1023 when connecting to VDD. &lt;/p&gt;
&lt;p&gt;Please correct If am doing wrong, As my capacitor pin is connected to AIN2/P0_4 so I have to short P0_4 to VDD/GND to check values correct?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;As mentioned above snippet, I set the resolution as 12bit in both files still I am getting 1023 raw values when I connect to VDD.&lt;/p&gt;
&lt;p&gt;Can you let me know your views on this?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks and Regards&lt;/p&gt;
&lt;p&gt;Rohit R&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/266899?ContentTypeID=1</link><pubDate>Fri, 28 Aug 2020 08:24:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d43359bc-03e4-4b15-ab2f-dc93c1dc0636</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Rohit R,&lt;/p&gt;
[quote user="Rohit Rajapure"]My configurations,[/quote]
&lt;p&gt;This is fine, with your code, you configure AIN2 channel to have 1/4 gain, VDD/4 reference and 10 us TAQ.&lt;br /&gt;Be advised that the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.0%2Fgroup__nrfx__saadc.html&amp;amp;anchor=gad0786760626db89142b8216320f223c8"&gt;NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE&lt;/a&gt; is a macro for setting up the default channel configurations. You may then change those that you do not want to be default. In your case, you are changing some things to the value that they already hold, which is why I am mentioning this.&lt;/p&gt;
[quote user="Rohit Rajapure"]After making changes in SDK example with the above configuration. When I followed the testing steps suggested for SDK example by Connecting pin to VDD and GND, I am still getting 10bit raw value. But I have configured for 12bit.[/quote]
&lt;p&gt;&amp;nbsp;The SAADC example is using 10 bit resolution as default. Could you show me where you have changed this to 12 bit? Also, this is not done as part of the channel configuration, but rather as part of the SAADC configuration.&lt;/p&gt;
[quote user="Rohit Rajapure"]Once I get exact raw values then I can apply voltage converter calculation as mentioned by you in the previous post.[/quote]
&lt;p&gt;Yes, lets ensure that you are getting the correct raw SAADC output values first. This is a good approach.&lt;/p&gt;
[quote user="Rohit Rajapure"]Please go through schematic also and let me know if I am making any mistakes in configuring SAADC.[/quote]
&lt;p&gt;What specifically would you like me to take a look at in your schematics / in your other ticket?&lt;br /&gt;It seems to me that you are getting good help by my colleague Jørgen in the other ticket.&lt;br /&gt;&lt;br /&gt;As for the SAADC configuration, you still have not told me what your required resolution for the project is, and what your intended sampling frequency is.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/266852?ContentTypeID=1</link><pubDate>Fri, 28 Aug 2020 04:20:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d4172b3-b365-4d66-8ede-4fdd9a3f4671</guid><dc:creator>Rohit Rajapure</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;As you suggested I tried configuring my custom requirement in SDK example.&lt;/p&gt;
&lt;p&gt;My configurations,&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    nrf_saadc_channel_config_t channel_config =
        NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN2);  //singale shot and channel config 
        
   channel_config.gain = NRF_SAADC_GAIN1_4;
   channel_config.reference = NRF_SAADC_REFERENCE_VDD4;
   channel_config.mode = NRF_SAADC_MODE_SINGLE_ENDED;
   channel_config.pin_n = NRF_SAADC_INPUT_DISABLED; 
   channel_config.pin_p = NRF_SAADC_INPUT_AIN2;
   channel_config.resistor_n = NRF_SAADC_RESISTOR_DISABLED;
   channel_config.resistor_p = NRF_SAADC_RESISTOR_DISABLED;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;After making changes in SDK example with the above configuration. When I followed the testing steps suggested for SDK example by Connecting pin to VDD and GND, I am still getting 10bit raw value. But I have configured for 12bit.&lt;/p&gt;
&lt;p&gt;Once I get exact raw values then I can apply voltage converter calculation as mentioned by you in the previous post.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And one more thing I would like share is, my end device is Zigbee based Dimming control hardware. The selection of intensity levels is depended on the ADC values of the capacitor. More details you check mine below ticket where I have shared my schematic and details. This hardware is basically powered by 230V then using internal voltage converter we make 3V to power up nRF MCU.&lt;/p&gt;
&lt;p&gt;Please go through schematic also and let me know if I am making any mistakes in configuring SAADC.&lt;/p&gt;
&lt;p&gt;ticket link - &lt;a href="https://devzone.nordicsemi.com/support/255201"&gt;https://devzone.nordicsemi.com/support/255201&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks in advance&lt;/p&gt;
&lt;p&gt;Rohit R&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/265979?ContentTypeID=1</link><pubDate>Mon, 24 Aug 2020 12:30:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d49bf7d0-9e31-41aa-b153-bf58fadd27d1</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Rohit,&lt;/p&gt;
[quote user="Rohit Rajapure"]I will note your suggestion and look into it.[/quote]
&lt;p&gt;Great! Please do not hesitate to let me know if anything should be unclear.&lt;/p&gt;
&lt;p&gt;[quote user="Rohit Rajapure"][/quote]&lt;/p&gt;
&lt;p&gt;The voltage level of the input capacitor C14, 2.2µF / 400V to the Step-Down controller must be monitored. A voltage divider is used across the capacitor from R2, 3M3, and R3, 24k. The tapped voltage is measured at pin port P0.04 / AIN2 of the nRF52840. The expected voltage at the input of the controller is between 2.35V and 0V. The voltage at the capacitor must not fall below the value of 100V.&lt;/p&gt;
&lt;p&gt;Capacitor ( C14, 2.2µF) which is connected to Analog pin and my requirement is I have to read the voltage level.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Yes, like mentioned in the original ticket, but what is your required resolution and sampling frequency?&lt;br /&gt;If you only need to know when the voltage crosses a certain threshold then you might want to look into using the SAADC limits feature.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/265953?ContentTypeID=1</link><pubDate>Mon, 24 Aug 2020 11:40:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:efc0d220-7477-483d-a145-31a642265a15</guid><dc:creator>Rohit Rajapure</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;Thanks for the feedback,&lt;/p&gt;
&lt;p&gt;I will note your suggestion and look into it.&lt;/p&gt;
&lt;p&gt;Also, I am sharing my end requirement and image below,&lt;/p&gt;
&lt;p&gt;The voltage level of the input capacitor C14, 2.2&amp;micro;F / 400V to the Step-Down controller must be monitored. A voltage divider is used across the capacitor from R2, 3M3, and R3, 24k. The tapped voltage is measured at pin port P0.04 / AIN2 of the nRF52840. The expected voltage at the input of the controller is between 2.35V and 0V. The voltage at the capacitor must not fall below the value of 100V.&lt;/p&gt;
&lt;p&gt;Capacitor ( C14, 2.2&amp;micro;F) which is connected to Analog pin and my requirement is I have to read the voltage level.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/Capacitor-voltage-mes.png" /&gt;&lt;/p&gt;
&lt;p&gt;I hope this helps you understand my requirement.&lt;/p&gt;
&lt;p&gt;Looking forward to your reply on this.&lt;/p&gt;
&lt;p&gt;Thanks and Regards&lt;/p&gt;
&lt;p&gt;Rohit R&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/265938?ContentTypeID=1</link><pubDate>Mon, 24 Aug 2020 10:58:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2103451c-01a5-4643-b74b-1a01b94ea426</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Rohit,&lt;/p&gt;
[quote user="Rohit Rajapure"]sorry for the late response, I was not well so could not check any messages or notification.[/quote]
&lt;p&gt;It is no problem at all, do not worry. I am glad to hear that you are back to health!&lt;/p&gt;
[quote user="Rohit Rajapure"]I tried, I am getting same result -3 and 1023. I think I am still making any mistake or i did not understand it clear.[/quote]
&lt;p&gt;With the SAADC at 10-bit resolution, 1023 = VDD, and -3 = GND. I would at least expect the LSB to fluctuate on your measurements.&lt;/p&gt;
[quote user="Rohit Rajapure"]Is this correct or not? asap.[/quote]
&lt;p&gt;Well, it is hard to say really - you have not told me what your goal is, so it is hard for me to confirm if this is the right approach.&lt;br /&gt;If you are trying to measure one VDD pin and one GND pin, then you are correct.&lt;br /&gt;&lt;br /&gt;I would also recommend that you make use of the nrfx_saadc driver rather than the legacy nrf_drv driver. Additionally, I would advise you to use the PPI peripheral to connect your SAMPLE_STARt task to a timer event ( like demonstrated in the SAADC example from the SDK ) rather than having a given delay and manually having the CPU start each conversion ( with the call to&amp;nbsp;nrf_drv_saadc_sample. I would not recommend the current approach, as it uses excess CPU resources, and is generally inaccurate and not power optimized at all.&lt;br /&gt;On a general note, I would also mention that it is less-than-ideal for you to provide the code as you have done here. The large chunks of commented out code should not be included, because it takes the focus away from what you actually would like me to take a look at and provide feedback for.&lt;br /&gt;&lt;br /&gt;In conclusion, I would recommend that you revert to the general setup and approach of the SAADC example from the SDK ( which uses PPI ), instead of the implementation you have now. However, since I do not know exactly what you are trying to achieve, then the current approach that you have implemented might very well suit your purpose.&lt;br /&gt;&lt;br /&gt;If you would like to have the measurements displayed in millivolts ( mV ) instead of raw SAADC outputs then you need to convert them using the formula I referenced in my earlier comment. If you would like to see how battery measurement is implemented in another example, please have a look at the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/ble_sdk_app_proximity.html"&gt;BLE Proximity Example from the SDK&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/265449?ContentTypeID=1</link><pubDate>Thu, 20 Aug 2020 06:35:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:28f6ab2a-c64b-4620-a225-126775e23fad</guid><dc:creator>Rohit Rajapure</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;Please find my main.c file, I tried below configuration can you please check the file and let me know&lt;/p&gt;
&lt;p&gt;Is this correct or not? asap.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/2311.main.c"&gt;devzone.nordicsemi.com/.../2311.main.c&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I tried, I am getting same result -3 and 1023. I think I am still making any mistake or i did not understand it clear.&lt;/p&gt;
&lt;p&gt;Thanks and Regards&lt;/p&gt;
&lt;p&gt;Rohit R&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/265437?ContentTypeID=1</link><pubDate>Thu, 20 Aug 2020 04:12:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e1e735c9-8a43-4804-959e-adc8f064c05e</guid><dc:creator>Rohit Rajapure</dc:creator><description>&lt;p&gt;Hi Karl,&lt;/p&gt;
&lt;p&gt;Thanks for the response.&lt;/p&gt;
&lt;p&gt;I will note down points and try the configuration accordingly and share my result.&lt;/p&gt;
&lt;p&gt;And sorry for the late response, I was not well so could not check any messages or notification. I will check and let you know.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks and Regards&lt;/p&gt;
&lt;p&gt;Rohit R&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/264799?ContentTypeID=1</link><pubDate>Mon, 17 Aug 2020 09:14:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d4411e3-e3b9-403d-b39c-370e81080235</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again Rohit,&lt;/p&gt;
[quote user="Rohit Rajapure"]Yes, I have seen the document and SDK examples too.[/quote]
&lt;p&gt;Great, then we are off to a good start!&lt;/p&gt;
[quote user="Rohit Rajapure"]I am modifying SDK example as per my requirement, I have shared the changes in the previous post.[/quote]
&lt;p&gt;Regarding what you have shared in your other comment, I have some questions:&lt;br /&gt;- 1), 2), and 3) is just setting up a configuration structure, but they are not actually initializing any channel with that configuration. You will need to use &lt;em&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.0%2Fgroup__nrfx__saadc.html&amp;amp;anchor=gab74892a83a2f842436fac5f1462eca6a"&gt;nrfx_saadc_channel_init&lt;/a&gt;&amp;nbsp;&lt;/em&gt;for this. Please also note that the &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsdk_nrf5_v17.0.0%2Fgroup__nrfx__saadc.html&amp;amp;anchor=gad0786760626db89142b8216320f223c8"&gt;NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_S&lt;/a&gt;&lt;span&gt;E only generates a &amp;quot;default configuration struct for single ended input on the specified channel&amp;quot; struct, so any modifications to the default single ended input configuration will have to be done after this line.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;- 4) triggers a sampling, but no error check is performed. You will need to pass the error code to APP_ERROR_CHECK for this.&lt;br /&gt;&lt;br /&gt;- 5) this function is used to provide a new buffer to the SAADC. You should call this function as part of the DONE event callback and the SAADC init.&lt;br /&gt;&lt;br /&gt;- 7) a &amp;amp; b:&lt;br /&gt;&lt;br /&gt;You seem to get the SAADC outputs ~1024 and ~0 when connected to VDD and GND respectively. Given the 1), 2), and 3) I suspect that these values were acquired on pin AIN0, with the default single ended configuration. The SAADC output 1024 with 10 bit resolution, 1 / 6 gain and 600 mV reference equals 3.6 V using the formula provided in the documentation:&lt;/p&gt;
&lt;pre style="padding-left:30px;"&gt;&lt;code&gt;RESULT = (V(P) – V(N)) * (GAIN/REFERENCE) * 2&lt;sup&gt;(RESOLUTION - m)&lt;/sup&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;br /&gt;You should also perform a calibration of the SAADC after initialization and following significant temperature changes.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For future reference, please use the &amp;quot;Insert -&amp;gt; Code&amp;quot; option here on DevZone when submitting code, this drastically increases readability.&lt;/p&gt;
[quote user="Rohit Rajapure"]- Okay, let me try this configuration related Gain and check the result.[/quote]
&lt;p&gt;Yes, please try the other configuration and let me know what samples you receive.&lt;/p&gt;
&lt;p&gt;[quote user="Rohit Rajapure"][/quote]&lt;/p&gt;
&lt;p&gt;- One more question, I am using P0.04 / AIN2, with respect to SDK example as per my understanding AIN2 means the channel 2 and to configure this we need to call,&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;nrf_saadc_channel_config_t channel_config =&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN2);&amp;nbsp; //single shot and channel config&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I am correct in configuring pin or did I miss something.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Yes, at least partly - see my above comments. This is just generating the configuration struct - you are not actually initializing the channel.&lt;/p&gt;
[quote user="Rohit Rajapure"]If you make this ticket private then I can share the schematic file here as it confidential.[/quote]
&lt;p&gt;For the current SAADC issues I do not think I will need to see the schematics, but I may convert the ticket to private at any time if you would like - just let me know and it will be done.&lt;br /&gt;&lt;br /&gt;As a side note I will also have to mention that I highly recommend making use of the NRFX SAADC driver, instead of the nrf_drv_* legacy driver.&lt;br /&gt;As you will see if you dive into the nrf_drv_* legacy drivers source code, it is now just forwarding macros to the NRFX driver, so functionally the change from switching to the NRFX driver is nothing, but it will decrease future work if the legacy driver is discontinues in future releases.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Looking forward to resolving this issue together!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/264752?ContentTypeID=1</link><pubDate>Mon, 17 Aug 2020 07:44:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:786ede19-d57f-4d89-9491-3c43b0b531b6</guid><dc:creator>Rohit Rajapure</dc:creator><description>&lt;p&gt;Hi Karl, &lt;/p&gt;
&lt;p&gt;Yes, I have seen the document and SDK examples too.&lt;/p&gt;
&lt;p&gt;I am modifying SDK example as per my requirement, I have shared the changes in the previous post.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/64867/saadc-configuration/264749"]How is your nRF52840 supplies with power, are you using the coin cell battery, USB or external power?&lt;br /&gt;In the case of USB / 3 V power:[/quote]
&lt;p&gt;- It is basically a light Dimming control circuit we are using 230V and then using the voltage regulator and divider we are powering up MCU with 3.3V. If you make this ticket private then I can share the schematic file here as it confidential. &lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/64867/saadc-configuration/264749"]If you would like your SAADC to have a the input range 0 - 2.35 V, you could either use reference VDD/4 and gain 1/3, which yields the input range 0 - 2.27 V, or you could use VDD/4 and gain 1/4 and get 0 - 3 V.[/quote]
&lt;p&gt;- Okay, let me try this configuration related Gain and check the result. &lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;- One more question, I am using P0.04 / AIN2, with respect to SDK example as per my understanding AIN2 means the channel 2 and to configure this we need to call,&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;nrf_saadc_channel_config_t channel_config =&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN2);&amp;nbsp; //single shot and channel config&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I am correct in configuring pin or did I miss something.&lt;/p&gt;
&lt;p&gt;Correct me If i am doing anything wrong.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks and Regards&lt;/p&gt;
&lt;p&gt;Rohit R&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/264749?ContentTypeID=1</link><pubDate>Mon, 17 Aug 2020 07:32:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b8c81da1-3f80-4be3-9d0b-57a2f96edf35</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello Rohit R,&lt;br /&gt;&lt;br /&gt;Have you seen &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Fsaadc.html&amp;amp;anchor=unique_1891067092"&gt;the formulas for calculating SAADC input range in the SAADC documentation&lt;/a&gt;?&lt;/p&gt;
[quote user=""]The expected voltage at the input of the controller is between 2.35V and 0V.[/quote][quote user=""]This is my requirement can anyone help how to configure SAADC with respect to my requirement.[/quote]
&lt;p&gt;How is your nRF52840 supplies with power, are you using the coin cell battery, USB or external power?&lt;br /&gt;In the case of USB / 3 V power:&lt;br /&gt;If you would like your SAADC to have a the input range 0 - 2.35 V, you could either use reference VDD/4 and gain 1/3, which yields the input range 0 - 2.27 V, or you could use VDD/4 and gain 1/4 and get 0 - 3 V.&lt;br /&gt;Have you seen the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.0/nrf_dev_saadc_example.html"&gt;SAADC Example&lt;/a&gt;&amp;nbsp;from the SDK? It demonstrates how to setup and use the SAADC - then you could just input your own configuration, and you should start seeing your measurements.&lt;br /&gt;&lt;br /&gt;Please let me know if anything should be unclear with the forumlas, or how to go about doing the configuration.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/264745?ContentTypeID=1</link><pubDate>Mon, 17 Aug 2020 07:26:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c8fb865-9bc3-4a42-afa5-b8f862382a4b</guid><dc:creator>Rohit Rajapure</dc:creator><description>&lt;p&gt;Hi &lt;span class="user-name"&gt;Istvan,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="user-name"&gt;Thank you for the quick response&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="user-name"&gt;I have referred those documents and even SDK examples. &lt;/span&gt;&lt;/p&gt;
[quote userid="73726" url="~/f/nordic-q-a/64867/saadc-configuration/264742"]The 0.6 V internal reference is used by default, which you can tweak by changing the GAIN factor.[/quote]
&lt;p&gt;&lt;span class="user-name"&gt;- I did not understand it clearly. Can you please explain more regarding the Gain factor. &lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="user-name"&gt;For the tested purpose, I have configured as below,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="user-name"&gt;1) saadc_config.resolution = NRF_SAADC_RESOLUTION_12BIT;&amp;nbsp;&amp;nbsp; //12 bit resolution&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="user-name"&gt;2) NRF_DRV_SAADC_DEFAULT_CHANNEL_CONFIG_SE(NRF_SAADC_INPUT_AIN2);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="user-name"&gt;3) channel_config.gain = NRF_SAADC_GAIN1;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="user-name"&gt;4) err_code = nrf_drv_saadc_sample(); // Check error&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="user-name"&gt;5) &amp;nbsp;&amp;nbsp;&amp;nbsp; err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool[0], SAMPLES_IN_BUFFER);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; APP_ERROR_CHECK(err_code);&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="user-name"&gt;6) void saadc_callback(nrf_drv_saadc_evt_t const * p_event)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (p_event-&amp;gt;type == NRF_DRV_SAADC_EVT_DONE)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ret_code_t err_code;&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; err_code = nrf_drv_saadc_buffer_convert(p_event-&amp;gt;data.done.p_buffer, SAMPLES_IN_BUFFER);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; APP_ERROR_CHECK(err_code);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int i;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NRF_LOG_INFO(&amp;quot;ADC event number: %d&amp;quot;, (int)m_adc_evt_counter);&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (i = 0; i &amp;lt; SAMPLES_IN_BUFFER; i++)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NRF_LOG_INFO(&amp;quot;%d&amp;quot;, p_event-&amp;gt;data.done.p_buffer[i]);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; m_adc_evt_counter++;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;}&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="user-name"&gt;7) Buffer size is 1&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="user-name"&gt;And I have shorted P0_4 to VCC and GND Dev-kit on putty it shows me, &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="user-name"&gt;a) when short to VCC - 1023 &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="user-name"&gt;b) when short to GND - -6, -4, -3&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="user-name"&gt;I am not understanding with these values whether it is correct or wrong. Basically not understood SAADC config and it&amp;#39;s result. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="user-name"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="user-name"&gt;Thanks and Regards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="user-name"&gt;Rohit R&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Configuration</title><link>https://devzone.nordicsemi.com/thread/264742?ContentTypeID=1</link><pubDate>Mon, 17 Aug 2020 07:15:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e335647-c4f2-46f1-bd1a-4e5a3f8ba644</guid><dc:creator>IstvanS</dc:creator><description>&lt;p&gt;Check out the SAADC example from the SDK: &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fstruct_sdk%2Fstruct%2Fsdk_nrf5_latest.html&amp;amp;cp=7_1"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fstruct_sdk%2Fstruct%2Fsdk_nrf5_latest.html&amp;amp;cp=7_1&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And the SAADC documentation: &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Fsaadc.html&amp;amp;cp=2_1_0_36_2&amp;amp;anchor=saadc_digital_output"&gt;https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.nrf52832.ps.v1.1%2Fsaadc.html&amp;amp;cp=2_1_0_36_2&amp;amp;anchor=saadc_digital_output&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The 0.6 V internal reference is used by default, which you can tweak by changing the GAIN factor.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>