<?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>nrfx_saadc_uninit() do not work when use SAADC&amp;#39;s differential mode with SDK17.0.2, nrf52832, using NRFX_SAADC_API_V2</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/78856/nrfx_saadc_uninit-do-not-work-when-use-saadc-s-differential-mode-with-sdk17-0-2-nrf52832-using-nrfx_saadc_api_v2</link><description>Hi, dear Nordic &amp;amp; all： 
 
 I found nrfx_saadc_uninit() did not work when use SAADC&amp;#39;s differential mode with SDK17.0.2, nrf52832, the fellowing is saadc init and configuration code: 
 
 and my main function is: 
 
 I called just one time before for(;;</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 24 Aug 2021 06:35:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/78856/nrfx_saadc_uninit-do-not-work-when-use-saadc-s-differential-mode-with-sdk17-0-2-nrf52832-using-nrfx_saadc_api_v2" /><item><title>RE: nrfx_saadc_uninit() do not work when use SAADC's differential mode with SDK17.0.2, nrf52832, using NRFX_SAADC_API_V2</title><link>https://devzone.nordicsemi.com/thread/326271?ContentTypeID=1</link><pubDate>Tue, 24 Aug 2021 06:35:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e5649160-291a-46ea-84dc-048ed6cf3a34</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I am not sure how well it works to uninitialize the driver in the callback function, and if you do it in the for loop you will try to&amp;nbsp;uninitialize the driver before the first operation is even complete.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you try to set a flag in the callback function that signals&amp;nbsp;that the ADC operation is complete, and check this flag in the for loop before you uninitialize the ADC?&lt;/p&gt;
&lt;p&gt;Something like this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// Declare flag
static volatile bool adc_operation_completed = false;

// At the end of the adc callback
adc_operation_completed = true;

// Inside the for loop
if(adc_operation_completed)
{
    adc_operation_completed = false;
    stop_sample();
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Alternatively you can schedule the call to stop_sample() from the adc callback by using the app_scheduler, so that the uninit function will not be run from interrupt context.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>