<?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>nRF5340 high sleep current with short-duration sleep</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/93326/nrf5340-high-sleep-current-with-short-duration-sleep</link><description>I&amp;#39;m looking into the power consumption of our code, and have reached the point where it looks like our application isn&amp;#39;t going into sleep mode properly, and is using several hundred microamps more power than it should be. 
 We want to sample from the</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 07 Nov 2022 13:19:36 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/93326/nrf5340-high-sleep-current-with-short-duration-sleep" /><item><title>RE: nRF5340 high sleep current with short-duration sleep</title><link>https://devzone.nordicsemi.com/thread/394431?ContentTypeID=1</link><pubDate>Mon, 07 Nov 2022 13:19:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:eb107751-3aa3-4e06-85d9-dda5f69091cb</guid><dc:creator>Karl Ylvisaker</dc:creator><description>[quote user="isansys_rory"]However, I&amp;#39;ve realised that the board I&amp;#39;m testing on (a prototype of our device)[/quote]
&lt;p&gt;Oh, I was under the impression that you were conducting these measurements on a DK - then that could indeed explain it.&lt;/p&gt;
[quote user="isansys_rory"]I&amp;#39;m going to try it on a dev kit hooked up to an oscilloscope to see if I can actually see the spike, and confirm what the idle current is in between.[/quote]
&lt;p&gt;Great, I look forward to hearing your results from this! :)&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 high sleep current with short-duration sleep</title><link>https://devzone.nordicsemi.com/thread/394422?ContentTypeID=1</link><pubDate>Mon, 07 Nov 2022 12:56:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:526bdb32-0f30-46e0-a879-69b1d7497c9e</guid><dc:creator>Rory Morrison</dc:creator><description>&lt;p&gt;Possibly, although I don&amp;#39;t think that explains all of it. I can measure the CPU wake up and sleep using&amp;nbsp;&lt;a title="EVENTS_SLEEPENTER" href="https://infocenter.nordicsemi.com/topic/ps_nrf5340/chapters/power/doc/power.html?cp=3_0_0_3_5_0_5#register.EVENTS_SLEEPENTER"&gt;EVENTS_SLEEPENTER&lt;/a&gt;&lt;span&gt;&amp;nbsp;and&amp;nbsp;&lt;/span&gt;&lt;a title="EVENTS_SLEEPEXIT" href="https://infocenter.nordicsemi.com/topic/ps_nrf5340/chapters/power/doc/power.html?cp=3_0_0_3_5_0_6#register.EVENTS_SLEEPEXIT"&gt;EVENTS_SLEEPEXIT&lt;/a&gt;, and that gives me 80 us awake (sometimes only 40), then 1000 us asleep. A back-of-the-envelope calculation gives me about 320 uA from that, when I&amp;#39;m seeing twice that on the otii.&lt;/p&gt;
&lt;p&gt;However, I&amp;#39;ve realised that the board I&amp;#39;m testing on (a prototype of our device) has an LDO that drops the voltage going to the nRF module, and I think smooths the current draw. So that would explain why I&amp;#39;m not seeing a big ~4 mA spike when the CPU turns on, and also why I don&amp;#39;t necessarily see the full dip in current in sleep mode.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m going to try it on a dev kit hooked up to an oscilloscope to see if I can actually see the spike, and confirm what the idle current is in between.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 high sleep current with short-duration sleep</title><link>https://devzone.nordicsemi.com/thread/394333?ContentTypeID=1</link><pubDate>Mon, 07 Nov 2022 08:47:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c4b8c3f0-84e0-495d-9522-6144ff0e0a41</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;&lt;br /&gt;The system clock is the RTC1, which is a ultra low power clock source - it will not need to keep the HF clock on in order to time the kernel sleeps, so that should not be what you are seeing here.&lt;br /&gt;I would rather think you are seeing the increased current from having to wake up to process the k_msleep every 1 ms.&lt;br /&gt;Did you try to keep the loop empty, and measured the power consumption in this case? If you are then seeing the expected levels we would be able to confirm that the excess draw is indeed related to the CPU wakeup to process k_msleep.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 high sleep current with short-duration sleep</title><link>https://devzone.nordicsemi.com/thread/393979?ContentTypeID=1</link><pubDate>Thu, 03 Nov 2022 15:36:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:892e3104-2f81-4eca-abcc-2589c20c1c00</guid><dc:creator>Rory Morrison</dc:creator><description>&lt;p&gt;It&amp;#39;s occurred to me that when I call&amp;nbsp;&lt;span&gt;k_msleep(1) the operating system has to time a 1 ms sleep. It can&amp;#39;t accurately do that without using the HF clock, because 32768 clock cycles doesn&amp;#39;t divide into 1000. So presumably something in the OS has to decide if it&amp;#39;s worth using the LF clock and turning off the HF clock for part of the sleep time, or whether to just to keep the HF clock on throughout.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So the question is, how does the OS decide that? Is there any way I can get zephyr to turn off the HF clock faster?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 high sleep current with short-duration sleep</title><link>https://devzone.nordicsemi.com/thread/393905?ContentTypeID=1</link><pubDate>Thu, 03 Nov 2022 13:42:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39619cc5-d282-4fa7-bc83-eced8ca3588c</guid><dc:creator>Karl Ylvisaker</dc:creator><description>[quote user="isansys_rory"]&lt;p&gt;Ignoring all the PPI and SAADC stuff for the moment - this is just a while loop with a&amp;nbsp;&lt;span&gt;k_msleep for 1 millisecond.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Is this keeping the HF clock on all the time? Or is my current profiling out somehow?&lt;/span&gt;&lt;/p&gt;[/quote]
&lt;p&gt;Just for good measure, could you detail your setup? How is everything connected to your kit?&lt;br /&gt;For good measure, we&amp;#39;ve also got &lt;a href="https://infocenter.nordicsemi.com/topic/ug_nrf5340_dk/UG/dk/hw_measure_current.html"&gt;this Power Measuring guide for the nRF5340 DK&lt;/a&gt; that could be useful to reference in regards to the setup.&lt;/p&gt;
[quote user="isansys_rory"]So, when I call k_msleep, how quickly does the CPU turn off, and how quickly does the HF clock turn off?[/quote]
&lt;p&gt;The HFCLK will not turn of if it is being used / requested by any other peripherals, like the PPI or GPIOTE (for high accuracy events).&lt;br /&gt;In your minimal application you do not use any such&lt;br /&gt;However, when you use the k_msleep(1) it would mean that your CPU has to wake up every 1 ms to process the next k_msleep instruction, which likely is skewing your measurements.&lt;br /&gt;If you have no operations/processing other than the k_msleep happening in your main loop you could instead leave it empty, which will have it go into the sleep thread/SYSTEM_ON sleep, which should give you lower overall power consumption (if you only would like to measure power consumption of a background process anyways, no CPU actions).&lt;/p&gt;
[quote user="isansys_rory"]I&amp;#39;ve been using an otii sampling at 4 kHz so it&amp;#39;s possible it&amp;#39;s smoothing out the current and what looks like a small oscillation around 650 uA is actually a spike up to ~4 mA when the CPU turns on, and a dip down to 20 uA the rest of the time.[/quote]
&lt;p&gt;I would think that you would see the spike to ~4mA if this was the case, when sampling with 4 kHz. I unfortunately do not have any personal experience with the otii tools (I primarily use the PPK II myself), but I would not imagine that it would miss the spike of the CPU turning on.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 high sleep current with short-duration sleep</title><link>https://devzone.nordicsemi.com/thread/393696?ContentTypeID=1</link><pubDate>Wed, 02 Nov 2022 14:24:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:07dfc4b2-b3dd-417b-a254-1a99536e8b69</guid><dc:creator>Rory Morrison</dc:creator><description>&lt;p&gt;Ignoring all the PPI and SAADC stuff for the moment - this is just a while loop with a&amp;nbsp;&lt;span&gt;k_msleep for 1 millisecond.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Is this keeping the HF clock on all the time? Or is my current profiling out somehow?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I&amp;#39;ve been using an otii sampling at 4 kHz so it&amp;#39;s possible it&amp;#39;s smoothing out the current and what looks like a small oscillation around 650 uA is actually a spike up to ~4 mA when the CPU turns on, and a dip down to 20 uA the rest of the time.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So, when I call k_msleep, how quickly does the CPU turn off, and how quickly does the HF clock turn off?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 high sleep current with short-duration sleep</title><link>https://devzone.nordicsemi.com/thread/393669?ContentTypeID=1</link><pubDate>Wed, 02 Nov 2022 13:20:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3bfb5fe6-2112-4dc2-9f6d-6f5cc9701c78</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Thank you for providing the minimal project, I&amp;#39;ll do some testing here on my end and get back to you by the end of the week.&lt;/p&gt;
[quote user="isansys_rory"]The reason I&amp;#39;m looking at this is that in our actual code we&amp;#39;re using a GPIOTE interrupt to trigger sampling via PPI as you recommended above, and this is resulting in the same sort of behaviour, with, I think, the HF clock on permanently.[/quote]
&lt;p&gt;Ah, yes, the PPI will require the HF clock, but the draw of the HF clock is much lower than that of the CPU. CPU triggered sampling is only really more energy efficient if you sample very seldomly, or non-periodically.&lt;/p&gt;
[quote user="isansys_rory"]a) this is correct, and the HF clock is staying on, b) If it is, is it possible to turn it off quicker and so save current, or c) if it isn&amp;#39;t, is it possible to run the SAADC without turning the HF clock on at all.[/quote]
&lt;p&gt;It is correct that the HF clock will need to be enabled for the PPI to function, but it is also possible to run the SAADC from CPU triggered sampling, without PPI as well, but this &lt;em&gt;usually&lt;/em&gt; comes with a higher power consumption for periodic / high frequency sampling. However, if you were to only sample once every second you could instead consider using the CPU to trigger this, rather than the PPI.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 high sleep current with short-duration sleep</title><link>https://devzone.nordicsemi.com/thread/393066?ContentTypeID=1</link><pubDate>Fri, 28 Oct 2022 14:20:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d739d3e7-8dbe-462d-ab14-8520efd8abc7</guid><dc:creator>Rory Morrison</dc:creator><description>&lt;p&gt;Okay, this is the code I&amp;#39;m profiling - I&amp;#39;ve removed&amp;nbsp;everything that isn&amp;#39;t just sitting in a while loop sleeping, and checked it&amp;#39;s still behaving the same way. The 1 ms sleep version doesn&amp;#39;t seem to drop below about 650 uA at any point, although I can see the current going up and down as the CPU goes in and out of sleep.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;What I think is happening is that the HF oscillator doesn&amp;#39;t have time to turn off if the sleep duration is only 1 ms, so we draw 650 or so uA. Whereas with a longer sleep duration it turns off in between and we can get a much lower current.&lt;/p&gt;
&lt;p&gt;The reason I&amp;#39;m looking at this is that in our actual code we&amp;#39;re using a GPIOTE interrupt to trigger sampling via PPI as you recommended above, and this is resulting in the same sort of behaviour, with, I think, the HF clock on permanently.&lt;/p&gt;
&lt;p&gt;So I&amp;#39;m trying to work out whether a) this is correct, and the HF clock is staying on, b) If it is, is it possible to turn it off quicker and so save current, or c) if it isn&amp;#39;t, is it possible to run the SAADC without turning the HF clock on at all.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/minimal_5F00_current_5F00_profiling.zip"&gt;devzone.nordicsemi.com/.../minimal_5F00_current_5F00_profiling.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 high sleep current with short-duration sleep</title><link>https://devzone.nordicsemi.com/thread/393032?ContentTypeID=1</link><pubDate>Fri, 28 Oct 2022 12:57:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:abda0a04-d3bd-4b16-8fff-5ae0408eb285</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Could you show me the entire code for your minimal project that you used to perform the measurements?&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 high sleep current with short-duration sleep</title><link>https://devzone.nordicsemi.com/thread/393024?ContentTypeID=1</link><pubDate>Fri, 28 Oct 2022 12:33:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e9640924-8864-48c9-be0c-0fe6951f087e</guid><dc:creator>Rory Morrison</dc:creator><description>&lt;p&gt;I mean that literally just sleeping in a while loop draws hundreds of uA. No sampling, no interrupts, nothing.&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;code&gt;&lt;span&gt;void&lt;/span&gt;&lt;span&gt; &lt;/span&gt;&lt;span&gt;main&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;void&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;&lt;code&gt;&lt;span&gt;{&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;code&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;while&lt;/span&gt;&lt;span&gt; (&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;) {&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;&lt;code&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;k_msleep&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;&lt;code&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;code&gt;&lt;span&gt;}&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;
&lt;p&gt;Whereas sleeping for 1000 instead of 1 there draws ~23 uA&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF5340 high sleep current with short-duration sleep</title><link>https://devzone.nordicsemi.com/thread/393021?ContentTypeID=1</link><pubDate>Fri, 28 Oct 2022 12:25:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b32820f0-f9ea-463f-9f96-87a44f29334f</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;&lt;br /&gt;Could you show some of the code that ran when you did these measurements?&lt;/p&gt;
[quote user=""]The most basic example is just a while loop that sleeps for 1 ms.[/quote]
&lt;p&gt;I suspect that this means that you are doing direct calls to the manual call to sample, is this correct? This will require that the CPU is involved with every sample taken, which will increase your power consumption significantely.&lt;br /&gt;To achieve the lowest power consumption when doing periodic SAADC readings we recommend that you connect the SAADC sample TASK to a CC event of a TIMER (or other periodic event generator), so that you avoid the CPU waking up to perform every sampling. If you do not immediately need to process every sample you can store them in a larger buffer, so that the CPU can wake to process them less often.&lt;br /&gt;Please try this, and let me know if you see a sufficient reduction in your average power consumption.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>