<?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>Disabling saadc problem</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/30012/disabling-saadc-problem</link><description>I am using nrf52832, SDK14 and sd 132.5.0. I want to disable SAADC after measuring battery level then enable again when I want to measure it again like in this post . When I try to do that it resets device every time in this handler. 
 static void battery_level_meas_timeout_handler</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 30 Jan 2018 09:37:39 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/30012/disabling-saadc-problem" /><item><title>RE: Disabling saadc problem</title><link>https://devzone.nordicsemi.com/thread/119274?ContentTypeID=1</link><pubDate>Tue, 30 Jan 2018 09:37:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bbcbf1f4-6072-4681-8cc6-65bce9c34346</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;0x08 means &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v5.0.0/group__nrf__error.html?cp=2_3_1_1_0_2_0_7_11#gaf0aff2ba7864b34a36b4a96986e1851e"&gt;&lt;code&gt;NRF_ERROR_INVALID_STATE&lt;/code&gt;&lt;/a&gt;. If you get this from the init function, the SAADC driver is already initialized. You should use a flag that you set when init is called and clared after uninit, to keep track of the state. Another thing is that you can&amp;#39;t call uninit right after calling the sample function, as this will uninit the driver before sampling is completed. You need to move the uninit function to the SAADC callback.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Disabling saadc problem</title><link>https://devzone.nordicsemi.com/thread/119277?ContentTypeID=1</link><pubDate>Tue, 30 Jan 2018 09:20:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d87d0286-7d60-4b4c-b228-6dd0a8cd2157</guid><dc:creator>asombredance</dc:creator><description>&lt;p&gt;I used debugging method, the error code is 0x00000008 for err_code = nrf_drv_saadc_init(NULL, saadc_event_handler).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Disabling saadc problem</title><link>https://devzone.nordicsemi.com/thread/119276?ContentTypeID=1</link><pubDate>Tue, 30 Jan 2018 08:28:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6a2467ac-4412-45ea-91eb-320997c4045c</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;You need to check the error codes. Use the method I linked above, and make sure you check the error code from all function calls:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;ret_code_t err_code;
err_code = nrf_drv_saadc_init(NULL, saadc_event_handler);
APP_ERROR_CHECK(err_code);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Disabling saadc problem</title><link>https://devzone.nordicsemi.com/thread/119275?ContentTypeID=1</link><pubDate>Tue, 30 Jan 2018 08:26:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7348a584-bce5-46d8-8d21-434e24f3a45c</guid><dc:creator>asombredance</dc:creator><description>&lt;p&gt;At the beginning I called  nrf_drv_saadc_init(NULL, saadc_event_handler) when I was doing configuration in the main. In &lt;a href="https://devzone.nordicsemi.com/question/142396/saadc-doesnt-wake-up/"&gt;this question&lt;/a&gt; you said &amp;quot;Most likely you get an error code because you are trying to initialize a module that is allready initialized &amp;quot;, so I tried to make it pass initializing part for the first time handler runs.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Disabling saadc problem</title><link>https://devzone.nordicsemi.com/thread/119273?ContentTypeID=1</link><pubDate>Tue, 30 Jan 2018 08:16:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c42aab9-1a19-458d-87ea-95fa706c678d</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not sure I understand your code. If you uninit the SAADC driver after sampling, you need to init it again before next sample. What is your i=0;, if(i!=0) and i=1; code suppose to do?&lt;/p&gt;
&lt;p&gt;Most likely you are trying to call &lt;code&gt;nrf_drv_saadc_sample&lt;/code&gt; when the SAADC driver is not initialized, which will return an error code. When you pass a non-zero error code to &lt;code&gt;APP_ERROR_CHECK&lt;/code&gt;, the default recovery method is to reset the chip. Please use &lt;a href="https://devzone.nordicsemi.com/question/60125/my-device-is-freezing-and-restarting/"&gt;this debugging method&lt;/a&gt; to check the returned error codes in your application.&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>