<?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>The Saadc of issue of uninit</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/32929/the-saadc-of-issue-of-uninit</link><description>i init the saadc and uinit saadc ,then init saadc again. my code is below: 
 err_code = nrf_drv_saadc_init(NULL, saadc_callback); err_code = nrf_drv_saadc_channel_init(0, &amp;amp;channel_config_se1); err_code = nrf_drv_saadc_buffer_convert(m_buffer_pool, 1);</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 13 Sep 2018 13:14:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/32929/the-saadc-of-issue-of-uninit" /><item><title>RE: The Saadc of issue of uninit</title><link>https://devzone.nordicsemi.com/thread/148634?ContentTypeID=1</link><pubDate>Thu, 13 Sep 2018 13:14:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e565105a-653b-46cd-a8dc-f9788b1a2640</guid><dc:creator>lenli</dc:creator><description>&lt;p&gt;&lt;span&gt;hi:&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The uninit function will stay in a while loop until the STOPPED event is generated. &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;There are just a while,it cant&amp;nbsp;be guaranteed to trigger the&amp;nbsp;STOPPED event.its&amp;nbsp;not&amp;nbsp;very strict and may be have some except. i agree with u said in later.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: The Saadc of issue of uninit</title><link>https://devzone.nordicsemi.com/thread/148619?ContentTypeID=1</link><pubDate>Thu, 13 Sep 2018 12:18:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1bd3fedb-dd89-4b78-863e-b9dd59b2fc07</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;The uninit function will stay in a while loop until the STOPPED event is generated.&amp;nbsp;There is no need for&amp;nbsp;interrupts to be enabled in order for events to be generated. If you frequently pull the STOPPED event register, you will read the event when it is generated. If a timeout should happen for some reason, before the STOPPED event is generated, this should be caught by the ASSERT (given that you have enabled ASSERTS by defining symbol DEBUG_NRF in the preprocessor symbols). You will not be able to call init function before the STOPPED event is generated, or you will be trapped in assert handler.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: The Saadc of issue of uninit</title><link>https://devzone.nordicsemi.com/thread/148582?ContentTypeID=1</link><pubDate>Thu, 13 Sep 2018 10:33:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0149ff69-b928-426c-9db1-23f3ba707a4e</guid><dc:creator>lenli</dc:creator><description>&lt;p&gt;hi:&lt;/p&gt;
&lt;p&gt;Long time no see.&lt;/p&gt;
&lt;p&gt;nrf_saadc_task_trigger(NRF_SAADC_TASK_STOP) is triggered in uninit function,as the interupt is disabled,so it cant happed.&lt;/p&gt;
&lt;p&gt;But the init function will enable the interupt in next time,the stop task will happed immediatly.&lt;/p&gt;
&lt;p&gt;in ADCIRQ some of state will hava some problem,as i said in above.&lt;/p&gt;
&lt;p&gt;i agree that&amp;nbsp;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a class="internal-link view-user-profile" href="https://devzone.nordicsemi.com/members/olaf1"&gt;Olaf&lt;/a&gt;&amp;nbsp;said.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: The Saadc of issue of uninit</title><link>https://devzone.nordicsemi.com/thread/136131?ContentTypeID=1</link><pubDate>Thu, 14 Jun 2018 10:49:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b900269d-6da6-484b-824b-df31f53bb062</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;I do not understand why this issue should apprear. The uninit function disable all interrupts before triggering STOP task. Implementing the workaround proposed by &lt;a href="https://devzone.nordicsemi.com/members/olaf1"&gt;Olaf&lt;/a&gt; will most likely break the functionality of the abort function (see &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/29806/nrf52832-sdk14---saadc-calibration-issues/118302#118302"&gt;this thread&lt;/a&gt; for more details - this issue have been fixed in SDK 15).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: The Saadc of issue of uninit</title><link>https://devzone.nordicsemi.com/thread/136011?ContentTypeID=1</link><pubDate>Wed, 13 Jun 2018 20:21:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1dc55cce-24d5-4c40-8eaf-28a961bc41b1</guid><dc:creator>device_nrf_001</dc:creator><description>&lt;p&gt;I am facing the same issue as discussed above. I tried using else if case as suggested above and it solved the problem but I don&amp;#39;t want to change the driver and would rather prefer use latest version of SDK if the problem is solved. I am using currently SDK 12. Kindly let me know if there is a SDK version which solves this issue.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: The Saadc of issue of uninit</title><link>https://devzone.nordicsemi.com/thread/136009?ContentTypeID=1</link><pubDate>Wed, 13 Jun 2018 20:15:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd424f85-b379-4c74-9789-d7f42373a4d8</guid><dc:creator>device_nrf_001</dc:creator><description>&lt;p&gt;has this issue resolved in SDK 14 or SDK 15?&lt;/p&gt;
&lt;p&gt;Please reply.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: The Saadc of issue of uninit</title><link>https://devzone.nordicsemi.com/thread/130189?ContentTypeID=1</link><pubDate>Sun, 29 Apr 2018 05:29:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:78bcacc9-a2e7-4602-9a6f-981e6b1c4758</guid><dc:creator>Olaf</dc:creator><description>&lt;p&gt;I guess the problem is inside the SAADC_IRQHandler. When using the uninit inside the callback there is a NRF_SAADC_EVENT_STOPPED event created. As the handling of the end event in line 117 (&lt;span&gt;nRF5_SDK_12.3.0_d7731ad&lt;/span&gt;) is not terminating the IRQ function, the stop event is handled in line 190, setting the state of the driver to NRF_SAADC_STATE_IDLE after the reinit has been performed in the callback. The next call to nrf_drv_saadc_sample is then creating the invalid state error.&lt;/p&gt;
&lt;p&gt;Solution: In SAADC_IRQHandler use else if to handle each kind of event:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void SAADC_IRQHandler(void)
{
    if (nrf_saadc_event_check(NRF_SAADC_EVENT_END))
    {
        nrf_saadc_event_clear(NRF_SAADC_EVENT_END);
        NRF_LOG_DEBUG(&amp;quot;Event: %s.\r\n&amp;quot;, (uint32_t)EVT_TO_STR(NRF_SAADC_EVENT_END));

        if (!m_cb.low_power_mode || m_cb.conversions_end)
        {
            nrf_drv_saadc_evt_t evt;
            evt.type               = NRF_DRV_SAADC_EVT_DONE;
            evt.data.done.p_buffer = (nrf_saadc_value_t *)m_cb.p_buffer;
            evt.data.done.size     = m_cb.buffer_size;

            if (m_cb.p_secondary_buffer == NULL)
            {
                m_cb.adc_state = NRF_SAADC_STATE_IDLE;
            }
            else
            {
                m_cb.buffer_size_left   = m_cb.secondary_buffer_size;
                m_cb.p_buffer           = m_cb.p_secondary_buffer;
                m_cb.buffer_size        = m_cb.secondary_buffer_size;
                m_cb.p_secondary_buffer = NULL;
                if (!m_cb.low_power_mode)
                {
                    nrf_saadc_task_trigger(NRF_SAADC_TASK_START);
                }
            }
            m_cb.event_handler(&amp;amp;evt);
            m_cb.conversions_end = false;
        }
    }
    else if (m_cb.low_power_mode &amp;amp;&amp;amp; nrf_saadc_event_check(NRF_SAADC_EVENT_STARTED))
    {
        nrf_saadc_event_clear(NRF_SAADC_EVENT_STARTED);
        NRF_LOG_DEBUG(&amp;quot;Event: %s.\r\n&amp;quot;, (uint32_t)EVT_TO_STR(NRF_SAADC_EVENT_STARTED));

        if (m_cb.buffer_size_left &amp;gt; m_cb.active_channels)
        {
            // More samples to convert than for single event.
            m_cb.buffer_size_left -= m_cb.active_channels;
            nrf_saadc_buffer_init((nrf_saadc_value_t *)&amp;amp;m_cb.p_buffer[m_cb.buffer_size -
                                                                      m_cb.buffer_size_left],
                                  m_cb.active_channels);
        }
        else if ((m_cb.buffer_size_left == m_cb.active_channels) &amp;amp;&amp;amp;

                 (m_cb.p_secondary_buffer != NULL))
        {
            // Samples to convert for one event, prepare next buffer.
            m_cb.conversions_end  = true;
            m_cb.buffer_size_left = 0;
            nrf_saadc_buffer_init((nrf_saadc_value_t *)m_cb.p_secondary_buffer,
                                  m_cb.active_channels);
        }
        else if (m_cb.buffer_size_left == m_cb.active_channels)
        {
            // Samples to convert for one event, but no second buffer.
            m_cb.conversions_end  = true;
            m_cb.buffer_size_left = 0;
        }
        nrf_saadc_event_clear(NRF_SAADC_EVENT_END);
        nrf_saadc_task_trigger(NRF_SAADC_TASK_SAMPLE);
    }
    else if (nrf_saadc_event_check(NRF_SAADC_EVENT_CALIBRATEDONE))
    {
        nrf_saadc_event_clear(NRF_SAADC_EVENT_CALIBRATEDONE);
        NRF_LOG_DEBUG(&amp;quot;Event: %s.\r\n&amp;quot;, (uint32_t)EVT_TO_STR(NRF_SAADC_EVENT_CALIBRATEDONE));
        m_cb.adc_state = NRF_SAADC_STATE_IDLE;

        nrf_drv_saadc_evt_t evt;
        evt.type = NRF_DRV_SAADC_EVT_CALIBRATEDONE;
        m_cb.event_handler(&amp;amp;evt);
    }
    else if (nrf_saadc_event_check(NRF_SAADC_EVENT_STOPPED))
    {
        nrf_saadc_event_clear(NRF_SAADC_EVENT_STOPPED);
        NRF_LOG_DEBUG(&amp;quot;SAADC IRQ -- Event: %s.\r\n&amp;quot;, (uint32_t)EVT_TO_STR(NRF_SAADC_EVENT_STOPPED));
        m_cb.adc_state = NRF_SAADC_STATE_IDLE;
    }
    else
    {
        uint32_t          limit_flags = m_cb.limits_enabled_flags;
        uint32_t          flag_idx;
        nrf_saadc_event_t event;

        while (limit_flags)
        {
            flag_idx     = __CLZ(limit_flags);
            limit_flags &amp;amp;= ~((1UL &amp;lt;&amp;lt; 31) &amp;gt;&amp;gt; flag_idx);
            event        = FLAG_IDX_TO_EVENT(flag_idx);
            if (nrf_saadc_event_check(event))
            {
                nrf_saadc_event_clear(event);
                nrf_drv_saadc_evt_t evt;
                evt.type                  = NRF_DRV_SAADC_EVT_LIMIT;
                evt.data.limit.channel    = LIMIT_EVENT_TO_CHANNEL(event);
                evt.data.limit.limit_type = LIMIT_EVENT_TO_LIMIT_TYPE(event);
                NRF_LOG_DEBUG(&amp;quot;Event limit, channel: %d, limit type: %s.\r\n&amp;quot;, evt.data.limit.channel, (uint32_t)EVT_TO_STR(evt.data.limit.limit_type));
                m_cb.event_handler(&amp;amp;evt);
            }
        }
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: The Saadc of issue of uninit</title><link>https://devzone.nordicsemi.com/thread/127094?ContentTypeID=1</link><pubDate>Thu, 05 Apr 2018 14:43:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1bc85b02-3f30-4203-a222-5f9ec89b13fb</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;What do you mean by this: &amp;quot;the code cant check the stop interrput ,as init some bugs in next init code&amp;quot;? Are you actually checking the error codes from your calls to nrf_drv_saadc_*, or are they only assigned? You say you get error 0x08 when calling&amp;nbsp;nrf_drv_saadc_sample, this indicate that the driver is in IDLE state, normally because no buffer have been setup. You should have received an error code when you called one of the nrf_drv_saadc_* functions.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: The Saadc of issue of uninit</title><link>https://devzone.nordicsemi.com/thread/126509?ContentTypeID=1</link><pubDate>Mon, 02 Apr 2018 06:31:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd91a108-f0ad-4300-a219-a2bd9fbb8bc8</guid><dc:creator>lenli</dc:creator><description>&lt;p&gt;&lt;span&gt;nrf_drv_saadc_uninit() function code has some bugs as below:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;nrf_saadc_task_trigger(NRF_SAADC_TASK_STOP);&lt;/p&gt;
&lt;p&gt;Wait for ADC being stopped.&lt;br /&gt;uint32_t timeout = HW_TIMEOUT;&lt;br /&gt;while (nrf_saadc_event_check(NRF_SAADC_EVENT_STOPPED) == 0 &amp;amp;&amp;amp; timeout &amp;gt; 0)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp; --timeout;&lt;br /&gt;&amp;nbsp;}&lt;/p&gt;
&lt;p&gt;&lt;span&gt;while (nrf_saadc_event_check(NRF_SAADC_EVENT_STOPPED) == 0 &amp;amp;&amp;amp; timeout &amp;gt; 0)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp; --timeout;&lt;/span&gt;&lt;br /&gt;&lt;span&gt;&amp;nbsp;}&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;the code cant check the stop interrput ,as init some bugs in next init code.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: The Saadc of issue of uninit</title><link>https://devzone.nordicsemi.com/thread/126504?ContentTypeID=1</link><pubDate>Mon, 02 Apr 2018 04:23:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59a335d7-a142-4518-9cc2-20032bc83583</guid><dc:creator>lenli</dc:creator><description>&lt;p&gt;i try it today, but there r no effect.&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;the error is same with that before.&lt;/p&gt;
&lt;p&gt;how can u do ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: The Saadc of issue of uninit</title><link>https://devzone.nordicsemi.com/thread/126446?ContentTypeID=1</link><pubDate>Fri, 30 Mar 2018 11:30:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a289e595-ad5a-4ee5-bba9-6ae353319e68</guid><dc:creator>Chocol8</dc:creator><description>&lt;p&gt;Have you tried it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: The Saadc of issue of uninit</title><link>https://devzone.nordicsemi.com/thread/126441?ContentTypeID=1</link><pubDate>Fri, 30 Mar 2018 08:59:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10e5f81a-bb3d-418b-87ac-2781e107aa1e</guid><dc:creator>Chocol8</dc:creator><description>&lt;p&gt;try uninit saadc like this:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;nrf_drv_saadc_uninit();&lt;br /&gt; NRF_SAADC-&amp;gt;INTENCLR = (SAADC_INTENCLR_END_Clear &amp;lt;&amp;lt; SAADC_INTENCLR_END_Pos);&lt;br /&gt; NVIC_ClearPendingIRQ(SAADC_IRQn);&lt;/p&gt;
&lt;p&gt;Do you see that power consumption actualy goes down when you unitiliaze? I guess it might be that you do not unitiliaze it properly. This would explain why code works good until initialized for the second time.&lt;/p&gt;
&lt;p&gt;Does blocking function does not fit your plan?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: The Saadc of issue of uninit</title><link>https://devzone.nordicsemi.com/thread/126440?ContentTypeID=1</link><pubDate>Fri, 30 Mar 2018 08:42:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3ab04553-69e7-44ba-b358-5e89e1026154</guid><dc:creator>lenli</dc:creator><description>&lt;p&gt;i&amp;nbsp;use&amp;nbsp;the&amp;nbsp;&lt;span&gt;softdevice, sdk&amp;nbsp;is&amp;nbsp;nRF5_SDK_12.3.0_d7731ad.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;my error is that i said in above.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;when i use saadc,anything is ok. But i wanna uninit the saadc to power down the consumption.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;But when i init saadc in twice more,saadc cant work well.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;nrf_drv_saadc_sample error is 0x08, That means saadc is not busy.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;i bubeg the code , and i find the code enter&amp;nbsp;if (nrf_saadc_event_check(NRF_SAADC_EVENT_STOPPED)) in&amp;nbsp;SAADC_IRQHandler.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;why when i init saadc in twice more,the code enter&amp;nbsp;nrf_saadc_event_check(NRF_SAADC_EVENT_STOPPED)???&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: The Saadc of issue of uninit</title><link>https://devzone.nordicsemi.com/thread/126435?ContentTypeID=1</link><pubDate>Fri, 30 Mar 2018 07:38:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:59ef7f05-377f-4308-902d-c4121facf4d1</guid><dc:creator>Chocol8</dc:creator><description>&lt;p&gt;Hello, can you explain what are you trying to achieve? What is your setup MCU, sdk, softdevice? what does the error says? Recently I had problems while using SAADC. I would recommend you to take a look at proximity example. Moreover, do you do temperature calibration?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>