<?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>Can&amp;#39;t stop SAADC</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/32982/can-t-stop-saadc</link><description>Hi, 
 When I try to stop ADC sampling, the adc driver keeps on busy. The function nrf_drv_saadc_is_busy() keeps returning true. 
 I looked in other posts (like this one ) and found that this is the way to start and stop ADC: 
 
 
 But this is not working</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 12 Apr 2018 08:41:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/32982/can-t-stop-saadc" /><item><title>RE: Can't stop SAADC</title><link>https://devzone.nordicsemi.com/thread/127979?ContentTypeID=1</link><pubDate>Thu, 12 Apr 2018 08:41:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de60b8bc-9076-4fe8-93f9-940ecf7a800c</guid><dc:creator>Alaa</dc:creator><description>&lt;p&gt;Thank you. This worked in addition to adding&amp;nbsp;&lt;strong&gt;timer_uninit&lt;/strong&gt; and&amp;nbsp;&lt;strong&gt;ppi_uninit&lt;/strong&gt;. Like so:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void start_adc()
{
    saadc_sampling_event_init();
    saadc_init();
    saadc_sampling_event_enable();
}

void stop_adc()
{
    nrf_drv_timer_disable(&amp;amp;m_timer);
    nrf_drv_timer_uninit(&amp;amp;m_timer);
    nrf_drv_ppi_channel_disable(m_ppi_channel);
    nrf_drv_ppi_uninit();
    nrf_drv_saadc_abort();
    nrf_drv_saadc_uninit();
    while(nrf_drv_saadc_is_busy());
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't stop SAADC</title><link>https://devzone.nordicsemi.com/thread/127645?ContentTypeID=1</link><pubDate>Tue, 10 Apr 2018 13:53:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2070f75-dce7-4c82-b030-ca140cb25910</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;This should be sufficient:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Stop anything triggering the sample task (timer, PPI, etc.).&lt;/li&gt;
&lt;li&gt;Call nrf_drv_saadc_abort().&lt;/li&gt;
&lt;li&gt;Call&amp;nbsp;nrf_drv_saadc_uninit().&lt;/li&gt;
&lt;li&gt;Call you SAADC+channels init function.&lt;/li&gt;
&lt;li&gt;Start whatever triggers sample task.&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't stop SAADC</title><link>https://devzone.nordicsemi.com/thread/127626?ContentTypeID=1</link><pubDate>Tue, 10 Apr 2018 13:06:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:94b052cf-03b1-4c0a-a2a5-b6c857a3016c</guid><dc:creator>Alaa</dc:creator><description>&lt;p&gt;Sorry I&amp;#39;m confused. Can you please tell me what&amp;#39;s the proper way and the right order of operations to stop and restart ADC?&lt;/p&gt;
&lt;p&gt;Thank you very much&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't stop SAADC</title><link>https://devzone.nordicsemi.com/thread/127444?ContentTypeID=1</link><pubDate>Mon, 09 Apr 2018 13:28:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2783feb-40ba-4094-a740-d6c21bc4d294</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;nrf_drv_saadc_abort should stop the SAADC and any ongoing conversions, but if you are setting up new buffers and triggering sampling, you will still get callbacks. You should check the error codes from&amp;nbsp;nrf_drv_timer_disable and nrf_drv_ppi_channel_disablein stop_adc, to make sure the sampling is actually stopped, before aborting and uninitializing the SAADC.&lt;/p&gt;
&lt;p&gt;Error 133 (0x0085) means&amp;nbsp;NRF_ERROR_MODULE_ALREADY_INITIALIZED. If do not uninit the PPI driver,&amp;nbsp;it would be expected that you get this&amp;nbsp;error when calling&amp;nbsp;nrf_drv_ppi_init&lt;strong&gt;.&lt;/strong&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't stop SAADC</title><link>https://devzone.nordicsemi.com/thread/127304?ContentTypeID=1</link><pubDate>Sun, 08 Apr 2018 06:43:12 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:978289bb-9a63-45d6-b4ae-7f4743ecb37f</guid><dc:creator>Alaa</dc:creator><description>&lt;p&gt;Hi Jorgen,&lt;/p&gt;
&lt;p&gt;Thanks for the reply.&lt;/p&gt;
&lt;p&gt;I prefer to keep the double buffer so I tried the&amp;nbsp;&lt;strong&gt;abort&lt;/strong&gt; method. Calling &lt;strong&gt;nrf_drv_saadc_abort()&lt;/strong&gt;&amp;nbsp;alone doesn&amp;#39;t stop the adc callback. It keeps triggering with constant value 1024. And then if I call my function &lt;strong&gt;start_system()&lt;/strong&gt;&amp;nbsp;again, I get a hard fault from&amp;nbsp;&lt;strong&gt;nrf_drv_ppi_init()&lt;/strong&gt;&amp;nbsp;(133 error).&lt;/p&gt;
&lt;p&gt;I also tried calling&amp;nbsp;&lt;strong&gt;nrf_drv_saadc_uninit&lt;/strong&gt;&lt;strong&gt;()&lt;/strong&gt; after aborting - this did stop the callback, but I got the same hard fault (133)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can't stop SAADC</title><link>https://devzone.nordicsemi.com/thread/126894?ContentTypeID=1</link><pubDate>Wed, 04 Apr 2018 14:43:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de976135-758c-4300-9aaf-27b6b807c229</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The SAADC driver will always be in the busy state when a buffer is setup for conversion (by calling&amp;nbsp;nrf_drv_saadc_buffer_convert). It will not help to only disable double buffering, you also need to remove the second buffer.&lt;/p&gt;
&lt;p&gt;You have two alternatives:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Call&amp;nbsp;&lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.2.0/group__nrf__drv__saadc.html#ga427b72199784d4c386b896d61079f7c8"&gt;nrf_drv_saadc_abort&lt;/a&gt;&amp;nbsp;to remove the buffers and stop any ongoing sampling. This will trigger the STOP task and put the driver in IDLE state when STOPPED event is received.&lt;/li&gt;
&lt;li&gt;Disable double buffering, as you describe above, and only call&amp;nbsp;stop_adc in your SAADC event handler when you receive a DONE event, but before you call&amp;nbsp;nrf_drv_saadc_buffer_convert to setup the buffer for conversion again.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>