<?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 Measured sampling acquisition time is longer than expected</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/48754/saadc-measured-sampling-acquisition-time-is-longer-than-expected</link><description>Hi there, I have set my SAADC to have an acquisition time of 3us , however when I toggle a pin before and after calling 
 nrfx_saadc_sample_convert 
 I measure the time of one sample to be closer to 34us . Can you tell me why this is so? 
 I don&amp;#39;t require</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 24 Jun 2019 04:09:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/48754/saadc-measured-sampling-acquisition-time-is-longer-than-expected" /><item><title>RE: SAADC Measured sampling acquisition time is longer than expected</title><link>https://devzone.nordicsemi.com/thread/194206?ContentTypeID=1</link><pubDate>Mon, 24 Jun 2019 04:09:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b113af73-a6a8-411e-b1aa-a9a72260d330</guid><dc:creator>sammy91</dc:creator><description>&lt;p&gt;Ok I see, as I increase the oversampling, I get closer to what is expected&lt;br /&gt;&lt;br /&gt;Over 4x = 24us = &lt;strong&gt;6us&lt;/strong&gt;/sample&lt;br /&gt;Over 8x = 41us = &lt;strong&gt;5.1us&lt;/strong&gt;/sample&lt;br /&gt;Over 16x = 74us = &lt;strong&gt;4.6us&lt;/strong&gt;/sample&lt;br /&gt;&lt;br /&gt;Thanks for you help&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Measured sampling acquisition time is longer than expected</title><link>https://devzone.nordicsemi.com/thread/194122?ContentTypeID=1</link><pubDate>Fri, 21 Jun 2019 13:13:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ccc41b3e-a189-4b0c-9f5b-d8bcd1d724cb</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;but you&amp;#39;re still toggling a pin via CPU with significant overhead due to the driver processing the END event.&lt;br /&gt;&lt;br /&gt;If you want to measure the sample time then you &lt;strong&gt;need&lt;/strong&gt; to use PPI and GPIOTE to toggle the pin.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Measured sampling acquisition time is longer than expected</title><link>https://devzone.nordicsemi.com/thread/194074?ContentTypeID=1</link><pubDate>Fri, 21 Jun 2019 11:17:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2516d48f-059a-48a2-8cdf-9f052b4debbb</guid><dc:creator>sammy91</dc:creator><description>&lt;p&gt;Ok I&amp;#39;ve done it your way, and still measure about &lt;strong&gt;11us&lt;/strong&gt; when the time should be &amp;lt;(t&lt;sub&gt;ACQ&lt;/sub&gt;+t&lt;sub&gt;CONV&lt;/sub&gt;)&amp;times;2&lt;sup&gt;OVERSAMPLE&lt;/sup&gt;&lt;br /&gt;Im not using oversample, so it should be &lt;strong&gt;&amp;lt;5us&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt; Here&amp;#39;s my new code:&lt;/p&gt;
&lt;p&gt;Event Handler:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;bool ADC_IN_PROGRESS = false;
nrf_saadc_value_t adc_buf;
void saadc_event_handler(nrf_drv_saadc_evt_t const * p_event)
{
    if (p_event-&amp;gt;type == NRF_DRV_SAADC_EVT_DONE)
    {
        uint32_t err_code;

        adc_buf = p_event-&amp;gt;data.done.p_buffer[0];

        nrf_gpio_pin_clear(P1_PIN);     //TOGGLE PIN TO MEASURE TIME

        //set up conversion again
        err_code = nrfx_saadc_buffer_convert(p_event-&amp;gt;data.done.p_buffer, 1);
        if (err_code != NRF_SUCCESS){
            NRF_LOG_DEBUG(&amp;quot;ADC error %d&amp;quot;, err_code);
        }        
        APP_ERROR_CHECK(err_code);

        ADC_IN_PROGRESS = false;
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Take sample with nfrx_saadc_sample:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int32_t get_adc_value()
{
    ret_code_t err_code;

    nrf_gpio_cfg_output(P1_PIN);
    nrf_gpio_pin_set(P1_PIN);       //TOGGLE PIN TO MEASURE TIME

    //perform conversion
    ADC_IN_PROGRESS = true;
    err_code = nrfx_saadc_sample();
    if (err_code != NRF_SUCCESS){
        NRF_LOG_DEBUG(&amp;quot;ADC error %d&amp;quot;, err_code);
    }
    APP_ERROR_CHECK(err_code);

    //wait for adc to finish
    while(ADC_IN_PROGRESS);
    ADC_IN_PROGRESS = false;

    // return avg_adc;
    return adc_buf;
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Measured sampling acquisition time is longer than expected</title><link>https://devzone.nordicsemi.com/thread/193705?ContentTypeID=1</link><pubDate>Wed, 19 Jun 2019 13:48:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1666b64c-c3f9-4336-b3dd-fc2f65f41508</guid><dc:creator>haakonsh</dc:creator><description>&lt;p&gt;Short answer, you&amp;#39;re doing it wrong.&lt;br /&gt;&lt;br /&gt;I suggest you increase the buffer size and find an alternative trigger source for the SAMPLE task, like an RTC or TIMER.&amp;nbsp;&lt;br /&gt;Right now you&amp;#39;re taking individual samples via CPU, with substantial overhead in the driver, and then averaging them.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;You can also enable oversample and average over x number of samples with just one trigger of the SAMPLE task.&lt;br /&gt;&lt;br /&gt;See&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/saadc.html?cp=3_0_0_5_22"&gt;SAADC — Successive approximation analog-to-digital converter&lt;/a&gt;,&amp;nbsp;&lt;a title="SAADC" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/hardware_driver_saadc.html?cp=5_1_2_0_12"&gt;SAADC&lt;/a&gt;&amp;nbsp;driver documentation,&amp;nbsp;&lt;a title="SAADC driver" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/group__nrfx__saadc.html?cp=5_1_6_9_0_28_1"&gt;SAADC driver&lt;/a&gt;&amp;nbsp;API documentation,&amp;nbsp;&lt;a title="SAADC HAL" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/group__nrf__saadc__hal.html?cp=5_1_6_9_0_28_2"&gt;SAADC HAL&lt;/a&gt;&amp;nbsp;API documentation.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;See also&amp;nbsp;&lt;a title="PPI Example" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/ppi_example.html?cp=5_1_4_6_20"&gt;PPI Example&lt;/a&gt;,&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/ppi.html?cp=3_0_0_5_15"&gt;PPI — Programmable peripheral interconnect&lt;/a&gt;,&amp;nbsp;&lt;a title="PPI" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/group__nrf__ppi.html?cp=5_1_6_9_0_21"&gt;PPI&lt;/a&gt;&amp;nbsp;and HAL API documentation.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: SAADC Measured sampling acquisition time is longer than expected</title><link>https://devzone.nordicsemi.com/thread/193559?ContentTypeID=1</link><pubDate>Wed, 19 Jun 2019 07:45:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5b211d0a-24db-4232-ad47-d3c5d8d6dfa1</guid><dc:creator>sammy91</dc:creator><description>&lt;p&gt;Also, I am using nRF52840 with&amp;nbsp; SDK v15.2.0&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>