<?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>How to check SAADC is enabled?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/26121/how-to-check-saadc-is-enabled</link><description>Hello, 
 I would like to know how I can check whether the SAADC is enabled or nor on my application. I am disabling the SAADC with nrf_drv_saadc_uninit(); after configuring it, however when my interruption is triggered to sample it seems that the saadc</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 27 Oct 2017 07:52:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/26121/how-to-check-saadc-is-enabled" /><item><title>RE: How to check SAADC is enabled?</title><link>https://devzone.nordicsemi.com/thread/102936?ContentTypeID=1</link><pubDate>Fri, 27 Oct 2017 07:52:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a5bc7d37-ba01-48be-82c5-1c3509b0e294</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Yes, if you do not have a very high sample rate, you can save power by disabling the SAADC peripheral between samples. The end of the SAADC handler would then be the logical place to uninit the SAADC.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check SAADC is enabled?</title><link>https://devzone.nordicsemi.com/thread/102935?ContentTypeID=1</link><pubDate>Thu, 26 Oct 2017 12:53:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ffe3bc30-698c-4c6a-a883-acc62b91ad05</guid><dc:creator>ndarkness</dc:creator><description>&lt;p&gt;Ok, then I am using the right function since I am using the softdevice. Regarding to disabling the SAADC on the SAADC handler is that a good approach?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check SAADC is enabled?</title><link>https://devzone.nordicsemi.com/thread/102934?ContentTypeID=1</link><pubDate>Thu, 26 Oct 2017 12:50:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:142e4be6-b40c-429e-9742-4b54f38b5b60</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;If you are using the softdevice, you need to use the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v5.0.0/group___n_r_f___s_o_c___f_u_n_c_t_i_o_n_s.html?cp=2_3_1_1_0_2_7_2_0#ga11d88d38ac99fb72cde74c9385d36433"&gt;softdevice API&lt;/a&gt; to enter sleep mode. WFE/SEV can only be used when the softdevice is disabled.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check SAADC is enabled?</title><link>https://devzone.nordicsemi.com/thread/102933?ContentTypeID=1</link><pubDate>Thu, 26 Oct 2017 12:49:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:220d55b5-d06f-4f91-9df7-19f8e05ea968</guid><dc:creator>ndarkness</dc:creator><description>&lt;p&gt;Another question, I am uninitialize my saadc at the end of the saadc handler function, is that correct?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check SAADC is enabled?</title><link>https://devzone.nordicsemi.com/thread/102932?ContentTypeID=1</link><pubDate>Thu, 26 Oct 2017 12:46:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2106e7d2-d963-42e3-9721-636930c26066</guid><dc:creator>ndarkness</dc:creator><description>&lt;p&gt;@Jorgen thanks again, I have implemented so. I was wondering, in the power_manager function, I see that you set everything to go to sleep. I have taken that function from the &lt;code&gt;heart rate&lt;/code&gt; example and  there the calls to WFE,SEV  are not present, should I set them too?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check SAADC is enabled?</title><link>https://devzone.nordicsemi.com/thread/102930?ContentTypeID=1</link><pubDate>Thu, 26 Oct 2017 12:01:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7061312e-fb53-4691-85f7-51ff4054db29</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;That depends on if you have uninited the SAADC. I suggest you use a flag to know when you have inited/uninited the SAADC, like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static uint8_t saadc_is_initialized = false;

uint32_t initialize_saadc()
{
	uint32_t err_code;
	err_code = nrf_drv_saadc_init();
	if(err_code != NRF_SUCCESS)
	{
		return err_code;
	}
	err_code = nrf_drv_saadc_buffer_convert();
	if(err_code != NRF_SUCCESS)
	{
		return err_code;
	}
	saadc_is_initialized = true;
	return err_code;
}

void uninitialize_saadc()
{
	nrf_drv_saadc_uninit();
	saadc_is_initialized = false;
}

void battery_timer_handler()
{
	uint32_t err_code;
	
	if(!saadc_is_initialized)
	{
		err_code = initialize_saadc();
		APP_ERROR_CHECK(err_code);
	}
	
	err_code = nrf_drv_saadc_sample();
	APP_ERROR_CHECK(err_code);
}

void power_manager()
{
	if(saadc_is_initialized)
	{
		uninitialize_saadc();
	}
	
	// Go to sleep
	__WFE();
	__SEV();
	__WFE();
}
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check SAADC is enabled?</title><link>https://devzone.nordicsemi.com/thread/102938?ContentTypeID=1</link><pubDate>Thu, 26 Oct 2017 11:47:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75e87faf-e08e-40c8-b1d6-564178c981b0</guid><dc:creator>ndarkness</dc:creator><description>&lt;p&gt;so if I have a handler for updating my battery level, should it contain an initalization of the Saadc? If the power_manager has put it to sleep?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check SAADC is enabled?</title><link>https://devzone.nordicsemi.com/thread/102931?ContentTypeID=1</link><pubDate>Thu, 26 Oct 2017 11:22:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87d7b11d-37cf-46d5-b363-ac1e331517a6</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;The driver should handle this for you. You just need to keep track of when you have called &lt;code&gt;nrf_drv_saadc_init&lt;/code&gt; and &lt;code&gt;nrf_drv_saadc_buffer_convert&lt;/code&gt;, and when you have called &lt;code&gt;nrf_drv_saadc_uninit&lt;/code&gt;. When the two first functions have been called, the SAADC is ready to sample. The IRQ handler in the driver will check and clear the event registers, and you might not be able to reliably read these registers from your application.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check SAADC is enabled?</title><link>https://devzone.nordicsemi.com/thread/102929?ContentTypeID=1</link><pubDate>Thu, 26 Oct 2017 10:40:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a28451fa-e3f8-410d-8849-f695584089b0</guid><dc:creator>ndarkness</dc:creator><description>&lt;p&gt;I want to check whether the SAADC is started or not, just that. My device goes to sleep and i need to sample the battery after its timout expires, so before sampling I want to check that the SAADC is up, othwerwise I will start it up.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check SAADC is enabled?</title><link>https://devzone.nordicsemi.com/thread/102940?ContentTypeID=1</link><pubDate>Thu, 26 Oct 2017 10:34:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:745ebff4-6233-4b97-a066-362b3355c83c</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Why are you trying to use &lt;code&gt;nrf_saadc_event_check&lt;/code&gt;?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check SAADC is enabled?</title><link>https://devzone.nordicsemi.com/thread/102939?ContentTypeID=1</link><pubDate>Thu, 26 Oct 2017 10:26:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:885e6192-66ce-48f0-90dc-91c0d60b3b2b</guid><dc:creator>ndarkness</dc:creator><description>&lt;p&gt;@Jorgen, if I do as told, I get an error &lt;code&gt;too few arguments to function &amp;#39;nrf_saadc_event_check&amp;#39;&lt;/code&gt; looking into &lt;code&gt;nrf_saadc.h&lt;/code&gt; it expects an event as the proto states &lt;code&gt;__STATIC_INLINE bool nrf_saadc_event_check(nrf_saadc_event_t saadc_event)&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check SAADC is enabled?</title><link>https://devzone.nordicsemi.com/thread/102928?ContentTypeID=1</link><pubDate>Tue, 24 Oct 2017 12:38:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c6034a8d-b6d7-490c-8ffc-7189fce03062</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;No, &lt;code&gt;nrf_saadc_event_check()&lt;/code&gt; will do that. &lt;code&gt;nrf_saadc_enable_check()&lt;/code&gt; will return the value of the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/saadc.html?cp=2_1_0_36_10_4#register.ENABLE"&gt;ENABLE register&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check SAADC is enabled?</title><link>https://devzone.nordicsemi.com/thread/102937?ContentTypeID=1</link><pubDate>Tue, 24 Oct 2017 10:55:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dee6a87f-0f3b-4751-8f98-a7fb644b2e04</guid><dc:creator>ndarkness</dc:creator><description>&lt;p&gt;But with this function I will pass an saadc event type which will be filled if the saadc is enabled right?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to check SAADC is enabled?</title><link>https://devzone.nordicsemi.com/thread/102927?ContentTypeID=1</link><pubDate>Mon, 23 Oct 2017 09:02:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e97ee7a-fb4d-42de-b36b-a957871b611b</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can check if the SAADC &lt;strong&gt;&lt;em&gt;peripheral&lt;/em&gt;&lt;/strong&gt; is enabled by calling the HAL function &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.1.0/group__nrf__saadc__hal.html?cp=4_0_0_6_9_20_0_24#gaeb83173d981b1a64907a5b072e06e4fa"&gt;&lt;code&gt;nrf_saadc_enable_check()&lt;/code&gt;&lt;/a&gt;, but from your question I&amp;#39;m not sure this is what you want.&lt;/p&gt;
&lt;p&gt;If you call &lt;code&gt;nrf_drv_saadc_uninit()&lt;/code&gt;, the SAADC driver will be uninitialized, and the peripheral will be disabled. If you try to sample after this, without calling &lt;code&gt;nrf_drv_saadc_init()&lt;/code&gt;, you will get an error code.&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>