<?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>nRF52832 SDK14 - SAADC calibration issues</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/29806/nrf52832-sdk14---saadc-calibration-issues</link><description>I&amp;#39;m using the nRF52832 with softdevice s132 and SDK14 with ARM GCC 
 I&amp;#39;m trying to set up the SAADC peripheral to read battery voltage, and I can get everything working as expected except periodic calibration. At boot, I call my initialization function</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 09 Sep 2019 12:31:55 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/29806/nrf52832-sdk14---saadc-calibration-issues" /><item><title>RE: nRF52832 SDK14 - SAADC calibration issues</title><link>https://devzone.nordicsemi.com/thread/208683?ContentTypeID=1</link><pubDate>Mon, 09 Sep 2019 12:31:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:35473fcc-24b7-4753-9dae-1040aaad2287</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;I&amp;#39;m not sure exactly what you refer to with your question, but there are two erratas related to SAADC with TACQ &amp;lt; 10us that I can see, both with a workaround:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/errata_nRF52832_Rev2/ERR/nRF52832/Rev2/latest/anomaly_832_74.html?cp=3_1_1_0_1_14"&gt;[74] SAADC: Started events fires prematurely&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/errata_nRF52832_Rev2/ERR/nRF52832/Rev2/latest/anomaly_832_178.html?cp=3_1_1_0_1_45"&gt;[178] SAADC: END event firing too early&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 SDK14 - SAADC calibration issues</title><link>https://devzone.nordicsemi.com/thread/208559?ContentTypeID=1</link><pubDate>Sun, 08 Sep 2019 13:09:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c2e82500-27c9-42b3-8c77-5033946d987e</guid><dc:creator>Franz</dc:creator><description>&lt;p&gt;Sorry for a reply to an old topic, but I stumbled upon this also, and aborting in the CALIBRATE_DONE callback is a solution to the workaround... for sample times &amp;gt;=10&amp;micro;s. What is a reasonable workaround for 3&amp;micro;s/5&amp;micro;s?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 SDK14 - SAADC calibration issues</title><link>https://devzone.nordicsemi.com/thread/119398?ContentTypeID=1</link><pubDate>Thu, 01 Feb 2018 15:47:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3607daea-806f-4a58-a34e-980883820a47</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;You are correct, but I answered with my previous comment in mind:&lt;/p&gt;
[quote user="joh2"]You need to stop the SAADC after calibration.[/quote]
&lt;p&gt;If you call the abort task&amp;nbsp;&lt;strong&gt;during&lt;/strong&gt; calibration, you will have to wait for the STOPPED event. If you call it&amp;nbsp;&lt;strong&gt;after&lt;/strong&gt; calibration, the state should not be set to IDLE undtil after the STOPPED event is received.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 SDK14 - SAADC calibration issues</title><link>https://devzone.nordicsemi.com/thread/118309?ContentTypeID=1</link><pubDate>Tue, 30 Jan 2018 18:27:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:897a4482-ca97-4532-8ba2-c4a10b6fb8ed</guid><dc:creator>Andy</dc:creator><description>&lt;p&gt;@Jorgen Holmefjord, as of SDK 14, nrf_drv_saadc_abort is not sufficient, as it does not wait for the SAADC to become IDLE when in calibration mode. Instead, it just sets the state to IDLE, which is incorrect.&lt;/p&gt;
&lt;p&gt;@ndarkness, You should manually loop and wait for the SAADC state to be IDLE like this:
&lt;code&gt;while(NRF_SAADC-&amp;gt;STATUS == (SAADC_STATUS_STATUS_Busy &amp;lt;&amp;lt; SAADC_STATUS_STATUS_Pos));&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 SDK14 - SAADC calibration issues</title><link>https://devzone.nordicsemi.com/thread/118307?ContentTypeID=1</link><pubDate>Tue, 12 Dec 2017 11:34:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8fd17bf5-7a67-40f0-aa85-658efe338efe</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;The document refers to the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/saadc.html?cp=2_1_0_36_10#topic"&gt;peripheral tasks and event registers&lt;/a&gt;, i.e. starting the &lt;code&gt;TASKS_STOP&lt;/code&gt; task and wait for the &lt;code&gt;EVENTS_STOPPED&lt;/code&gt; event. If you are using the SAADC driver in the SDK, you can call &lt;code&gt;nrf_drv_saadc_abort&lt;/code&gt; to stop the SAADC.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 SDK14 - SAADC calibration issues</title><link>https://devzone.nordicsemi.com/thread/118308?ContentTypeID=1</link><pubDate>Tue, 12 Dec 2017 11:08:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f7286b93-1fd5-4d6d-b7b5-42adff627636</guid><dc:creator>ndarkness</dc:creator><description>&lt;p&gt;@Jorgen Holmefjord, how do you stop exactly the SAADC? I have this issue with SDK12.3 and I don&amp;#39;t know what functions to use when that document says &lt;code&gt;STOP-&amp;gt;STOPPED&lt;/code&gt;. Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 SDK14 - SAADC calibration issues</title><link>https://devzone.nordicsemi.com/thread/118306?ContentTypeID=1</link><pubDate>Tue, 31 Oct 2017 15:21:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77543662-9678-43bc-a50c-814e6ba729da</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;There is an errata on this, PAN-86: &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.Rev1.errata/anomaly_832_86.html?cp=2_1_1_0_1_23"&gt;SAADC: Triggering START task after offset calibration may write a sample to RAM&lt;/a&gt;. You need to stop the SAADC after calibration. I thought this was implemented in the driver, but it does not look like it is. I will check this.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 SDK14 - SAADC calibration issues</title><link>https://devzone.nordicsemi.com/thread/118305?ContentTypeID=1</link><pubDate>Fri, 27 Oct 2017 20:09:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c2a6842-2d67-42dd-8d1e-a2ca81f7674e</guid><dc:creator>Sydney</dc:creator><description>&lt;p&gt;edit: sorry I had trouble getting my code to format here, so I edited the relevant code into the original post. But yes, I am doing the buffer conversion on my two buffers, and then I schedule a call to a function that calls nrf_drv_saadc_sample().&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 SDK14 - SAADC calibration issues</title><link>https://devzone.nordicsemi.com/thread/118304?ContentTypeID=1</link><pubDate>Fri, 27 Oct 2017 08:59:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:298a96ec-5a9f-442d-8ffd-2b80947e24a0</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Are you setting up a buffer for conversion before you call &lt;code&gt;nrf_drv_saadc_sample&lt;/code&gt;? Could you post a code snippet of the &lt;code&gt;NRF_DRV_SAADC_EVT_CALIBRATEDONE&lt;/code&gt; event handling?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 SDK14 - SAADC calibration issues</title><link>https://devzone.nordicsemi.com/thread/118303?ContentTypeID=1</link><pubDate>Tue, 24 Oct 2017 17:21:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2981ba6-74c3-4b2a-91b6-a396167d5ee0</guid><dc:creator>Sydney</dc:creator><description>&lt;p&gt;Thanks- this does appear to fix the abort timeout, but now there&amp;#39;s another issue that may be related. In my SAADC event handler, on NRF_DRV_SAADC_EVT_CALIBRATEDONE, I schedule an event that will call nrf_drv_saadc_sample() the next time the scheduler is processed. When this scheduled event happens, I can confirm that nrf_drv_saadc_sample() does return NRF_SUCCESS, but then I never get any SAADC events. So the next time my timer expires and wants to call nrf_drv_saadc_sample() again, my code can tell that the last sample request never returned. When this happens I can abort, buffer_convert(), and sample() again and it works. But is there a way to detect that nrf_drv_saadc_sample() isn&amp;#39;t going to generate any events even though it returned NRF_SUCCESS?&lt;/p&gt;
&lt;p&gt;Also of interest- I noticed if I call nrf_delay_us(100) at the end of my CALIBRATEDONE handler, the problem doesn&amp;#39;t happen.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52832 SDK14 - SAADC calibration issues</title><link>https://devzone.nordicsemi.com/thread/118302?ContentTypeID=1</link><pubDate>Tue, 24 Oct 2017 12:35:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2fe8ae87-58c3-49bb-8d4c-1ab288957969</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;It looks like this issue is related to the low power mode of the SAADC driver, and what events are generated by the &lt;code&gt;NRF_SAADC_TASK_STOP&lt;/code&gt; task triggered within &lt;code&gt;nrf_drv_saadc_abort()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;From the documentation of &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.0.0/group__nrf__drv__saadc.html#ga427b72199784d4c386b896d61079f7c8"&gt;&lt;code&gt;nrf_drv_saadc_abort()&lt;/code&gt;&lt;/a&gt;, the following note is given:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;NRF_DRV_SAADC_EVT_DONE&lt;/code&gt; event will be
generated if there is a conversion in
progress. Event will contain number of
words in the sample buffer.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A conversion will be in progress when the &lt;code&gt;NRF_SAADC_TASK_START&lt;/code&gt; task have been triggered. In &lt;code&gt;nrf_drv_saadc_init()&lt;/code&gt; interrupts are enabled for &lt;code&gt;NRF_SAADC_EVENT_END&lt;/code&gt;, and &lt;code&gt;NRF_SAADC_EVENT_STARTED&lt;/code&gt; when low power mode is used, but not for &lt;code&gt;NRF_SAADC_EVENT_STOPPED&lt;/code&gt;. This is not an issue when low power mode is not used, as a call to &lt;code&gt;nrf_drv_saadc_buffer_convert&lt;/code&gt; will trigger &lt;code&gt;NRF_SAADC_TASK_START&lt;/code&gt;, but for low power mode, &lt;code&gt;NRF_SAADC_TASK_START&lt;/code&gt; is first triggered in call to &lt;code&gt;nrf_drv_saadc_sample()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;In normal operation mode, the END event will generate an interrupt, and call &lt;code&gt;SAADC_IRQHandler()&lt;/code&gt;. The handler will also detect the STOPPED event, and set the state to IDLE. In low power mode, no END event will be generated, and therefor no interrupts either.&lt;/p&gt;
&lt;p&gt;The solution to this issue would be to enable interrupt for &lt;code&gt;NRF_SAADC_EVENT_STOPPED&lt;/code&gt;,before triggering &lt;code&gt;NRF_SAADC_TASK_STOP&lt;/code&gt;. This will also be a better approach for normal operation mode, than relying on the NRF_SAADC_EVENT_END to generate the interruot. This can be achieved with this modified version of &lt;code&gt;nrf_drv_saadc_abort()&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;void nrf_drv_saadc_abort(void)
{
    if (nrf_drv_saadc_is_busy())
    {    
        nrf_saadc_int_enable(NRF_SAADC_INT_STOPPED);
        nrf_saadc_event_clear(NRF_SAADC_EVENT_STOPPED);
        nrf_saadc_task_trigger(NRF_SAADC_TASK_STOP);

        if (m_cb.adc_state == NRF_SAADC_STATE_CALIBRATION)
        {
            m_cb.adc_state = NRF_SAADC_STATE_IDLE;
        }
        else
        {
            // Wait for ADC being stopped.
            uint32_t timeout = HW_TIMEOUT;

            while ((m_cb.adc_state != NRF_SAADC_STATE_IDLE) &amp;amp;&amp;amp; (timeout &amp;gt; 0))
            {
                --timeout;
            }
            ASSERT(timeout &amp;gt; 0);
        }
        
        nrf_saadc_int_disable(NRF_SAADC_INT_STOPPED);

        m_cb.p_buffer           = 0;
        m_cb.p_secondary_buffer = 0;
        NRF_LOG_INFO(&amp;quot;Conversion aborted.&amp;quot;);
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I will report this issue internally. Thanks for reporting it!&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>