<?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>Wake up from sleep mode</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/34486/wake-up-from-sleep-mode</link><description>Hello, 
 
 
 I want to use ble_app_uart example. I&amp;#39;m usign nRF52832 with nRF5_SDK v15. I need to put the MCU in sleep mode. I can do that. When the MCU awakes from sleep, I do not want to run the BLE stack directly. I will make some measurements and then</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 12 Nov 2018 09:59:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/34486/wake-up-from-sleep-mode" /><item><title>RE: Wake up from sleep mode</title><link>https://devzone.nordicsemi.com/thread/156838?ContentTypeID=1</link><pubDate>Mon, 12 Nov 2018 09:59:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6cbafc44-349c-4835-9612-4a6880973f44</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I can&amp;#39;t find any question from you, what do you need help with?&lt;/p&gt;
&lt;p&gt;Unless it&amp;#39;s directly related to the old case I would suggest you open a new question about it, it makes it much easier to track.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up from sleep mode</title><link>https://devzone.nordicsemi.com/thread/156623?ContentTypeID=1</link><pubDate>Fri, 09 Nov 2018 09:48:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2772c79b-deda-435b-8c03-af310e3fdef7</guid><dc:creator>ps_anu</dc:creator><description>&lt;p&gt;hi.....avrebekk can you help me&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up from sleep mode</title><link>https://devzone.nordicsemi.com/thread/156622?ContentTypeID=1</link><pubDate>Fri, 09 Nov 2018 09:47:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3f00a8c9-3d2a-4c79-9937-65194c388fbe</guid><dc:creator>ps_anu</dc:creator><description>&lt;p&gt;hi..... avrebekk . i need help&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up from sleep mode</title><link>https://devzone.nordicsemi.com/thread/134559?ContentTypeID=1</link><pubDate>Mon, 04 Jun 2018 12:35:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:29c96507-5dd3-4b6e-899d-064782340ca8</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Then the issue is probably related to Richard Moldovan&amp;#39;s reply.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Since you don&amp;#39;t reset the RESETREAS register one of the flags might be remaining, and the next time you wake up the incorrect code block is run.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;For simplicity you should probably just clear the register in the sleep_mode_enter() function, so you don&amp;#39;t need to do it explicitly every place where you enter sleep mode.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up from sleep mode</title><link>https://devzone.nordicsemi.com/thread/134294?ContentTypeID=1</link><pubDate>Fri, 01 Jun 2018 08:31:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f61389be-0038-4783-8d31-1f2e169ea88f</guid><dc:creator>enkavak</dc:creator><description>&lt;p&gt;yes, it is.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up from sleep mode</title><link>https://devzone.nordicsemi.com/thread/134288?ContentTypeID=1</link><pubDate>Fri, 01 Jun 2018 08:10:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3eb46df-9a67-429c-87d4-51ddf7b23287</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;So are you saying that the only difference between the working and non working code is the following line at line 8 of your example?&lt;/p&gt;
&lt;p&gt;&lt;code&gt;NRF_POWER-&amp;gt;RESETREAS = 0xffffffff;&lt;/code&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up from sleep mode</title><link>https://devzone.nordicsemi.com/thread/133336?ContentTypeID=1</link><pubDate>Fri, 25 May 2018 06:31:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4088b9f-cca6-406a-ac92-2cbc13d326f6</guid><dc:creator>enkavak</dc:creator><description>&lt;p&gt;Nothing has changed even if I put&amp;nbsp;&lt;strong&gt;sleep_mode_enter();&lt;/strong&gt; in the else condition.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up from sleep mode</title><link>https://devzone.nordicsemi.com/thread/133279?ContentTypeID=1</link><pubDate>Thu, 24 May 2018 14:14:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d5c5446-190a-4ad2-9e8a-4d588764cb62</guid><dc:creator>AmbystomaLabs</dc:creator><description>&lt;p&gt;With RESETREAS it is always better to do a bit pattern compare with an AND.&amp;nbsp; Resetreas accumulates flags until a power cycle.&amp;nbsp; You could inadvertently have a spare flag set that would cause your equal statement to fail.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up from sleep mode</title><link>https://devzone.nordicsemi.com/thread/133276?ContentTypeID=1</link><pubDate>Thu, 24 May 2018 14:04:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a718f364-9cdd-4d4f-89e8-1f37c2416ccc</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Not directly answering your question, but be aware that sometimes RESETREAS is not what you might expect. An example is if you are using the reset pin and the device is programmed while debugging with an erase-program cycle. The SystemInit() function in particular can issue a soft reset which can affect RESETREAS and puzzled me for a while, particularly as I was also switch NFC pins toGPIO which issued effectively two extra reset (NFC pins then Reset pin)&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    /* Configure GPIO pads as pPin Reset pin if Pin Reset capabilities desired. If CONFIG_GPIO_AS_PINRESET is not
      defined, pin reset will not be available. One GPIO (see Product Specification to see which one) will then be
      reserved for PinReset and not available as normal GPIO. */
    #if defined (CONFIG_GPIO_AS_PINRESET)
        if (((NRF_UICR-&amp;gt;PSELRESET[0] &amp;amp; UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected &amp;lt;&amp;lt; UICR_PSELRESET_CONNECT_Pos)) ||
            ((NRF_UICR-&amp;gt;PSELRESET[1] &amp;amp; UICR_PSELRESET_CONNECT_Msk) != (UICR_PSELRESET_CONNECT_Connected &amp;lt;&amp;lt; UICR_PSELRESET_CONNECT_Pos))){
            NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Wen &amp;lt;&amp;lt; NVMC_CONFIG_WEN_Pos; // Write Enable
            while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy){}
            NRF_UICR-&amp;gt;PSELRESET[0] = 21;
            while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy){}
            NRF_UICR-&amp;gt;PSELRESET[1] = 21;
            while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy){}
            NRF_NVMC-&amp;gt;CONFIG = NVMC_CONFIG_WEN_Ren &amp;lt;&amp;lt; NVMC_CONFIG_WEN_Pos; // Read-only Enable
            while (NRF_NVMC-&amp;gt;READY == NVMC_READY_READY_Busy){}
            // UICR changes require a reset to be effective
            NVIC_SystemReset();
        }
    #endif
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up from sleep mode</title><link>https://devzone.nordicsemi.com/thread/133193?ContentTypeID=1</link><pubDate>Thu, 24 May 2018 10:28:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75991a5d-b779-402f-aec8-54924ec8a0b1</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Thanks for the code.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It confirms that your code will get stuck if you leave the else {} clause, since you are left in the for(;;) loop forever without ever entering system OFF again. The only way to return to the top of main then is to perform a power or pin reset.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up from sleep mode</title><link>https://devzone.nordicsemi.com/thread/132952?ContentTypeID=1</link><pubDate>Wed, 23 May 2018 10:23:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3df4d70e-d934-4f22-8142-46c71229e285</guid><dc:creator>enkavak</dc:creator><description>&lt;p&gt;you can find my full code below.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;
static void init_ble(void)
{
    ble_stack_init();
    gap_params_init();
    gatt_init();
    services_init();
    advertising_init();
    conn_params_init();
    advertising_start();
}


int main(void)
{
    bool erase_bonds;

    uart_init();
    log_init();
    timers_init();
    buttons_leds_init(&amp;amp;erase_bonds);
    power_management_init();


    reset_reason = NRF_POWER-&amp;gt;RESETREAS;
    printf(&amp;quot;0x%08x\r\n&amp;quot;,reset_reason );

    if(reset_reason == 0x00080000)          // NFC Wake up
    {
      init_ble();
      initBLEflag = 1;
      while(1);
      
    }
    else if(reset_reason == 0x00010000)     // GPIO Wake up
    {
      initBLEflag = 0;
      nrf_gpio_pin_clear(19);
      NRF_POWER-&amp;gt;RESETREAS = 0xffffffff;
      sleep_mode_enter();
    }
    else
    {
        NRF_POWER-&amp;gt;RESETREAS = 0xffffffff;
    }
    
    for (;;)
    {
        nrf_delay_ms(1);
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up from sleep mode</title><link>https://devzone.nordicsemi.com/thread/132950?ContentTypeID=1</link><pubDate>Wed, 23 May 2018 10:19:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ec11df3-62d2-4c80-8d41-7e40d988ba12</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;It&amp;#39;s a bit hard to know exactly why the last one works and not the first, without seeing the rest of the code, but I would have to assume it is caused by the missing sleep_mode_enter() call in the else {} clause.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I assume sleep_mode_enter() enables system OFF sleep mode, and if the code is allowed to exit the else{} clause instead of entering system OFF then the program flow might be broken (impossible to say for sure without seeing what happens after the if/else).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up from sleep mode</title><link>https://devzone.nordicsemi.com/thread/132762?ContentTypeID=1</link><pubDate>Tue, 22 May 2018 12:32:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bf6c902f-3918-4bf1-9268-bf750e381326</guid><dc:creator>enkavak</dc:creator><description>&lt;p&gt;Hello&amp;nbsp;&lt;span&gt;Torbj&amp;oslash;rn&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;We are designing a very low power circuit Which will be sleeping most of the time. The device will wake up with 2 triggering event occurs and then start advertising for communication via BLE. The triggering events are NFC and GPIO. In fact, We only need to advertise When the NFC wakes up the MCU. When GPIO wakes up the MCU, MCU will only do some measurement and go to sleep again. I think that I can explain the working principle of my design.&lt;/p&gt;
&lt;p&gt;I have an experimental code one works and the other not. Could you please say that Why the is not working does not work ?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Not Working&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    reset_reason = NRF_POWER-&amp;gt;RESETREAS;
    printf(&amp;quot;0x%08x\r\n&amp;quot;,reset_reason );

    if(reset_reason == 0x00080000)          // NFC Wake up
    {
      init_ble();
      initBLEflag = 1;
      NRF_POWER-&amp;gt;RESETREAS = 0xffffffff;
      while(1);
      
    }
    else if(reset_reason == 0x00010000)     // GPIO Wake up
    {
      initBLEflag = 0;
      nrf_gpio_pin_clear(19);
      NRF_POWER-&amp;gt;RESETREAS = 0xffffffff;
      sleep_mode_enter();
    }
    else
    {
        NRF_POWER-&amp;gt;RESETREAS = 0xffffffff;
        sleep_mode_enter();
    }&lt;/pre&gt;&amp;nbsp; &amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Working&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;    reset_reason = NRF_POWER-&amp;gt;RESETREAS;
    printf(&amp;quot;0x%08x\r\n&amp;quot;,reset_reason );

    if(reset_reason == 0x00080000)          // NFC Wake up
    {
      init_ble();
      initBLEflag = 1;
      while(1);
      
    }
    else if(reset_reason == 0x00010000)     // GPIO Wake up
    {
      initBLEflag = 0;
      nrf_gpio_pin_clear(19);
      NRF_POWER-&amp;gt;RESETREAS = 0xffffffff;
      sleep_mode_enter();
    }
    else
    {
        NRF_POWER-&amp;gt;RESETREAS = 0xffffffff;
    }&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up from sleep mode</title><link>https://devzone.nordicsemi.com/thread/132740?ContentTypeID=1</link><pubDate>Tue, 22 May 2018 12:00:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e9ae4314-704f-4af4-8500-278b48810aa3</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;If you configure an app_timer callback you will be woken up at regular intervals, so that you can make your measurements, do some calculations, or whatever else you need to do, independently of what the BLE stack is doing.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The BLE stack will have it&amp;#39;s own internal events that will wake up the CPU when the BLE stack needs it, but this is invisible to the application (until the BLE stack sends an event that you need to process).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t know what you mean about only running the BLE stack when you need to. If the BLE stack is advertising, or in a BLE connection, it will need to run the MCU at regular intervals to keep the connection/advertising running.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up from sleep mode</title><link>https://devzone.nordicsemi.com/thread/132460?ContentTypeID=1</link><pubDate>Fri, 18 May 2018 05:34:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b7ac0dff-4aa1-4770-a876-2b4e9ddf33bd</guid><dc:creator>enkavak</dc:creator><description>&lt;p&gt;Any idea ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>