<?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>ADC of zephyr</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/82619/adc-of-zephyr</link><description>Hi, 
 I am working on the nrf5340 with zephyr (NCS 1.7.1), I need to monitor the voltage of the battery, in the beginning, I used the ADC API of zephyr, and it works well, but the zephyr API doesn&amp;#39;t seem to provide API to close the ADC, so I have to switch</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 30 Mar 2022 08:56:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/82619/adc-of-zephyr" /><item><title>RE: ADC of zephyr</title><link>https://devzone.nordicsemi.com/thread/360696?ContentTypeID=1</link><pubDate>Wed, 30 Mar 2022 08:56:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0a077a4d-7971-4abe-8124-41ac925a9082</guid><dc:creator>Jason</dc:creator><description>&lt;p&gt;No any other details, just add &amp;quot;&lt;span&gt;IRQ_CONNECT&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;NRFX_IRQ_NUMBER_GET&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;NRF_SAADC&lt;/span&gt;&lt;span&gt;),&amp;nbsp;&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;,&amp;nbsp;&lt;/span&gt;&lt;span&gt;nrfx_isr&lt;/span&gt;&lt;span&gt;,&amp;nbsp;&lt;/span&gt;&lt;span&gt;nrfx_saadc_irq_handler&lt;/span&gt;&lt;span&gt;,&amp;nbsp;&lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;);&amp;quot;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;before&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&amp;quot;nrfx_saadc_init&amp;quot;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC of zephyr</title><link>https://devzone.nordicsemi.com/thread/359476?ContentTypeID=1</link><pubDate>Wed, 23 Mar 2022 02:38:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a1b70401-8ad0-47cb-bc2c-cc54beb0544b</guid><dc:creator>sredaley</dc:creator><description>&lt;p&gt;Can you detail your fix here? I think I&amp;#39;m running into the same issue. I cannot get the IRQ based mode to run. When including the IRQ_Connect line I get an error and cannot build.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC of zephyr</title><link>https://devzone.nordicsemi.com/thread/346011?ContentTypeID=1</link><pubDate>Wed, 05 Jan 2022 02:18:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c5ea66f6-0b40-4e60-b3e6-e1034b712b68</guid><dc:creator>Jason</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Priyanka,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I have found the answer， it needs to&amp;nbsp;&lt;/span&gt;use Zephyr&amp;#39;s method to set up ISR first.&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;IRQ_CONNECT&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;NRFX_IRQ_NUMBER_GET&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;NRF_SAADC&lt;/span&gt;&lt;span&gt;), &lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;nrfx_isr&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;nrfx_saadc_irq_handler&lt;/span&gt;&lt;span&gt;, &lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC of zephyr</title><link>https://devzone.nordicsemi.com/thread/344408?ContentTypeID=1</link><pubDate>Mon, 20 Dec 2021 14:59:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d201c230-9509-4707-92e4-1b459a3cc274</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Hi Jason,&lt;/p&gt;
&lt;p&gt;I am looking into your case and will get back to you soon. We are understaffed at the moment due to the holiday season and hence kindly expect some delays in the replies.&lt;/p&gt;
&lt;p&gt;Thank you for understanding,&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC of zephyr</title><link>https://devzone.nordicsemi.com/thread/344033?ContentTypeID=1</link><pubDate>Fri, 17 Dec 2021 02:03:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:94ca8c2b-e876-4577-8786-24f2f47374a9</guid><dc:creator>Jason</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;Priyanka,&lt;/p&gt;
&lt;p&gt;I just create an application from zephyr/samples/hello_world, and copy the ADC sample code to the main.c,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;if the event handler is NULL, it works.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;nrfx_saadc_simple_mode_set&lt;/span&gt;&lt;span&gt;((&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt; &amp;lt;&amp;lt; &lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;),&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;NRF_SAADC_RESOLUTION_12BIT&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;NRF_SAADC_OVERSAMPLE_DISABLED&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;NULL&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;if&amp;nbsp;set the&amp;nbsp;event handler, it does not work.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;nrfx_saadc_simple_mode_set&lt;/span&gt;&lt;span&gt;((&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;&amp;nbsp;&amp;lt;&amp;lt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;),&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;NRF_SAADC_RESOLUTION_12BIT&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;NRF_SAADC_OVERSAMPLE_DISABLED&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;event_handler&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;I attached the main.c and prj.conf as below.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/*
 * Copyright (c) 2012-2014 Wind River Systems, Inc.
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;sys/printk.h&amp;gt;
#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;lt;nrfx_saadc.h&amp;gt;

static volatile bool is_ready;
static nrf_saadc_value_t sample;

nrfx_saadc_channel_t channel = NRFX_SAADC_DEFAULT_CHANNEL_SE(NRF_SAADC_INPUT_VDD, 0);
#define BATTERY_VOLTAGE(sample) (sample * 6 * 600UL / (1 &amp;lt;&amp;lt; 12))
static void handle_error(nrfx_err_t error_code)
{
	if (error_code != NRFX_SUCCESS)
	{
		// error
		while (1)
		{
		};
	}
}

static void event_handler(nrfx_saadc_evt_t const *p_event)
{
	if (p_event-&amp;gt;type == NRFX_SAADC_EVT_DONE)
	{
		// Buffer with data is available here: p_event-&amp;gt;data.done.p_buffer
		is_ready = true;
	}
}

int main(void)
{
	nrfx_err_t err_code;

	err_code = nrfx_saadc_init(NRFX_SAADC_DEFAULT_CONFIG_IRQ_PRIORITY);
	handle_error(err_code);

	err_code = nrfx_saadc_channels_config(&amp;amp;channel, 1);
	handle_error(err_code);

	err_code = nrfx_saadc_simple_mode_set((1 &amp;lt;&amp;lt; 0),
										  NRF_SAADC_RESOLUTION_12BIT,
										  NRF_SAADC_OVERSAMPLE_DISABLED,
										  NULL);
	handle_error(err_code);

	err_code = nrfx_saadc_buffer_set(&amp;amp;sample, 1);
	handle_error(err_code);
	printk(&amp;quot;Hello World! %s\n&amp;quot;, CONFIG_BOARD);
	while (1)
	{
		err_code = nrfx_saadc_mode_trigger();
		handle_error(err_code);
		printk(&amp;quot;sample %u&amp;quot;, BATTERY_VOLTAGE(sample));
		k_msleep(1000);
	}
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;the pri.conf, only enable&amp;nbsp;CONFIG_NRFX_SAADC&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_NRFX_SAADC=y&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC of zephyr</title><link>https://devzone.nordicsemi.com/thread/343955?ContentTypeID=1</link><pubDate>Thu, 16 Dec 2021 14:10:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fb288334-fdde-44ee-b040-b51c6731a0bb</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Hi Jason,&lt;/p&gt;
&lt;p&gt;What have you included in the folder where the example is stored, i.e., the folder with the &lt;em&gt;prj.conf, src&lt;/em&gt; and any other files that you have created. It would be helpful if you could share your folder.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: ADC of zephyr</title><link>https://devzone.nordicsemi.com/thread/343238?ContentTypeID=1</link><pubDate>Mon, 13 Dec 2021 14:53:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4d027cf7-3a41-437e-82dd-952fd1716a3b</guid><dc:creator>Priyanka</dc:creator><description>&lt;p&gt;Hi Jason,&lt;/p&gt;
&lt;p&gt;Sorry for the delayed response. I am looking into this and will get back to you soon.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Priyanka&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>