<?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>FreeRTOS power consumption spikes when in System ON sleep mode</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/55885/freertos-power-consumption-spikes-when-in-system-on-sleep-mode</link><description>Hello - 
 
 We are developing on the nRF52840-DK, using SDK 15.3.0 and FreeRTOS with tickless idle. The SoftDevice is disabled. Using the PPK v2.3.1 when our app is in System ON sleep mode, we are seeing power consumption spikes at regular ~1s intervals</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 16 Sep 2020 00:58:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/55885/freertos-power-consumption-spikes-when-in-system-on-sleep-mode" /><item><title>RE: FreeRTOS power consumption spikes when in System ON sleep mode</title><link>https://devzone.nordicsemi.com/thread/269744?ContentTypeID=1</link><pubDate>Wed, 16 Sep 2020 00:58:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:43c76a89-6125-409e-bdb9-ff940e5cbee3</guid><dc:creator>bfriedk1</dc:creator><description>&lt;p&gt;Hello -&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Just a quick check to see if there is anything else we can try&amp;nbsp;here. Another thought I had was to turn off /on the WDT inside&amp;nbsp;&lt;span&gt;vPortSuppressTicksAndSleep() before and after sleep.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Brian&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS power consumption spikes when in System ON sleep mode</title><link>https://devzone.nordicsemi.com/thread/269230?ContentTypeID=1</link><pubDate>Fri, 11 Sep 2020 23:30:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:592d555f-5aca-4949-a057-99a0c83906b6</guid><dc:creator>bfriedk1</dc:creator><description>&lt;p&gt;Susheel -&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Welcome back to this case. In our application idle hook we are calling WFE in the profile I shared three days ago. We do not have NRF_LOG_ENABLED in our build. We do have SOFTDEVICE_PRESENT set to 1 in our build, though this test app isn&amp;#39;t using the SoftDevice. Hence the call to nrf_sdh_is_enabled() returns false and we call WFE. The code I shared from the idle hook was basically copied from the SDK&amp;nbsp;&lt;span&gt;vPortSuppressTicksAndSleep() function. Just to clarify, is there anything wrong with this approach?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;That said, I remembered that we have the watch dog timer enabled. In our build we have the&amp;nbsp;NRFX_WDT_CONFIG_BEHAVIOR set to 1 (Run in SLEEP, Pause in HALT). I reverted our code back to use tickless idle, the Nordic&amp;nbsp;vPortSuppressTicksAndSleep() function, but disabled the watch dog timer. That seems to have eliminated the power consumption spikes. The strange thing is that setting the&amp;nbsp;NRFX_WDT_CONFIG_BEHAVIOR to 1, 0, or 8 doesn&amp;#39;t eliminate the spikes. Nor does changing the&amp;nbsp;NRFX_WDT_CONFIG_RELOAD_VALUE. Unless the watch dog timer is completely disabled, we see the spikes at ~1s intervals, even if the reload value is much higher.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I hope these findings help to pin down the root cause. We do want to run with tickless idle and also have the WDT enabled to catch any unexpected stalls while&amp;nbsp;not sleeping. For reference, here is our WDT setup and feed code:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;static nrf_drv_wdt_channel_id wdt_channel_id;

static void watchdog_init(void)
{
	nrf_drv_wdt_config_t config = NRF_DRV_WDT_DEAFULT_CONFIG;
	nrf_drv_clock_lfclk_request(NULL);
	ret_code_t err_code = nrf_drv_wdt_init(&amp;amp;config, wdt_event_handler);
	APP_ERROR_CHECK(err_code);
	nrf_drv_wdt_channel_alloc(&amp;amp;wdt_channel_id);
	nrf_drv_wdt_enable();
}

static void watchdog_feed(void)
{
	nrf_drv_wdt_feed();
}
&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Brian&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS power consumption spikes when in System ON sleep mode</title><link>https://devzone.nordicsemi.com/thread/269098?ContentTypeID=1</link><pubDate>Fri, 11 Sep 2020 08:33:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cdb9956c-2340-400a-8b06-9817798b57c8</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;That is a worrisome finding. In your application idle hook, you are using both sd_app_evt_wait and WFE. Which one is executed by your application? Are you using logs? can you test once by disabling logs ?(NRF_LOG_ENABLED set to 0 in sdk_config.h file)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS power consumption spikes when in System ON sleep mode</title><link>https://devzone.nordicsemi.com/thread/268610?ContentTypeID=1</link><pubDate>Wed, 09 Sep 2020 00:46:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d175daf-79e4-411d-b6c3-3e72a797484b</guid><dc:creator>bfriedk1</dc:creator><description>&lt;p&gt;Hello -&lt;/p&gt;
&lt;p&gt;I apologize for the&amp;nbsp;very late follow-up here. We&amp;#39;ve since brought up our custom nRF52840 board and we are still seeing regular power consumption spikes at ~1s intervals when running under FreeRTOS, with tickless idle enabled, and using the&amp;nbsp;vPortSuppressTicksAndSleep() function provided in the nRF52 SDK v17.0.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;We enter System ON sleep mode by waiting forever on a FreeRTOS task queue. Using the PPK, this is what we see when that happens:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x480/__key/communityserver-discussions-components-files/4/4101.image.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;My understanding is that the spikes are related to the RTC wakeup configuration I described above.&lt;/p&gt;
&lt;p&gt;Changing the value of&amp;nbsp;&lt;span&gt;configEXPECTED_IDLE_TIME_BEFORE_SLEEP doesn&amp;#39;t seem to help. As a test I bumped that value up to 2000 and the resulting power draw was much higher and constant.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I did some experiments to try and isolate the problem. One of those experiments disables tickless idle and instead calls __WFE() from our application idle hook function. Here is the idle hook implementation:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void vApplicationIdleHook( void )
{
#ifdef SOFTDEVICE_PRESENT
	if (nrf_sdh_is_enabled())
	{
		uint32_t err_code = sd_app_evt_wait();
		APP_ERROR_CHECK(err_code);
	}
	else
#endif
	{
		/* No SD -  we would just block interrupts globally.
		* BASEPRI cannot be used for that because it would prevent WFE from wake up.
		*/
		do{
			__WFE();
		} while (0 == (NVIC-&amp;gt;ISPR[0] | NVIC-&amp;gt;ISPR[1]));
	}
#endif
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When we run this configuration, without tickless idle, the power spikes are essentially eliminated, but the average current consumption is much higher:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/7416.image-_2800_1_2900_.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Based on this experiment I am wondering if something in the&amp;nbsp;&lt;span&gt;vPortSuppressTicksAndSleep() function reduces current consumption. Ideally we are looking for a solution that eliminates the spikes but also reduces power consumption down to what we&amp;#39;ve measured when tickless idle is enabled.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thank you again for your helpful feedback. Looking forward to finding a solution.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Brian&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS power consumption spikes when in System ON sleep mode</title><link>https://devzone.nordicsemi.com/thread/229525?ContentTypeID=1</link><pubDate>Fri, 17 Jan 2020 08:04:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:74ec86c1-f1b6-40ce-b60d-43f4384897e3</guid><dc:creator>Susheel Nuguru</dc:creator><description>&lt;p&gt;Your system seems to be sleeping most of the time and hence you managed to pull the power consumption low most of the time.&lt;/p&gt;
&lt;p&gt;The&amp;nbsp;configEXPECTED_IDLE_TIME_BEFORE_SLEEP in the FreeRTOSConfig.h file decides the expected sleep time and after which the RTOS will wakeup to see if everything is ok and do the book keeping. You can increase this to a suitable value for you app and this should move the spikes farther apart if you increase the value.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS power consumption spikes when in System ON sleep mode</title><link>https://devzone.nordicsemi.com/thread/228996?ContentTypeID=1</link><pubDate>Tue, 14 Jan 2020 10:16:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:304f86ce-6a78-4975-9851-3aca29b06476</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;Apologize for the delay.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;m not too familiar with FreeRTOS, and our engineer working with FreeRTOS is currently out of office. &lt;br /&gt;He&amp;#39;ll be back in office tomorrow (14/1), and I&amp;#39;ll have him take a look at your issue then.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Br,&amp;nbsp;&lt;br /&gt;Joakim&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS power consumption spikes when in System ON sleep mode</title><link>https://devzone.nordicsemi.com/thread/228694?ContentTypeID=1</link><pubDate>Sun, 12 Jan 2020 18:31:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b51b3570-a1ca-4385-a722-4c109b93d586</guid><dc:creator>bfriedk1</dc:creator><description>&lt;p&gt;Hello -&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Just checking back after the holiday break. Still looking for a solution to eliminate the power consumption spikes.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Brian&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: FreeRTOS power consumption spikes when in System ON sleep mode</title><link>https://devzone.nordicsemi.com/thread/226870?ContentTypeID=1</link><pubDate>Fri, 27 Dec 2019 01:02:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1e9083d7-7d84-41a2-9760-2b112b51ce2c</guid><dc:creator>Joakim Jakobsen</dc:creator><description>&lt;p&gt;Hi. &lt;br /&gt;&lt;br /&gt;Nordic technical support staff is reduced due to the christmas holiday in Norway. &lt;br /&gt;We will be back to full staffing at 6th of January, and might not be able to provide you with an answer before that.&lt;br /&gt;&lt;br /&gt;Best regards, &lt;br /&gt;Nordic technical support&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>