<?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>Hi power consumption after RTC initialization</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/104864/hi-power-consumption-after-rtc-initialization</link><description>I faced with high current consumption in System ON sleep after RTC initialization. If I &amp;quot;call&amp;quot; wfi instruction at the beginning of main() function then chip sleep with 5 uA current consumption, but if I initialize RTC before wfi then power consumption</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 25 Oct 2023 10:47:54 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/104864/hi-power-consumption-after-rtc-initialization" /><item><title>RE: Hi power consumption after RTC initialization</title><link>https://devzone.nordicsemi.com/thread/452228?ContentTypeID=1</link><pubDate>Wed, 25 Oct 2023 10:47:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ffd041af-2134-4682-909b-e0ca92d7fb3e</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Sefo,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Yes you can make the design choice to go bare metal especially if it fits your ecosystem with other microcontroller.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As I said we are more familiar with the nRF Connect SDK and you will have better support if you use the SDK.&amp;nbsp;We will try to help you to debug the issue but it will be limited to verifying the functionality of the hardware according to spec. Could you please provide a minimum example that we can build here&amp;nbsp;?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Also&amp;nbsp;another suggestion is to capture a power profiler trace with&lt;a href="https://www.nordicsemi.com/Products/Development-hardware/Power-Profiler-Kit-2"&gt; a PPK2 for example&lt;/a&gt;, so we can have more insight on when exactly the current go up and with more accurate measurement.&lt;/p&gt;
&lt;p&gt;2mA doesn&amp;#39;t ring any bell to me. I can only think of EasyDMA being used. But as you described if you only use RTC, it should not relate to EasyDMA.&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Please make sure you turn off the netcore, turn off UART/RTT log when you measure current consumption.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi power consumption after RTC initialization</title><link>https://devzone.nordicsemi.com/thread/452020?ContentTypeID=1</link><pubDate>Tue, 24 Oct 2023 14:01:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b241bbc5-93f9-4fc4-ac09-c69f337e171d</guid><dc:creator>sefo</dc:creator><description>&lt;p&gt;Hi Hung,&lt;/p&gt;
&lt;p&gt;Zephyr, of course, works with nRF5340, but only developer of zephyr know how it works. Therefore zephyr&amp;#39;s example is not source of knowledge how nRF5340 works and how to program RTC to&amp;nbsp;still at&amp;nbsp;low power.&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t have problem with RTC functionality itself - RTC work well from functional point of view but definitely there is something that is missed in documentation regarding power consumption minimization when RTC is used. May be I missed some information, maybe I disclose HW bug which should be investigated by Nordic&amp;#39;s engineer and described in Errata.&lt;/p&gt;
&lt;p&gt;Problem to use zephyr or nRF Connect SDK is outdated C programming. I use C++ and I developed C++ framework which permit me and my colleagues develop FW for different microcontrollers from different manufacturer easy and fast. This framework several times increase developers performance comparing with C programming. So I don&amp;#39;t like to downgrade development flow in 2023 to the&amp;nbsp;technology of past century just because Nordic&amp;#39;s support don&amp;#39;t have deep understanding how their own chips work. In such case will be easier to use other BLE chips from other manufacturers.&lt;/p&gt;
&lt;p&gt;So, now I have full functional project on nRF5340 which uses both cores and works well. Single problem is that RTC do automatically some things which increase power consumption and which isn&amp;#39;t described in Nordic&amp;#39;s documentation for nRF5340. All that I request - please provide me information which must be in documentation, but missed.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi power consumption after RTC initialization</title><link>https://devzone.nordicsemi.com/thread/451941?ContentTypeID=1</link><pubDate>Tue, 24 Oct 2023 11:11:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dda4bbe1-4f19-4b81-b3f9-0b772af5faef</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Sefo,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It&amp;#39;s possible to develop the nRF53 in bare metal but you are pretty much on your own and we have limited support if you are going in this direction.&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;I don&amp;#39;t fully understand this:&amp;nbsp;&lt;/p&gt;
[quote user="sefo"]zephyr&amp;#39;s examples are completely useless because show only how to use well preconfigured zephyr example, but not nRF5340.&amp;nbsp;[/quote]
&lt;p&gt;As far as I know most of the samples in Zephyr/NCS works fine with nRF5340. You just need to make sure you flash both the netcore and appcore. If you don&amp;#39;t use the netcore, flash it with the empty netcore application.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Have you tested with latest nRF Connect SDK ? It&amp;#39;s strongly recommended to use the SDK when you develop application for nRF53.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi power consumption after RTC initialization</title><link>https://devzone.nordicsemi.com/thread/451794?ContentTypeID=1</link><pubDate>Mon, 23 Oct 2023 15:43:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd82b6e0-459c-47f2-8f09-fcb9f4d32542</guid><dc:creator>sefo</dc:creator><description>&lt;p&gt;Hi Hung,&lt;/p&gt;
&lt;p&gt;I use&amp;nbsp;NORA-B106 with nRF5340. I don&amp;#39;t use nRF SDK except few headers where address map is defined. I use FreeRTOS and initialization is:&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#0000ff;"&gt;&lt;code&gt;&lt;/code&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;extern &amp;quot;C&amp;quot; void vPortSetupTimerInterrupt( void ) /* PRIVILEGED_FUNCTION */
{
&amp;#160; TICK_RTC-&amp;gt;PRESCALER = (32768 / configTICK_RATE_HZ) - 1;
&amp;#160; TICK_RTC-&amp;gt;INTENSET = RTC_INTENSET_TICK_Msk;
&amp;#160; TICK_RTC-&amp;gt;EVTENSET = RTC_EVTENSET_TICK_Msk;
&amp;#160; TICK_RTC-&amp;gt;TASKS_CLEAR = 1;
&amp;#160; TICK_RTC-&amp;gt;TASKS_START = 1;

&amp;#160; NVIC_SetPriority(TICK_RTC_IRQ, configLIBRARY_LOWEST_INTERRUPT_PRIORITY);&amp;#160;
&amp;#160; NVIC_EnableIRQ(TICK_RTC_IRQ);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="color:#0000ff;"&gt;&lt;code&gt;&lt;/code&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;zephyr&amp;#39;s examples are completely useless because show only how to use well preconfigured zephyr example, but not nRF5340.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;How zephyr uses the RTC (if you are right and zephyr uses RTC) hidden in the depths of&amp;nbsp;zephyr:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static inline int32_t k_msleep(int32_t ms)
{
return k_sleep(Z_TIMEOUT_MS(ms));
}

static inline int32_t k_sleep(k_timeout_t timeout)
{
#ifdef CONFIG_USERSPACE
if (z_syscall_trap()) {
union { struct { uintptr_t lo, hi; } split; k_timeout_t val; } parm0;
parm0.val = timeout;
return (int32_t) arch_syscall_invoke2(parm0.split.lo, parm0.split.hi, K_SYSCALL_K_SLEEP);
}
#endif
compiler_barrier();
return z_impl_k_sleep(timeout);
}



int32_t z_impl_k_sleep(k_timeout_t timeout)
{
k_ticks_t ticks;

__ASSERT(!arch_is_in_isr(), &amp;quot;&amp;quot;);

SYS_PORT_TRACING_FUNC_ENTER(k_thread, sleep, timeout);

/* in case of K_FOREVER, we suspend */
if (K_TIMEOUT_EQ(timeout, K_FOREVER)) {
k_thread_suspend(_current);

SYS_PORT_TRACING_FUNC_EXIT(k_thread, sleep, timeout, (int32_t) K_TICKS_FOREVER);

return (int32_t) K_TICKS_FOREVER;
}

ticks = timeout.ticks;

ticks = z_tick_sleep(ticks);

int32_t ret = k_ticks_to_ms_floor64(ticks);

SYS_PORT_TRACING_FUNC_EXIT(k_thread, sleep, timeout, ret);

return ret;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;As you can see this&amp;nbsp;call tree is little bit &amp;quot;endless&amp;quot; and it is not interesting to spend time for reverse engineering of internal code of zephyr which is overcomplicated because should be universal and cover lot of variations of target platform and even don&amp;#39;t have good comments.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Unfortunately, I already faced few times with facts that Nordic&amp;#39;s documentation sometimes miss important details, sometimes information is placed in unexpected place of document, sometimes don&amp;#39;t correspond to the reality.&amp;nbsp; Therefore, I expect that some Nordic&amp;#39;s engineer just explain me how to properly init and deinit RTC to avoid extra current consumption or point me the place in nRF5340 documentation where it explained and which I just somehow missed.&lt;/p&gt;
&lt;p&gt;For investigation I exclude FreeRTOS and just try in main() init RTC, deinit RTC and call WFI&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;__asm volatile (&amp;quot;wfi&amp;quot;);&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Hi power consumption after RTC initialization</title><link>https://devzone.nordicsemi.com/thread/451509?ContentTypeID=1</link><pubDate>Fri, 20 Oct 2023 12:44:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:551cc3b0-90fc-4e22-85cc-d442ae34d39c</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Sefo,&amp;nbsp;&lt;br /&gt;Could you please show how you initialize RTC and how you call WFI ?&amp;nbsp;&lt;br /&gt;Are you using nRF Connect SDK ?&amp;nbsp;&lt;br /&gt;I assume you are testing with a nRF5340 chip ?&amp;nbsp;&lt;br /&gt;Have you tested with \zephyr\samples\basic\blinky example ? As far as I know Zephyr will use RTC to count time when you call&amp;nbsp;k_msleep()&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>