<?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>Is there any setting for using WFE();?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/62079/is-there-any-setting-for-using-wfe</link><description>Hi, 
 In my proejct, I am using WFE(); in some while loops because of core low power mode. 
 For example, waiting for time_out flags like codes below. 
 I am wondering if it is helpful to use WFE(); in terms of power consumption and if the example usage</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 11 Jun 2020 21:36:16 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/62079/is-there-any-setting-for-using-wfe" /><item><title>RE: Is there any setting for using WFE();?</title><link>https://devzone.nordicsemi.com/thread/254575?ContentTypeID=1</link><pubDate>Thu, 11 Jun 2020 21:36:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:77bcecfd-bebb-4470-abe7-5511b36b96b7</guid><dc:creator>eleven-x_devteam</dc:creator><description>&lt;p&gt;Thank you for clarifying.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is there any setting for using WFE();?</title><link>https://devzone.nordicsemi.com/thread/254508?ContentTypeID=1</link><pubDate>Thu, 11 Jun 2020 13:17:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:150d71da-be51-430a-a0a0-ffafd0a4b22b</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Yes, you&amp;#39;re thinking right. You should not use the nrf_pwr_mgmt_run() to go to sleep in the middle of operations, but rather when you&amp;#39;d like to go to sleep and stay there until an event wakes it up.&amp;nbsp;&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><item><title>RE: Is there any setting for using WFE();?</title><link>https://devzone.nordicsemi.com/thread/254303?ContentTypeID=1</link><pubDate>Wed, 10 Jun 2020 14:37:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:acf539c6-8156-4f8b-bcda-10d1319f69d1</guid><dc:creator>eleven-x_devteam</dc:creator><description>&lt;p&gt;Sorry I&amp;#39;ll try to give more details for you to understand my question.&lt;/p&gt;
&lt;p&gt;I am using a kind of loop concept to queue jobs and execute them and if there is no job to do then go to sleep.&lt;/p&gt;
&lt;p&gt;Of course, when the device goes to sleep,&amp;nbsp;&lt;span&gt;nrf_pwr_mgmt_run() will be called and it works fine.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;However, my question is about i2c read/write&amp;#39;s while loop to wait for&amp;nbsp;i2c_xfer_done.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;When I use&amp;nbsp;nrf_pwr_mgmt_run() like below and i2c sensor is disconnected, it seems it can&amp;#39;t wake up from nrf_pwr_mgmt_run().&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;And when I send data through UART then it restarts progressing. So I guess i2c_xfer_done can&amp;#39;t be done because h/w is disconnected and no more event to wake up the device so it is stuck there and UART event triggers the device to wake up from&amp;nbsp;nrf_pwr_mgmt_run(). So in this case I think it&amp;#39;s better to use just some delay vs&amp;nbsp;nrf_pwr_mgmt_run() for the while loop.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I just want to make sure if what I am thinking is correct.&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&gt;&lt;span&gt;int&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;i2c_read&lt;/span&gt;&lt;span&gt;(i2c_s&amp;nbsp;*&lt;/span&gt;&lt;span&gt;obj&lt;/span&gt;&lt;span&gt;,&amp;nbsp;&lt;/span&gt;&lt;span&gt;uint8_t&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;devAddr&lt;/span&gt;&lt;span&gt;,&amp;nbsp;&lt;/span&gt;&lt;span&gt;uint8_t&lt;/span&gt;&lt;span&gt;&amp;nbsp;*&lt;/span&gt;&lt;span&gt;data&lt;/span&gt;&lt;span&gt;,&amp;nbsp;&lt;/span&gt;&lt;span&gt;uint8_t&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;length&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;i2c_xfer_done&lt;/span&gt;&lt;span&gt;[&lt;/span&gt;&lt;span&gt;obj&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;instance&lt;/span&gt;&lt;span&gt;]&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span&gt;false&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;int&lt;/span&gt;&lt;span&gt;&amp;nbsp;retry&amp;nbsp;=&amp;nbsp;I2C_RETRY_NUM;&lt;/span&gt;&lt;/div&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;ret_code_t&lt;/span&gt;&lt;span&gt;&amp;nbsp;err_code&amp;nbsp;=&amp;nbsp;&lt;/span&gt;&lt;span&gt;nrf_drv_twi_rx&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;obj&lt;/span&gt;&lt;span&gt;-&amp;gt;&lt;/span&gt;&lt;span&gt;i2c_dev&lt;/span&gt;&lt;span&gt;,&amp;nbsp;devAddr,&amp;nbsp;data,&amp;nbsp;length);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;if&lt;/span&gt;&lt;span&gt;&amp;nbsp;(err_code&amp;nbsp;!=&amp;nbsp;NRFX_SUCCESS)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;debug_verbose&lt;/span&gt;&lt;span&gt;(NON_CRITICAL_ERROR,&amp;nbsp;SENSOR_CONTROL_CATEGORY,&amp;nbsp;&lt;/span&gt;&lt;span&gt;&amp;quot;i2c_read:&amp;nbsp;nrf_drv_twi_init&amp;nbsp;error&lt;/span&gt;&lt;span&gt;\r\n&lt;/span&gt;&lt;span&gt;&amp;quot;&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;while&amp;nbsp;(i2c_xfer_done[obj-&amp;gt;instance]&amp;nbsp;==&amp;nbsp;false&amp;nbsp;&amp;amp;&amp;amp;&amp;nbsp;retry--)&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;nrf_pwr_mgmt_run()&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;if&lt;/span&gt;&lt;span&gt;&amp;nbsp;(retry&amp;nbsp;&amp;lt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;0&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;err_code&amp;nbsp;=&amp;nbsp;NRFX_ERROR_TIMEOUT;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span&gt;return&lt;/span&gt;&lt;span&gt;&amp;nbsp;err_code;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Thanks!&lt;/span&gt;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is there any setting for using WFE();?</title><link>https://devzone.nordicsemi.com/thread/253973?ContentTypeID=1</link><pubDate>Tue, 09 Jun 2020 09:14:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b056313-df58-4b48-a915-6a139b3a22c5</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;How exactly does the application get stuck?&amp;nbsp;It&amp;#39;s entirely up to you if you&amp;#39;d like to use the nrf_pwr_mgmt_run() function or not, but if you just call __WFE, keep in mind that you won&amp;#39;t prepare the device for sleep like the nrf_pwr_mgmt_run() function does (See below for the full function):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void nrf_pwr_mgmt_run(void)
{
    PWR_MGMT_FPU_SLEEP_PREPARE();
    PWR_MGMT_SLEEP_LOCK_ACQUIRE();
    PWR_MGMT_CPU_USAGE_MONITOR_SECTION_ENTER();
    PWR_MGMT_DEBUG_PIN_SET();

    // Wait for an event.
#ifdef SOFTDEVICE_PRESENT
    if (nrf_sdh_is_enabled())
    {
        ret_code_t ret_code = sd_app_evt_wait();
        ASSERT((ret_code == NRF_SUCCESS) || (ret_code == NRF_ERROR_SOFTDEVICE_NOT_ENABLED));
        UNUSED_VARIABLE(ret_code);
    }
    else
#endif // SOFTDEVICE_PRESENT
    {
        // Wait for an event.
        __WFE();
        // Clear the internal event register.
        __SEV();
        __WFE();
    }

    PWR_MGMT_DEBUG_PIN_CLEAR();
    PWR_MGMT_CPU_USAGE_MONITOR_SECTION_EXIT();
    PWR_MGMT_SLEEP_LOCK_RELEASE();
}
&lt;/pre&gt;&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><item><title>RE: Is there any setting for using WFE();?</title><link>https://devzone.nordicsemi.com/thread/253895?ContentTypeID=1</link><pubDate>Mon, 08 Jun 2020 22:45:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:356eb240-4fae-4895-aa2d-7bc533bb69bb</guid><dc:creator>eleven-x_devteam</dc:creator><description>&lt;p&gt;Hi Simon,&lt;/p&gt;
&lt;p&gt;Thank you for your answer.&lt;/p&gt;
&lt;p&gt;I have another question.&lt;/p&gt;
&lt;p&gt;One thing I found that i2c read while loop is stuck before other interrupt happen like uart reading when I change __WFE to&amp;nbsp;&lt;span&gt;nrf_pwr_mgmt_run() If the sensor is not connected. In that case, using just some delay instead&amp;nbsp;nrf_pwr_mgmt_run() should be better, right? Also SPI read /write should be the same?&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.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Is there any setting for using WFE();?</title><link>https://devzone.nordicsemi.com/thread/252990?ContentTypeID=1</link><pubDate>Wed, 03 Jun 2020 12:09:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a19b26f-3073-4e9e-83cc-df4d4adf336a</guid><dc:creator>Simonr</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I would suggest checking out our examples in the SDK which has the nrf_pwr_mgmt_run() function set at the bottom of the main loop (for example the &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/ble_sdk_app_nus_eval.html"&gt;ble_app_uart&lt;/a&gt;, or &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v16.0.0/pwr_mgmt_example.html"&gt;pwr_mgmt &lt;/a&gt;examples), triggering whenever nothing else is going on in the application. This should be a cleaner solution than adding __WFE(); multiple places in your application. nrf_pwr_mgmt_run() will also take care of any necessary preparation tasks. For details on what needs to be prepared when going to sleep, you can check out the nrf_pwr_mgmt_run() function in nrf_pwr_mgmt.c in the SDK.&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><item><title>RE: Is there any setting for using WFE();?</title><link>https://devzone.nordicsemi.com/thread/252858?ContentTypeID=1</link><pubDate>Tue, 02 Jun 2020 22:18:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6abbc4e5-5d5b-4eee-8e13-5c2c879ca707</guid><dc:creator>eleven-x_devteam</dc:creator><description>&lt;p&gt;One more thing, Can use&amp;nbsp; nrf_pwr_mgmt_run() instead of __WFE() in those situation like waiting for timeout.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;There is already device sleep mode code with&amp;nbsp;&lt;span&gt;nrf_pwr_mgmt_run().&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>