<?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>NRF52840 Zephyr ADC read issue</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/85912/nrf52840-zephyr-adc-read-issue</link><description>Hello, 
 I am using nrf52840 on usb dongle and i would like to measure voltage on a specific ADC input pin. 
 According to the datasheet, i use P0.02/AIN0. 
 My problem is that adc_read() function returns -22 error. 
 I am posting the code and the overlay</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 06 Sep 2024 08:06:57 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/85912/nrf52840-zephyr-adc-read-issue" /><item><title>RE: NRF52840 Zephyr ADC read issue</title><link>https://devzone.nordicsemi.com/thread/501486?ContentTypeID=1</link><pubDate>Fri, 06 Sep 2024 08:06:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9c63bd8f-1533-4ec0-9846-eed7759633ce</guid><dc:creator>Marte Myrvold</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;This ticket is more than two years old. Please create a new ticket.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Marte&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 Zephyr ADC read issue</title><link>https://devzone.nordicsemi.com/thread/501349?ContentTypeID=1</link><pubDate>Thu, 05 Sep 2024 11:46:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:101be192-6ab6-4cef-9eae-9298e4dd1c83</guid><dc:creator>mohammad alrefaie</dc:creator><description>&lt;p&gt;hello sir&lt;br /&gt;how you built the adc sample for nrf52840 dongle??&lt;br /&gt;can you guide me please??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 Zephyr ADC read issue</title><link>https://devzone.nordicsemi.com/thread/360325?ContentTypeID=1</link><pubDate>Mon, 28 Mar 2022 13:16:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55cd513e-caa2-45f9-b528-7c41b5a3dd0b</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I finally got some time to run some power consumption tests using the ADC driver, and using the adc_sample() function I don&amp;#39;t seem to need to do anything in order to get low power consumption (other than disable logging in the application). When I sample the ADC at a slow rate it has very little impact on overall system power, and the sleep currents seem to be unchanged:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/adc_5F00_low_5F00_power.zip"&gt;devzone.nordicsemi.com/.../adc_5F00_low_5F00_power.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Could you try it out and see if it works for you as well?&lt;/p&gt;
&lt;p&gt;Regarding Zephyr threads it is important not to get them mixed up with the Thread wireless protocol ;)&lt;/p&gt;
&lt;p&gt;The easiest way to create a thread is to use the K_THREAD_DEFINE macro, then you can create and start a thread with a single line of code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// Define the thread function
void my_thread_func(void)
{

}

// Initialize and start the thread
K_THREAD_DEFINE(my_thread, 1024, my_thread_func, NULL, NULL, NULL, 5, 0, 0);&lt;/pre&gt;&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><item><title>RE: NRF52840 Zephyr ADC read issue</title><link>https://devzone.nordicsemi.com/thread/360262?ContentTypeID=1</link><pubDate>Mon, 28 Mar 2022 11:24:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:62e362ad-4b11-4d36-b186-08f1afac1174</guid><dc:creator>thanosPr</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I deleted the &amp;quot;io-channels = &amp;lt;&amp;amp;adc 0&amp;gt;&amp;quot; in overlay file, only status exists in there.&lt;/p&gt;
&lt;p&gt;Let me insert my new modified code about adc.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;zephyr/types.h&amp;gt;
#include &amp;lt;stddef.h&amp;gt;
#include &amp;lt;sys/printk.h&amp;gt;
#include &amp;lt;sys/util.h&amp;gt;

#include &amp;lt;device.h&amp;gt;
#include &amp;lt;devicetree.h&amp;gt;
#include &amp;lt;drivers/adc.h&amp;gt;
#include &amp;lt;drivers/gpio.h&amp;gt;

#define ADC_RESOLUTION		    10
#define ADC_GAIN			    ADC_GAIN_1_2
#define ADC_REFERENCE		    ADC_REF_INTERNAL
#define ADC_ACQUISITION_TIME	ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 40)

#define ADC_CHANNEL_AIN0       0


#define NUM_OF_SAMPLES          128
#define VOLTAGE_DIVIDER_RATIO   0.2474   // R1=10k, R2=3.3K
#define VOLTAGE_DROP_PNP        30

const struct device *adc_dev;


uint32_t adcBuffer[NUM_OF_SAMPLES] = {0};
const float voltageDividerRatio = VOLTAGE_DIVIDER_RATIO;
const float voltageDropPNP = VOLTAGE_DROP_PNP;

static enum adc_action sample_with_interval_callback(struct device *dev, const struct adc_sequence *sequence, uint16_t sampling_index)
{   
    return ADC_ACTION_FINISH;
}

struct adc_sequence_options adcOptions = 
{
    .callback = sample_with_interval_callback,
};

static struct adc_channel_cfg adcConfig = 
{
	.gain             = ADC_GAIN,
	.reference        = ADC_REFERENCE,
	.acquisition_time = ADC_ACQUISITION_TIME,
	.channel_id       = ADC_CHANNEL_AIN0,
#if CONFIG_ADC_CONFIGURABLE_INPUTS
	.input_positive   = 1, 
#endif
};

const struct adc_sequence sequence = 
{
	    .options     = &amp;amp;adcOptions,				// extra samples and callback
		.channels    = BIT(ADC_CHANNEL_AIN0),	// bit mask of channels to read
		.buffer      = adcBuffer,		        // where to put samples read
		.buffer_size = sizeof(adcBuffer),
		.resolution  = ADC_RESOLUTION,		    // desired resolution
};
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bool initializeADC(uint8_t channel)
{
    int adcInitError;
    
    adc_dev = DEVICE_DT_GET(DT_NODELABEL(adc));
    if(adc_dev == NULL)
    {
        return false;
    }   
    
    adc_dev = device_get_binding(DEVICE_DT_NAME(DT_NODELABEL(adc)));
    if(adc_dev == NULL)
    {
        return false;
    }

      return true;
}
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void setADCenable(void)
{
     gpio_pin_set(adc_enable_dev, ADC_IO_PIN, 1);
}
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
void clearADCenable(void)
{
     gpio_pin_set(adc_enable_dev, ADC_IO_PIN, 0);
}
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
uint32_t getADCrawValue(void)
{
    int adcReadErr = 0;

    adcReadErr = adc_read(adc_dev, &amp;amp;sequence);
    if(adcReadErr == 0)
    {
        return adcBuffer[0];
    }
    return 0;
}
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
uint32_t readBatteryVoltage(void)
{
    uint32_t adcRaw = 0;
    uint32_t adcReading = 0;    
    
    for(int i=0; i&amp;lt;NUM_OF_SAMPLES; i++)
    {
        adcRaw = getADCrawValue();
        adcReading += adcRaw;
    }
    adcReading /= NUM_OF_SAMPLES;
    
    int32_t adc_vref = adc_ref_internal(adc_dev);

    adc_raw_to_millivolts(adc_vref, ADC_GAIN, 10, &amp;amp;adcReading); 

    adcReading += VOLTAGE_DROP_PNP;

     return adcReading * 4;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;About creating a thread, you could use the below commands:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div style="background-color:#1e1e1e;color:#d4d4d4;font-family:Consolas, &amp;#39;Courier New&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;
&lt;div style="background-color:#1e1e1e;color:#d4d4d4;font-family:Consolas, &amp;#39;Courier New&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;&lt;span style="color:#c586c0;"&gt;#define&lt;/span&gt;&lt;span style="color:#569cd6;"&gt; TEST&lt;/span&gt;&lt;span style="color:#569cd6;"&gt;_MGR_STACK&lt;/span&gt;&lt;span style="color:#569cd6;"&gt; &lt;/span&gt;&lt;span style="color:#b5cea8;"&gt;2048&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#b5cea8;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#569cd6;"&gt;struct&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt; &lt;/span&gt;&lt;span style="color:#4ec9b0;"&gt;k_thread&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt; test&lt;/span&gt;&lt;span style="color:#9cdcfe;"&gt;_mgr&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#d4d4d4;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="background-color:#1e1e1e;color:#d4d4d4;font-family:Consolas, &amp;#39;Courier New&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;&lt;span style="color:#569cd6;"&gt;extern&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt; &lt;/span&gt;&lt;span style="color:#569cd6;"&gt;void&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt; test&lt;/span&gt;&lt;span style="color:#dcdcaa;"&gt;_task&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;(&lt;/span&gt;&lt;span style="color:#569cd6;"&gt;void&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt; *, &lt;/span&gt;&lt;span style="color:#569cd6;"&gt;void&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt; *, &lt;/span&gt;&lt;span style="color:#569cd6;"&gt;void&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt; *);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#d4d4d4;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div style="background-color:#1e1e1e;color:#d4d4d4;font-family:Consolas, &amp;#39;Courier New&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;&lt;span style="color:#569cd6;"&gt;K_THREAD_STACK_DEFINE&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;(test&lt;/span&gt;&lt;span style="color:#9cdcfe;"&gt;_mgr_area&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;, TEST&lt;/span&gt;&lt;span style="color:#569cd6;"&gt;_MGR_STACK&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#d4d4d4;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style="background-color:#1e1e1e;color:#d4d4d4;font-family:Consolas, &amp;#39;Courier New&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;&lt;span style="color:#569cd6;"&gt;void&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt; &lt;/span&gt;&lt;span style="color:#dcdcaa;"&gt;main&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;(&lt;/span&gt;&lt;span style="color:#569cd6;"&gt;void&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#d4d4d4;"&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style="background-color:#1e1e1e;color:#d4d4d4;font-family:Consolas, &amp;#39;Courier New&amp;#39;, monospace;font-size:14px;font-weight:normal;line-height:19px;white-space:pre;"&gt;
&lt;div&gt;&lt;span style="color:#d4d4d4;"&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="color:#dcdcaa;"&gt;k_thread_create&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;(&amp;amp;&lt;/span&gt;&lt;span style="color:#9cdcfe;"&gt;test_mgr&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;, &lt;/span&gt;&lt;span style="color:#9cdcfe;"&gt;test_mgr_area&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;, &lt;/span&gt;&lt;span style="color:#569cd6;"&gt;K_THREAD_STACK_SIZEOF&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;(&lt;/span&gt;&lt;span style="color:#9cdcfe;"&gt;test_mgr_area&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;), &lt;/span&gt;&lt;span style="color:#dcdcaa;"&gt;test_task&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;, &lt;/span&gt;&lt;span style="color:#569cd6;"&gt;NULL&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;, &lt;/span&gt;&lt;span style="color:#569cd6;"&gt;NULL&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;, &lt;/span&gt;&lt;span style="color:#569cd6;"&gt;NULL&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;, &lt;/span&gt;&lt;span style="color:#569cd6;"&gt;MY_PRIORITY&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;, &lt;/span&gt;&lt;span style="color:#b5cea8;"&gt;0&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;, &lt;/span&gt;&lt;span style="color:#569cd6;"&gt;K_NO_WAIT&lt;/span&gt;&lt;span style="color:#d4d4d4;"&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#d4d4d4;"&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;span style="color:#d4d4d4;"&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 Zephyr ADC read issue</title><link>https://devzone.nordicsemi.com/thread/360131?ContentTypeID=1</link><pubDate>Mon, 28 Mar 2022 03:45:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:87272123-157a-4d2e-b554-0c01fa65e896</guid><dc:creator>yoyou</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;NCS1.9.1, nRF52840DK,Windows10 X64, VSCode,&lt;/p&gt;
&lt;p&gt;i&amp;#39;ve follow you,and&amp;nbsp;&lt;span&gt;adc_read() function returns -22 error.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;How did you solve this problem? add thread?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1648437128268v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;zephyr.h&amp;gt;
#include &amp;lt;device.h&amp;gt;
#include &amp;lt;drivers/gpio.h&amp;gt;
#include &amp;lt;sys/util.h&amp;gt;
#include &amp;lt;sys/printk.h&amp;gt;
#include &amp;lt;inttypes.h&amp;gt;
#include &amp;lt;drivers/adc.h&amp;gt;


#define ADC_RESOLUTION		    12
#define ADC_GAIN			    ADC_GAIN_1
#define ADC_REFERENCE		    ADC_REF_INTERNAL
#define ADC_ACQUISITION_TIME	ADC_ACQ_TIME(ADC_ACQ_TIME_MICROSECONDS, 40)
#define ADC_CHANNEL_AIN0       0

#define ADC_IO_LABEL            DT_GPIO_LABEL(DT_ALIAS(gpiocus1), gpios)
#define ADC_IO_PIN	            DT_GPIO_PIN(DT_ALIAS(gpiocus1), gpios)

const struct device *adc_dev;
const struct device *adc_en_dev;


uint32_t sample_buffer[10] = {0};


static struct adc_channel_cfg adcConfig = 
{
	.gain             = ADC_GAIN,
	.reference        = ADC_REFERENCE,
	.acquisition_time = ADC_ACQUISITION_TIME,
	.channel_id       = 1, // gets set during init
	.differential	  = 0,
// #if CONFIG_ADC_CONFIGURABLE_INPUTS
	// .input_positive   = 0, // gets set during init
// #endif
};

const struct adc_sequence sequence = 
{
	    .options     = NULL,				// extra samples and callback
		.channels    = BIT(ADC_CHANNEL_AIN0),		// bit mask of channels to read
		.buffer      = sample_buffer,		// where to put samples read
		.buffer_size = sizeof(sample_buffer),
		.resolution  = ADC_RESOLUTION,		// desired resolution
		.oversampling = 0,					// don&amp;#39;t oversample
		.calibrate = 0						// don&amp;#39;t calibrate
};
//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
bool adc_init(uint8_t channel)
{
    int adcInitError;
    
    adc_dev = DEVICE_DT_GET(DT_NODELABEL(adc));
    if(adc_dev == NULL)
    {
 		printk(&amp;quot;adc_init fail 1\n&amp;quot;);
       	return false;
    }

    adc_dev = device_get_binding(DEVICE_DT_NAME(DT_NODELABEL(adc)));
    if(adc_dev == NULL)
    {
		printk(&amp;quot;adc_init fail 2\n&amp;quot;);
        return false;
    }

    adcConfig.channel_id = channel;
    adcInitError = adc_channel_setup(adc_dev, &amp;amp;adcConfig);
    if(adcInitError)
    {
		printk(&amp;quot;adc_init fail 3\n&amp;quot;);
        return false;
    }
	printk(&amp;quot;adc_init done\n&amp;quot;);

    return true;
}

//----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
uint32_t main(void)
{
	adc_init(0);
    int readBatteryVoltageError = 0;

    readBatteryVoltageError = adc_read(adc_dev, &amp;amp;sequence);
    if(readBatteryVoltageError == 0)
    {
 		printk(&amp;quot;readBatteryVoltage: %d \n&amp;quot;,sample_buffer[0]);
		return sample_buffer[0];
    }
	printk(&amp;quot;readBatteryVoltage error: %d \n&amp;quot;,readBatteryVoltageError);

    return 0;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;i cant not&amp;nbsp; find know how to create thread&lt;/p&gt;
&lt;p&gt;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.9.1/zephyr/reference/networking/thread.html?highlight=config%20thread"&gt;Thread protocol &amp;mdash; Zephyr Project Documentation (nordicsemi.com)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best Regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 Zephyr ADC read issue</title><link>https://devzone.nordicsemi.com/thread/358924?ContentTypeID=1</link><pubDate>Fri, 18 Mar 2022 16:50:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:46650678-f3e9-43f3-bc92-431b29583add</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Very good question, I have looked around for a power optimized ADC sample but can&amp;#39;t seem to find any.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I will have to continue my search next week and get back to you &lt;span class="emoticon" data-url="https://devzone.nordicsemi.com/cfs-file/__key/system/emoji/1f642.svg" title="Slight smile"&gt;&amp;#x1f642;&lt;/span&gt;&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><item><title>RE: NRF52840 Zephyr ADC read issue</title><link>https://devzone.nordicsemi.com/thread/358622?ContentTypeID=1</link><pubDate>Thu, 17 Mar 2022 11:52:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14516526-4590-447f-8f9b-1d16608c3fee</guid><dc:creator>thanosPr</dc:creator><description>&lt;p&gt;Thanks ovrebekk for your anwser.&lt;/p&gt;
&lt;p&gt;I have completed succesfully adc reading, but i am trying to disable it in order to reduce consumption.&lt;/p&gt;
&lt;p&gt;How can i do that?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52840 Zephyr ADC read issue</title><link>https://devzone.nordicsemi.com/thread/358616?ContentTypeID=1</link><pubDate>Thu, 17 Mar 2022 11:34:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1a9bac47-2a8f-465b-b43e-3bac4b201732</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Thanos&lt;/p&gt;
&lt;p&gt;From where do you call the &lt;em&gt;readBatteryVoltage()&lt;/em&gt; function?&lt;/p&gt;
&lt;p&gt;The &lt;em&gt;adc_read()&lt;/em&gt; function can not be called from an interrupt context, so it is important to make sure you call&amp;nbsp;&lt;em&gt;readBatteryVoltage()&lt;/em&gt;&lt;span&gt;&amp;nbsp;from&amp;nbsp;thread context for this code to work.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards&lt;br /&gt;Torbjørn&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>