<?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 tickless low power idle always ticking</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/75774/nrf52840-zephyr-tickless-low-power-idle-always-ticking</link><description>I&amp;#39;m working on a custom board using an nRF52840 for a sensor Tag (light, hum, temp, press) https://www.homesmartmesh.com/docs/microcontrollers/nrf52/thread_sensortag/ 
 I would like to use openthread over Zephyr. Using a previous nRF-SDK without Zephyr</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 18 Feb 2023 02:57:08 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/75774/nrf52840-zephyr-tickless-low-power-idle-always-ticking" /><item><title>RE: nRF52840 Zephyr tickless low power idle always ticking</title><link>https://devzone.nordicsemi.com/thread/410735?ContentTypeID=1</link><pubDate>Sat, 18 Feb 2023 02:57:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c5e078b-c087-410f-be49-a9056152a0ea</guid><dc:creator>engineer2022</dc:creator><description>&lt;p&gt;For future readers: this helped me a lot, I wasn&amp;#39;t even using the CONSOLE libraries, and adding these explicit options turn off: &lt;br /&gt;CONFIG_CONSOLE=n&lt;br /&gt;CONFIG_UART_CONSOLE=n&lt;br /&gt;CONFIG_RTT_CONSOLE=n&lt;br /&gt;&lt;br /&gt;reduced my floor current by 80uA! &lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 Zephyr tickless low power idle always ticking</title><link>https://devzone.nordicsemi.com/thread/313348?ContentTypeID=1</link><pubDate>Thu, 03 Jun 2021 10:18:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10525253-973e-4a34-b9e4-c067b2dbc48a</guid><dc:creator>wass</dc:creator><description>&lt;p&gt;Thanks for the hints, yes, I use `build\zephyr\.config` to&amp;nbsp;verify and also as basis of the review of all existing flags default values.&lt;br /&gt;Thanks also for the hint about the multi image, I&amp;#39;m not there yet but I&amp;#39;ll keep that in mind.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 Zephyr tickless low power idle always ticking</title><link>https://devzone.nordicsemi.com/thread/313342?ContentTypeID=1</link><pubDate>Thu, 03 Jun 2021 10:06:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9246ccd-c90a-4a9b-9923-08a6f093ff06</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;I&amp;#39;m glad to help, and happy you got the power down. Unless you&amp;#39;re not already aware of it, I would recommend you to check the file &amp;lt;application&amp;gt;/build/zephyr/.config to see what the Kconfigs are actually set to (e.g. if CONFIG_SERIAL is equal to n).&lt;/p&gt;
&lt;p&gt;Be aware that if you&amp;#39;re building a multi image application, e.g. with mcuboot, you have to set CONFIG_SERIAL in the other images as well to get the power down.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 Zephyr tickless low power idle always ticking</title><link>https://devzone.nordicsemi.com/thread/313341?ContentTypeID=1</link><pubDate>Thu, 03 Jun 2021 09:59:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6548457e-36f9-4080-831b-a734ff9027ea</guid><dc:creator>wass</dc:creator><description>&lt;p&gt;You were right, I managed to get ~ 3uA of sleep current with a simple k_sleep(K_MSEC(5000)). I&amp;nbsp;set your answer to verified because it is correct, although it does not explain the issue I&amp;#39;ve run into, which is I think beyond the goal of this ticket.&lt;br /&gt;The goal of this ticket was to get the simplest low power kernel sleep running and it is achieved.&lt;br /&gt;The flag you suggested was already set in my example `CONFIG_SERIAL=n`, but as an exercise, I went through all the config to check what is set by default to &amp;quot;y&amp;quot; and likely to use a peripheral that consumes power, as&amp;nbsp;info for others this is the config I used&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;CONFIG_SERIAL=n
CONFIG_LOG=n
CONFIG_CONSOLE=n
CONFIG_UART_CONSOLE=n
CONFIG_RTT_CONSOLE=n
CONFIG_USE_SEGGER_RTT=n
CONFIG_PRINTK=n&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I got stuck while trying to do something very simple, and the more I altered the config and used custom functions, the more it interfered with the proper running of the OS.&amp;nbsp;It went as far as&amp;nbsp;a simple comment of a custom function call fixed the issue and allowed the k_sleep power to go from 460 uA down to the expected 3uA.&lt;br /&gt;So as a hint&amp;nbsp;for anyone who does not manage to get k_sleep into low power in a complex example =&amp;gt; make sure your code is not messing up with low level calls&amp;nbsp;`sys_clock_set_timeout, nrf_clock_task_trigger,&amp;nbsp;nrf_power_task_trigger,&lt;span&gt;__WFE, _SVE, ...&lt;/span&gt;` unless you&amp;#39;re on your own and you know what you&amp;#39;re doing.&lt;/p&gt;
&lt;p&gt;So on the positive side, I leaned a lot from this issue by looking into the depth of Zephyr.&lt;br /&gt;The work is only starting now, I need to get my complex example of openthread as Sleepy End Device into this ultra low power sleep, if I manage, I&amp;#39;ll update here as the code being optimized is already available so if someone wants to help or give advices, feel free :&amp;nbsp;&lt;a href="https://github.com/HomeSmartMesh/sdk-hsm-sensortag/tree/main/samples/tag_sensors_broadcast"&gt;https://github.com/HomeSmartMesh/sdk-hsm-sensortag/tree/main/samples/tag_sensors_broadcast&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 Zephyr tickless low power idle always ticking</title><link>https://devzone.nordicsemi.com/thread/313290?ContentTypeID=1</link><pubDate>Thu, 03 Jun 2021 07:54:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6704aa51-d7b2-43e1-83fa-5280107c7c99</guid><dc:creator>Simon</dc:creator><description>[quote userid="91345" url="~/f/nordic-q-a/75774/nrf52840-zephyr-tickless-low-power-idle-always-ticking/312701#312701"]We have two paths on how we could progress on this, if you or someone know an example proven to have driven an nRF52840 with Zephyr into less than 10 uA in a kernel sleep function, then having a commit with all the code and config in a repo would be much appreciated,&amp;nbsp;I can test it. My target is exactly the nRF52840.[/quote]
&lt;p&gt;I guess the current consumption is caused by UART/logging being enabled. Can you test the sample &lt;a href="https://github.com/nrfconnect/sdk-zephyr/tree/v2.4.99-ncs2/samples/basic/blinky"&gt;zephyr/samples/basic/blinky&lt;/a&gt; with CONFIG_SERIAL=n in prj.conf?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 Zephyr tickless low power idle always ticking</title><link>https://devzone.nordicsemi.com/thread/312701?ContentTypeID=1</link><pubDate>Mon, 31 May 2021 16:03:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f86c2fa2-f22e-402c-bbff-b9cefda70216</guid><dc:creator>wass</dc:creator><description>&lt;p&gt;I tried that in the first place but it did not work, the current consumption was high,&amp;nbsp;only then I started digging deeper. That&amp;#39;s when I realized that the CONFIG_PM had no effect.&lt;br /&gt;The first issue start in `soc/arm/nordic_nrf/nrf52/power.c` where only `PM_STATE_SOFT_OFF` is implemented.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/zephyrproject-rtos/zephyr/blob/3d39f72a88b3100ac83e7c6c285ae567aca640d0/soc/arm/nordic_nrf/nrf52/power.c#L17"&gt;https://github.com/zephyrproject-rtos/zephyr/blob/3d39f72a88b3100ac83e7c6c285ae567aca640d0/soc/arm/nordic_nrf/nrf52/power.c#L17&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;img alt=" " height="178" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1622476033394v1.png" width="370" /&gt;&lt;/p&gt;
&lt;p&gt;That means if we call the kernel sleep functions that give back the hand to the OS to keep the idle task running and start tracing back from there you would go through `idle()` task from `zephyr\kernel\idle.c` that only in case `CONFIG_PM` is enabled will call&amp;nbsp;pm_save_idle -&amp;gt;&amp;nbsp;pm_system_suspend -&amp;gt;&amp;nbsp;pm_policy_next_state&amp;nbsp;which then always returns `&lt;span&gt;PM_STATE_ACTIVE&lt;/span&gt;`.&lt;/p&gt;
&lt;p&gt;And that is not exactly what my question was about, my question is about the tickless idle.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;We have two paths on how we could progress on this, if you or someone know an example proven to have driven an nRF52840 with Zephyr into less than 10 uA in a kernel sleep function, then having a commit with all the code and config in a repo would be much appreciated,&amp;nbsp;I can test it. My target is exactly the nRF52840.&lt;br /&gt;&lt;br /&gt;Otherwise, we can also talk about&amp;nbsp;code review, and how the zephyr sleep is supposed to put the nRF52 target in sleep and the resume after waking up from the RTC interrupt. I did implement additional low power states (in the patch link I provided), but due&amp;nbsp;to what seams like a bug, the idle Task does not let go and keeps ticking, it&amp;#39;s hard to debug as the RTC behavior cannot be step debugged and the real time pio debug does not output values. And by the way Zephyr OS is using the RTC so the user is not expected to touch it and the system would wakeup on the next expected event. To be more specific, in tickless mode, the system is only expected to wakeup in the next planned event and not keep waking it periodically every 264 uS to check if something has to happen, that is what I&amp;#39;m observing now. That frequent wakeup creates a cpu overhead that deteriorates the average current consumption during the kernel sleep period.&lt;/p&gt;
&lt;p&gt;More obvious with SystemView&lt;br /&gt;This is how a supposedly low power kernel sleep looks like, idle keeps looping and scheduler&amp;nbsp;keep triggering periodically&lt;br /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1622655489725v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1622655920363v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 Zephyr tickless low power idle always ticking</title><link>https://devzone.nordicsemi.com/thread/312682?ContentTypeID=1</link><pubDate>Mon, 31 May 2021 14:30:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:28463983-5b60-4b31-95f4-897bca6491a3</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;You actually don&amp;#39;t need to do anything actively to put the chip into System ON sleep: &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/65959/how-to-enter-system-on-sleep-in-zephyr/269893#269893"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/65959/how-to-enter-system-on-sleep-in-zephyr/269893#269893&lt;/a&gt;. It will happen automatically when nothing else is going on. Just configure the RTC to wake it up periodically and the chip will go to sleep in between.&lt;/p&gt;
&lt;p&gt;Hopefully I have understood you correctly. If not, please tell me and clarify.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>