<?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>Low power SAADC</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/93336/low-power-saadc</link><description>Hi, 
 I have a very high consumption when using the ADC of the nRF9160, I am using the NCS 2.0, the firmware used is inspired by the sample provided on github below: 
 https://github.com/Rallare/fw-nrfconnect-nrf/blob/nrf9160_samples/samples/nrf9160/adc</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 31 Oct 2022 16:06:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/93336/low-power-saadc" /><item><title>RE: Low power SAADC</title><link>https://devzone.nordicsemi.com/thread/393312?ContentTypeID=1</link><pubDate>Mon, 31 Oct 2022 16:06:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c3760d9-59b6-44ad-8924-4a9a40c6000a</guid><dc:creator>Thabet</dc:creator><description>&lt;p&gt;Hi &lt;a href="https://devzone.nordicsemi.com/members/usmanmehmood55"&gt;usmanmehmood55&lt;/a&gt;&amp;nbsp;,&lt;/p&gt;
&lt;p&gt;It was not due to a debug, but due to a &amp;quot;bug&amp;quot; found in the nRF9160-DK, if the power jumper of the nRF9160 is removed to connect the PPK2 while the DK is with the switch in the ON position, the consumption is with a floor current of 2.8mA.&lt;/p&gt;
&lt;p&gt;After that, even if the DK is restarted, or the device&amp;#39;s flash is erased, both by the Programmer and VS Code, none of this solves the problem. The consumption only returns to normal (below 2.8mA) if certain firmware is written. Recording the adc sample firmware did not solve the problem, but if I record at_client, or mqtt_simple (these were the ones I tested, but many others can work) the consumption returns to normal, observing floor currents lower than 3uA. The noises also disappeared!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Low power SAADC</title><link>https://devzone.nordicsemi.com/thread/393098?ContentTypeID=1</link><pubDate>Sat, 29 Oct 2022 05:55:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6299575f-2b10-4e7b-9339-63ef6db5be4a</guid><dc:creator>usmanmehmood55</dc:creator><description>&lt;p&gt;One explanation might be that you had debugging on while measuring the current. That itself adds a whole lot of static current, and it doesn&amp;#39;t go back to normal even when you stop debugging. It goes back when you reset, or re-flash.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As for the fixed interval noises, if you are not running any other task or peripheral in the background, it could be related to hardware (like a capacitor charging/discharging at intervals, or the regulator misbehaving)&lt;/p&gt;
&lt;p&gt;If you can attach the latest code here, I can have a look at it during my free time.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Low power SAADC</title><link>https://devzone.nordicsemi.com/thread/393083?ContentTypeID=1</link><pubDate>Fri, 28 Oct 2022 18:57:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:141dd676-dc69-4ead-af38-15b91db67af4</guid><dc:creator>Thabet</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/usmanmehmood55"&gt;usmanmehmood55&lt;/a&gt;&amp;nbsp;,&lt;/p&gt;
&lt;p&gt;Now your suggestion is working!&lt;/p&gt;
&lt;p&gt;I found another approach, developed by @Jared in the topic below, and it worked, so I decided to go back to your approach and it also worked... It was strange to work only after reprogramming and without making any changes, but anyway, both approaches are working and I reach a current of 2 uA floor!&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/92005/nrf5340-cpunet-accessing-saadc/386791"&gt;devzone.nordicsemi.com/.../386791&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;But in both approaches I don&amp;#39;t have a clean graph, I have a noise between the ADC readings, it seems that these noises appear at fixed time intervals, as can be seen below:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1666984762443v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Do you also observe this behavior? Thanks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Low power SAADC</title><link>https://devzone.nordicsemi.com/thread/393047?ContentTypeID=1</link><pubDate>Fri, 28 Oct 2022 13:31:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a603d4ec-8468-43c3-be54-0e99500779da</guid><dc:creator>Thabet</dc:creator><description>[quote userid="94615" url="~/f/nordic-q-a/93336/low-power-saadc/393035"]You can choose to turn off the ADC when it is not needed. That being said, I leave it as is, and it doesn&amp;#39;t consume any power unless I perform an ADC operation (capture, process etc.)[/quote]
&lt;p&gt;&lt;span&gt;How could I do this? Is there any example?&lt;/span&gt;&lt;/p&gt;
[quote userid="94615" url="~/f/nordic-q-a/93336/low-power-saadc/393035"]&lt;p&gt;I find it very strange that the baseline current for sleep is 2.8 mA, that is extremely high.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I would advise that you thoroughly check your measurement process, and make sure nothing else is running in the background. GPIOs, i2c, PWM, could be any of those.&amp;nbsp;&lt;/p&gt;[/quote]
&lt;p&gt;I agree, it&amp;#39;s extremely something, and I&amp;#39;m really not using anything other than ADC, my firmware is attached, if you can check and confirm that, I&amp;#39;d appreciate it! Without any hardware modifications or how to measure, just programming another firmware based on mqtt_simple, I get 2.62 uA in PSM, so it really looks like this is totally related to this ADC sample.&lt;/p&gt;
&lt;p&gt;In this firmware if I disable the ADC settings, the setup, and call the driver, I have an average consumption of 2.93uA.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Low power SAADC</title><link>https://devzone.nordicsemi.com/thread/393035?ContentTypeID=1</link><pubDate>Fri, 28 Oct 2022 13:05:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:14b12d7f-6b50-482e-85e6-98c1a9c244fc</guid><dc:creator>usmanmehmood55</dc:creator><description>&lt;p&gt;You can choose to turn off the ADC when it is not needed. That being said, I leave it as is, and it doesn&amp;#39;t consume any power unless I perform an ADC operation (capture, process etc.)&lt;/p&gt;
&lt;p&gt;I find it very strange that the baseline current for sleep is 2.8 mA, that is extremely high.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I would advise that you thoroughly check your measurement process, and make sure nothing else is running in the background. GPIOs, i2c, PWM, could be any of those.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Low power SAADC</title><link>https://devzone.nordicsemi.com/thread/393026?ContentTypeID=1</link><pubDate>Fri, 28 Oct 2022 12:40:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7852a282-af11-4082-9205-5adf78237d39</guid><dc:creator>Thabet</dc:creator><description>&lt;p&gt;Yes, I&amp;#39;m sure it&amp;#39;s not being consumed by any other peripheral, this code is exclusive to the ADC, I don&amp;#39;t have threads and this while is in the main, I only execute the ADC reads every 2 seconds.&lt;/p&gt;
&lt;p&gt;I added the necessary libs and CONFIG, so I didn&amp;#39;t have any errors, but my consumption didn&amp;#39;t change.&lt;/p&gt;
&lt;p&gt;I take the opportunity to leave a question, this approach only reduces consumption (or should) when the entire system is idle right? So in a real application, where I will have other threads, will the high consumption of the ADC remain even when I wake up the CPU to run other threads that are not related to the ADC? If that&amp;#39;s the case, I don&amp;#39;t think it&amp;#39;s ideal for my application.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Low power SAADC</title><link>https://devzone.nordicsemi.com/thread/393017?ContentTypeID=1</link><pubDate>Fri, 28 Oct 2022 12:22:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d02dabb9-bceb-46c5-b919-262674f2f2f2</guid><dc:creator>usmanmehmood55</dc:creator><description>&lt;p&gt;It took me a while to get the code, personally I have it in form of an easy to read function&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;bool force_low_power_state()
{
    struct pm_state_info info =
    {
        .state            = PM_STATE_SUSPEND_TO_RAM,
        .substate_id      = 0,
        .exit_latency_us  = 0,
        .min_residency_us = 0,
    };
    return pm_state_force(CPU_ID, &amp;amp;info);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;But yeah, your code checks out, and it should not be taking THAT much current.&lt;/p&gt;
&lt;p&gt;Are you sure it isn&amp;#39;t being consumed by some some other component or peripheral?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Low power SAADC</title><link>https://devzone.nordicsemi.com/thread/393009?ContentTypeID=1</link><pubDate>Fri, 28 Oct 2022 12:07:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7399c552-804f-47d9-a2d5-8d228ecb5737</guid><dc:creator>Thabet</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/members/usmanmehmood55"&gt;usmanmehmood55&lt;/a&gt;&amp;nbsp;,&lt;/p&gt;
&lt;p&gt;Thanks for the answer!&lt;/p&gt;
&lt;p&gt;Should this work on the nRF9160? I changed my code forcing to use the recommended power management mode &amp;quot;PM_STATE_SUSPEND_TO_RAM&amp;quot;, during idle state between ADC reads, but there was no change in consumption... did I miss any details?&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;pre class="ui-code" data-mode="text"&gt;while (1) {
		err = adc_sample();
		if (err) {
			printk(&amp;quot;Error in adc sampling: %d\n&amp;quot;, err);
		}
		pm_state_force ( 0u , &amp;amp;( struct pm_state_info){PM_STATE_SUSPEND_TO_RAM, 0 , 0 });
		k_sleep(K_MSEC(2000));
	}&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Low power SAADC</title><link>https://devzone.nordicsemi.com/thread/392954?ContentTypeID=1</link><pubDate>Fri, 28 Oct 2022 08:12:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec55cab6-4350-4ede-9581-011176f22c81</guid><dc:creator>usmanmehmood55</dc:creator><description>&lt;p&gt;Hi.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can achieve similar average current in NCS, by combining the ADC example with the system_off example.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In system_off, they use&amp;nbsp;&lt;code&gt;PM_STATE_SOFT_OFF&lt;/code&gt; with the power manager, which you shouldn&amp;#39;t be using. Instead use &lt;code&gt;PM_STATE_SUSPEND_TO_RAM&lt;/code&gt;, and put the system to sleep between ADC reads, using &lt;code&gt;k_msleep()&lt;/code&gt; or &lt;code&gt;k_sleep()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Attached is an image of the current profile I was able to achieve on nRF52832 using NCS. The sleep current is 2.8 uA.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1666944738759v1.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>