<?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>Power Consumption Issue</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/49194/power-consumption-issue</link><description>I have inherited some code that is production after doing some extensive testing on battery life have noticed that after writing to the flash my power consumption on the Nordic Power profilier increases from approx 20 micro amps to 3 milli Amps, this</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 02 Jul 2019 15:07:27 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/49194/power-consumption-issue" /><item><title>RE: Power Consumption Issue</title><link>https://devzone.nordicsemi.com/thread/196051?ContentTypeID=1</link><pubDate>Tue, 02 Jul 2019 15:07:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f5bd63f-6ee6-4f3f-a51d-b5702468fe31</guid><dc:creator>bjorn-spockeli</dc:creator><description>[quote user="NordJus"]The code checks that the flash operation has returned NRF_SUCCESS, The code&amp;nbsp;waits for an interrupt from the&amp;nbsp;Softdevice and makes then calls sd_evt_get to check the interrupt.&amp;nbsp; Once completed the code performs the next write operation, or completes the write operation.[/quote]
&lt;p&gt;&amp;nbsp;You should only have to add an event handler to the&amp;nbsp;sys_evt_dispatch() function in main.c, which forwards all system events to the different software modules. See the attached snippet&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void ble_advertising_on_sys_evt(uint32_t sys_evt)
{
    uint32_t err_code = NRF_SUCCESS;
    switch (sys_evt)
    {

        case NRF_EVT_FLASH_OPERATION_SUCCESS:
        // Fall through.

        //When a flash operation finishes, advertising no longer needs to be pending.
        case NRF_EVT_FLASH_OPERATION_ERROR:
            if (m_advertising_start_pending)
            {
                m_advertising_start_pending = false;
                err_code = ble_advertising_start(m_adv_mode_current);
                if ((err_code != NRF_SUCCESS) &amp;amp;&amp;amp; (m_error_handler != NULL))
                {
                    m_error_handler(err_code);
                }
            }
            break;

        default:
            // No implementation needed.
            break;
    }
}


/**@brief Function for dispatching a system event to interested modules.
 *
 * @details This function is called from the System event interrupt handler after a system
 *          event has been received.
 *
 * @param[in] sys_evt  System stack event.
 */
static void sys_evt_dispatch(uint32_t sys_evt)
{
    pstorage_sys_event_handler(sys_evt);
    ble_advertising_on_sys_evt(sys_evt);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You can also check if the nRF52 is not going to its low power mode by checking if teh&amp;nbsp;sd_app_evt_wait() function which is called in the main while loop returns immediately on every call.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void power_manage(void)
{
    uint32_t err_code = sd_app_evt_wait();
    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You could for instance toggle a GPIO pin before and after the&amp;nbsp;&lt;span&gt;sd_app_evt_wait() call and look at the state of the GPIO through a logic analyzer or oscilloscope. If it always returns immediately, then there is probably a pending interrupt that is not cleared.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Bjørn&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Power Consumption Issue</title><link>https://devzone.nordicsemi.com/thread/196046?ContentTypeID=1</link><pubDate>Tue, 02 Jul 2019 14:46:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a173ca9a-6664-4606-8dca-265df8ba4517</guid><dc:creator>NordJus</dc:creator><description>&lt;p&gt;&lt;em&gt;Are only calling&amp;nbsp;sd_flash_write() once at start-up or is&amp;nbsp;sd_flash_write() called anywhere else in the code?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;The only call to sd_flash_write is when the device is paired with a remote central.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;em&gt;How are you handling the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v2.0.0/group___n_r_f___s_o_c___e_n_u_m_s.html#gga2a3d2f55035ee3173aff0c05465fb648a566ef9d8a97914dd30cd152bdfcd50e6"&gt;NRF_EVT_FLASH_OPERATION_SUCCESS&lt;/a&gt;&amp;nbsp;event? You mentioned that you were polling for the event?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&lt;span&gt;The&amp;nbsp;sd_flash_write() function will return immediately&amp;nbsp;with NRF_SUCCESS if the flash operation has been queued successfully and then you will get the&amp;nbsp;&lt;/span&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v2.0.0/group___n_r_f___s_o_c___e_n_u_m_s.html#gga2a3d2f55035ee3173aff0c05465fb648a566ef9d8a97914dd30cd152bdfcd50e6"&gt;NRF_EVT_FLASH_OPERATION_SUCCESS&lt;/a&gt;&lt;span&gt;&amp;nbsp;event when the operation is done. There is no additional events or callbacks that are invoked.&amp;nbsp;&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The code checks that the flash operation has returned NRF_SUCCESS, The code&amp;nbsp;waits for an interrupt from the&amp;nbsp;Softdevice and makes then calls sd_evt_get to check the interrupt.&amp;nbsp; Once completed the code performs the next write operation, or completes the write operation.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;Have you verified that the device is not stuck in an error handler or in the Hardfault handler when the current consumption goes from 20ua to 3mA? Is the device functional after the current consumption&amp;nbsp;increase, e.g. can you send and receive BLE packets?&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Every hour the product&amp;nbsp;connects to the remote central and immediately disconnects (to test the connection is still working).&amp;nbsp; This is continuing for about 4-6 days successfully until the battery reaches a level that the&amp;nbsp;chip can no longer draw enough current.&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;For testing purposes to investigate this issue I have set the product to perform general non-connectable advertising every 10 seconds.&amp;nbsp; Every 10 minutes this updates the battery level to give me an indication of the current battery level.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;When the battery is removed from the product after the pairing then the connect/disconnect process will continue for currently at least 8 weeks (still units under test).&lt;br /&gt;&lt;br /&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;On a separate line I have changed the code so that after a write operation to allow the watchdog to expire and restart the system this is currently under test to see if this will overcome the issue we are seeing.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Previously has attempt calling&amp;nbsp;sd_nvic_SystemReset and this did not seem to rectify the issue&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Power Consumption Issue</title><link>https://devzone.nordicsemi.com/thread/196041?ContentTypeID=1</link><pubDate>Tue, 02 Jul 2019 14:28:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:029d89bc-6dbb-4949-9ff9-8986e0837684</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Are only calling&amp;nbsp;&lt;span&gt;sd_flash_write() once at start-up or is&amp;nbsp;sd_flash_write() called anywhere else in the code?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;How are you handling the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v2.0.0/group___n_r_f___s_o_c___e_n_u_m_s.html#gga2a3d2f55035ee3173aff0c05465fb648a566ef9d8a97914dd30cd152bdfcd50e6"&gt;NRF_EVT_FLASH_OPERATION_SUCCESS&lt;/a&gt;&lt;span&gt;&amp;nbsp;event? You mentioned that you were polling for the event?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The&amp;nbsp;sd_flash_write() function will return immediately&amp;nbsp;with NRF_SUCCESS if the flash operation has been queued successfully and then you will get the&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v2.0.0/group___n_r_f___s_o_c___e_n_u_m_s.html#gga2a3d2f55035ee3173aff0c05465fb648a566ef9d8a97914dd30cd152bdfcd50e6"&gt;NRF_EVT_FLASH_OPERATION_SUCCESS&lt;/a&gt;&amp;nbsp;event when the operation is done. There is no additional events or callbacks that are invoked.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Have you verified that the device is not stuck in an error handler or in the Hardfault handler when the current consumption goes from 20ua to 3mA? Is the device functional after the current consumption&amp;nbsp;increase, e.g. can you send and receive BLE packets?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;BEst regards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Bjørn&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Power Consumption Issue</title><link>https://devzone.nordicsemi.com/thread/196036?ContentTypeID=1</link><pubDate>Tue, 02 Jul 2019 14:17:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a075595-1779-4360-9725-30d3a2df7297</guid><dc:creator>NordJus</dc:creator><description>&lt;p&gt;Hi Bjorn&lt;br /&gt;&lt;br /&gt;Currently the product is supplied using a AAA battery (1.5V) with a step-up regulator to 3V.&amp;nbsp; I have just checked and the product us&amp;nbsp;using DCDC.&lt;/p&gt;
&lt;p&gt;We are using SDK v11.0.0.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Just to be clear the increased current consumption occurs 20-30 seconds after the write has been completed and will stay in that level&amp;nbsp;onwards (there is no increase after the write has been completed)&lt;/p&gt;
&lt;p&gt;Just removing the sd_flash_write does not show this power increase.&lt;/p&gt;
&lt;p&gt;So performing the same actions in the following:&lt;/p&gt;
&lt;p&gt;1.&amp;nbsp; &amp;nbsp;Start the product and do not store the bluetooth peer address using sd_flash_write - no increase in power consumption at all&lt;br /&gt;2.&amp;nbsp; &amp;nbsp;Start the product and stores the bluetooth peer address uing sd_flash_write - after 30 seconds the power increases to approx 3mA.&lt;br /&gt;&lt;br /&gt;My initial feeling was that some callback /event might be occurring from the Nordic is there anything to check&amp;nbsp;for&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Power Consumption Issue</title><link>https://devzone.nordicsemi.com/thread/196020?ContentTypeID=1</link><pubDate>Tue, 02 Jul 2019 13:31:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:91a499da-f01a-489f-99a3-09b3a35aae8a</guid><dc:creator>bjorn-spockeli</dc:creator><description>&lt;p&gt;Hi NordJus,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have not seen issues where calling the sd_flash- API leads to increased current consumption 20-30 seconds after the call has returned and the&amp;nbsp;&lt;a class="el" href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v6.1.0/group___n_r_f___s_o_c___e_n_u_m_s.html#gga2a3d2f55035ee3173aff0c05465fb648a566ef9d8a97914dd30cd152bdfcd50e6"&gt;NRF_EVT_FLASH_OPERATION_SUCCESS&lt;/a&gt;&lt;span&gt;&amp;nbsp;event has been received.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;If&amp;nbsp;the current consumption still increases after 20-30 after you have reset the chip after calling&amp;nbsp;&lt;span&gt;sd_flash_write(), then there must be something else going on.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Which SDK version are you using? If you are using S132 v2.x.x, then my guess is SDK v11.0.0`?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;3mA is quite a lot of current so that could indicate the CPU is running and not going to idle(i.e. sleep). However, the current consumption numbers only fit if you&amp;#39;re using the DCDC&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;CPU current, running from flash, cache enabled, DCDC 3V&amp;nbsp; &amp;nbsp; &amp;nbsp; 3.7 mA&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Bj&amp;oslash;rn&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Power Consumption Issue</title><link>https://devzone.nordicsemi.com/thread/195686?ContentTypeID=1</link><pubDate>Mon, 01 Jul 2019 13:42:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a398e94f-007e-4714-ab0d-e5a1ca2f8328</guid><dc:creator>NordJus</dc:creator><description>&lt;p&gt;Sorry to add but the other thing that I can see if I remove the batteries until all the power has drained and then re-insert the batteries then the power level stays at 20 uA&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Power Consumption Issue</title><link>https://devzone.nordicsemi.com/thread/195683?ContentTypeID=1</link><pubDate>Mon, 01 Jul 2019 13:40:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:71c2a001-4068-4852-b570-eeec856095bf</guid><dc:creator>NordJus</dc:creator><description>&lt;p&gt;I have attempted to restart the product after notifying that the write been successful.&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Immediately and after 30 seconds this seems to have had no effect&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>