<?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>nrf_pwr_mgmt_run() with SoftDevice not go to low power</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/64035/nrf_pwr_mgmt_run-with-softdevice-not-go-to-low-power</link><description>Hello. 
 I use SDK16 in my project. 
 Previously when I want to go on sleep I use __WFI(), and get into sleep till interrupt. Because I use The SoftDevice I change the command to nrf_pwr_mgmt_run() as instruct by Nordic . But now it doesn&amp;#39;t enter sleep</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 27 Jul 2020 12:59:15 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/64035/nrf_pwr_mgmt_run-with-softdevice-not-go-to-low-power" /><item><title>RE: nrf_pwr_mgmt_run() with SoftDevice not go to low power</title><link>https://devzone.nordicsemi.com/thread/261794?ContentTypeID=1</link><pubDate>Mon, 27 Jul 2020 12:59:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f74f637c-84dd-4b12-bf46-d1a24f76700d</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thank you for your observations.&lt;/p&gt;
&lt;p&gt;Could you upload a &lt;strong&gt;minimal project&lt;/strong&gt; that reproduces the issue and &lt;strong&gt;will run on the nRF52840 DK&lt;/strong&gt;? I&amp;#39;ll try to reproduce it and see if I can find the root cause.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;best regards&lt;/p&gt;
&lt;p&gt;Jared&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_pwr_mgmt_run() with SoftDevice not go to low power</title><link>https://devzone.nordicsemi.com/thread/261785?ContentTypeID=1</link><pubDate>Mon, 27 Jul 2020 12:41:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6117fa39-a3ac-4a7e-b75a-bd1581f20952</guid><dc:creator>Bar</dc:creator><description>&lt;p&gt;Hi Jared.&lt;/p&gt;
&lt;p&gt;I found also something strange about implement the _WFE()&lt;/p&gt;
&lt;p&gt;In some examples I found it set like this&amp;nbsp;&lt;/p&gt;
&lt;p&gt;__WFE();&lt;/p&gt;
&lt;p&gt;__SEV();&lt;br /&gt; __WFE();&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;but using it won&amp;#39;t get it to low power&amp;nbsp;&lt;/p&gt;
&lt;p&gt;But know during reading about&amp;nbsp;&lt;span&gt;sd_app_evt_wait();&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I found it is written like this&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;__SEV();&lt;br /&gt;__WFE();&lt;/p&gt;
&lt;p&gt;__WFE();&lt;/p&gt;
&lt;p&gt;This one work.&lt;/p&gt;
&lt;p&gt;So maybe inside&amp;nbsp;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;sd_app_evt_wait();&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;It still use the wrong setting&lt;/p&gt;
&lt;p&gt;__WFE();&lt;/p&gt;
&lt;p&gt;__SEV();&lt;br /&gt;__WFE();&lt;/p&gt;
&lt;p&gt;(I can&amp;#39;t look inside this function at my SDK)?&lt;/p&gt;
&lt;p&gt;Bar.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_pwr_mgmt_run() with SoftDevice not go to low power</title><link>https://devzone.nordicsemi.com/thread/261770?ContentTypeID=1</link><pubDate>Mon, 27 Jul 2020 12:04:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e53268bf-91cf-43b7-a960-5d8b61fd1968</guid><dc:creator>Bar</dc:creator><description>&lt;p&gt;Hello Jared.&lt;/p&gt;
&lt;p&gt;As&amp;nbsp; I look into&amp;nbsp;&lt;span&gt;sd_app_evt_wait() I just get to this function&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;SVCALL(SD_APP_EVT_WAIT, uint32_t, sd_app_evt_wait(void));&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;But can&amp;#39;t get inside. It is look it send and receive interrupt flags&amp;nbsp;from the SD.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I look on the header explain and I see this:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In order to wake up from disabled interrupts, the &lt;strong&gt;SEVONPEND&lt;/strong&gt; flag has to be set in the Cortex-M&lt;br /&gt;MCU&amp;#39;s System Control Register (SCR), CMSIS_SCB.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;...&amp;nbsp;The application must ensure that the pended flag is cleared using ::sd_nvic_ClearPendingIRQ&lt;br /&gt;&amp;nbsp;in order to sleep using this function. This is only necessary for disabled interrupts&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I can&amp;#39;t find anything about&amp;nbsp;&lt;strong&gt;sd_nvic_ClearPendingIRQ&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;But when look for the&amp;nbsp;&lt;strong&gt;SEVONPEND&lt;/strong&gt;&lt;span&gt;&amp;nbsp;flag I found this discussion:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/7107/sevonpend-setting---how-to"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/7107/sevonpend-setting---how-to&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;WHere he did some work exactly with the some function I try to handle.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Where look for&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/7107/sevonpend-setting---how-to"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/7107/sevonpend-setting---how-to&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;So I look for&amp;nbsp;&lt;strong&gt;SCB_SCR_SEVONPEND_Msk&amp;nbsp;&lt;/strong&gt;and the only thing I found was&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;SCB-&amp;gt;SCR |= SCB_SCR_SEVONPEND_Msk;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;which is close by&amp;nbsp;#ifdef PWR_MGMT_SLEEP_IN_CRITICAL_SECTION_REQUIRED&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;DO I need&amp;nbsp;to open this define?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I also read comment exactly about some issue with&amp;nbsp;sd_app_evt_wait(void) and excessive current. They all take about the FPU and its interrupt panding.&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/13670/solved-nrf52-sd_app_evt_wait-will-not-go-to-sleep"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/13670/solved-nrf52-sd_app_evt_wait-will-not-go-to-sleep&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;But I try some like&lt;/span&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  // Set bit 7 and bits 4..0 in the mask to one (0x ...00 1001 1111)
  #define FPU_EXCEPTION_MASK 0x0000009F 

      /* Clear exceptions and PendingIRQ from the FPU unit */
      __set_FPSCR(__get_FPSCR()  &amp;amp; ~(FPU_EXCEPTION_MASK));      
      (void) __get_FPSCR();
      NVIC_ClearPendingIRQ(FPU_IRQn);&lt;br /&gt;before &lt;br /&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;error_code = sd_app_evt_wait();&lt;/code&gt;&lt;br /&gt;but didn&amp;#39;t help.&lt;br /&gt;What could be the problem?&lt;br /&gt;Regards&lt;br /&gt;Bar.&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&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;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_pwr_mgmt_run() with SoftDevice not go to low power</title><link>https://devzone.nordicsemi.com/thread/261720?ContentTypeID=1</link><pubDate>Mon, 27 Jul 2020 08:03:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5246422d-5e10-4cee-98b4-cbfe77040f78</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Sorry for the confusion, you&amp;#39;re absolutely correct. Does it go to the WFE() inside the sd_app_evt_wait()?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_pwr_mgmt_run() with SoftDevice not go to low power</title><link>https://devzone.nordicsemi.com/thread/261684?ContentTypeID=1</link><pubDate>Sun, 26 Jul 2020 07:07:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cbb67b8f-6e8e-46cc-820c-f45ea6c2970c</guid><dc:creator>Bar</dc:creator><description>&lt;p&gt;Hi Jored.&lt;/p&gt;
&lt;p&gt;It doesn&amp;#39;t stop there because I enable the BLE and the softdevice define &lt;strong&gt;SOFTDEVICE_PRESENT&lt;/strong&gt;. So it go &lt;strong&gt;to&amp;nbsp;sd_app_evt_wait()&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Look at the code.&lt;/p&gt;
&lt;p&gt;// Wait for an event.&lt;br /&gt;#ifdef &lt;strong&gt;SOFTDEVICE_PRESENT&lt;/strong&gt;&lt;br /&gt; if (nrf_sdh_is_enabled())&lt;br /&gt; {&lt;br /&gt; ret_code_t ret_code = sd_app_evt_wait();&lt;br /&gt; ASSERT((ret_code == NRF_SUCCESS) || (ret_code == NRF_ERROR_SOFTDEVICE_NOT_ENABLED));&lt;br /&gt; UNUSED_VARIABLE(ret_code);&lt;br /&gt; }&lt;br /&gt; else&lt;br /&gt;#endif // SOFTDEVICE_PRESENT&lt;br /&gt; {&lt;br /&gt; // Wait for an event.&lt;br /&gt; __WFE();&lt;br /&gt; // Clear the internal event register.&lt;br /&gt; __SEV();&lt;br /&gt; __WFE();&lt;br /&gt; }&lt;/p&gt;
&lt;p&gt;As I see it when it use BLE with SOFTDEVICE and it is enable it should go there.&lt;/p&gt;
&lt;p&gt;Is there a problem about it?&lt;/p&gt;
&lt;p&gt;Bar.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_pwr_mgmt_run() with SoftDevice not go to low power</title><link>https://devzone.nordicsemi.com/thread/261519?ContentTypeID=1</link><pubDate>Fri, 24 Jul 2020 07:56:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ccd0361-9490-499b-8c2f-375aac9e39ca</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Use a debugger and set a breakpoint inside nrf_pwr_mgmt_run() at line 359 and see if the program hits the breakpoint.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_pwr_mgmt_run() with SoftDevice not go to low power</title><link>https://devzone.nordicsemi.com/thread/261180?ContentTypeID=1</link><pubDate>Wed, 22 Jul 2020 11:43:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9824763d-8200-4a1a-8ffb-af84b99deb63</guid><dc:creator>Bar</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Jared.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I use my own board where I have a peripheral&amp;nbsp;that take extra power. With __WFI() I get 2ma. With&amp;nbsp;nrf_pwr_mgmt_run()&amp;nbsp; I get about 8ma.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The relevant code is as follow&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;#if ((OS_VIEW_IFSELECT != OS_VIEW_IF_JLINK) &amp;amp;&amp;amp; (OS_DEBUG == 0))
        if (IdleTicks &amp;gt; 2) // nothing to do wait for interrupt at run time
		{
			// Switch CPU into sleep mode
			nrf_pwr_mgmt_run();
		}

#endif&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nrf_pwr_mgmt_run() with SoftDevice not go to low power</title><link>https://devzone.nordicsemi.com/thread/261178?ContentTypeID=1</link><pubDate>Wed, 22 Jul 2020 11:26:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c21bcf84-a1cb-40f4-a1ae-011ce7bd4402</guid><dc:creator>Jared</dc:creator><description>&lt;p&gt;Hi,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;How are you determining that the device doesn&amp;#39;t go into sleep and are you using a custom board?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please provide more information regarding your application such as code.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;best regards&lt;/p&gt;
&lt;p&gt;Jared&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>