<?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 in system ON mode</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/71053/wake-up-from-sleep-in-system-on-mode</link><description>Hi Folks, 
 I am facing an issue while trying to perform a system On suspend procedure with a wake up on HITOLOW event. 
 No event is triggered when button pressed. 
 
 However, when I run nrf_pwr_mgmt_run() within a conditionnal loop (which exit from</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 16 Feb 2021 16:52:10 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/71053/wake-up-from-sleep-in-system-on-mode" /><item><title>RE: Wake up from sleep in system ON mode</title><link>https://devzone.nordicsemi.com/thread/294700?ContentTypeID=1</link><pubDate>Tue, 16 Feb 2021 16:52:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f04f46b-1fae-46f1-a7ee-8dafc2e27fee</guid><dc:creator>Sebastien DRI</dc:creator><description>&lt;p&gt;Hi Jorgen,&lt;/p&gt;
&lt;p&gt;Sorry for the late reply.&lt;/p&gt;
&lt;p&gt;I did not run this code in Debug mode previously. I also ran just upon flashing device.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I must also add that I am not testing on a DK board but a custom one but I can&amp;#39;t find a good explanation for the reason which may cause an exit from LP mode without the while(1) statement.&lt;/p&gt;
&lt;p&gt;I have observed the same phenomena as you when trying to execute in debug mode but no &amp;quot;in_pin_handler&amp;quot; is triggered.&lt;/p&gt;
&lt;p&gt;I will try to test your code on a different board to check if I can reproduce your results.&lt;/p&gt;
&lt;p&gt;Very strange...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up from sleep in system ON mode</title><link>https://devzone.nordicsemi.com/thread/293733?ContentTypeID=1</link><pubDate>Wed, 10 Feb 2021 11:13:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7252f27e-594e-46e0-8c86-e475bf368941</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Sorry for the slow response. I tried to reproduce the described issue with a similar code to yours:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;nrf_gpio.h&amp;quot;
#include &amp;quot;nrfx_gpiote.h&amp;quot;
#include &amp;quot;nrf_pwr_mgmt.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;

volatile bool test = false;
void in_pin_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    test = true;
    nrf_gpio_pin_toggle(15);
}

int main( void )
{ 
  nrf_gpio_cfg_output(13);
  nrf_gpio_cfg_output(14);
  nrf_gpio_cfg_output(15);
  nrf_gpio_pin_set(13);
  nrf_gpio_pin_set(14);
  nrf_gpio_pin_set(15);


  nrf_pwr_mgmt_init();
  uint32_t err_code;
  err_code = nrfx_gpiote_init();
  APP_ERROR_CHECK(err_code);

  nrfx_gpiote_in_config_t in_config = NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(false); // Set low_accu to true to use PORT_EVENT.
  in_config.pull = NRF_GPIO_PIN_PULLUP; //I do have a pull up resistor on that pin
  err_code = nrfx_gpiote_in_init(11, &amp;amp;in_config, in_pin_handler); // in_pin_handler = IN_EVENT
  nrfx_gpiote_in_event_enable(11, true);

  //while(!test) {
                nrf_gpio_pin_clear(13);
		nrf_pwr_mgmt_run();
  //}

  for (;;)
  {
      nrf_gpio_pin_clear(14);
  }

  return 0;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I can see that both LED1 and LED2 on the DK lights up if I flash this application directly from SES, or if I run a debug session, but if I power cycle/reset the board without a debug session, I only see LED1 light up. I assume that the debug interface mode will cause some additional wakes of the chip.&lt;/p&gt;
&lt;p&gt;Did you run in debug mode while testing this? Can you test the attached code on your board?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up from sleep in system ON mode</title><link>https://devzone.nordicsemi.com/thread/291995?ContentTypeID=1</link><pubDate>Fri, 29 Jan 2021 13:02:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e541f272-f6ac-44c2-8973-56cf9197c9e7</guid><dc:creator>Sebastien DRI</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;quot;nrfx_gpiote.h&amp;quot;
#include &amp;quot;nrf_pwr_mgmt.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;

// Weak empty variant initialization function.
// May be redefined by variant files.
void initVariant() __attribute__((weak));
void initVariant() { }

volatile bool test = false;
void in_pin_handler(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
	test = true;
}

int main( void )
{
  //init();
   
  initVariant();

  nrf_delay_ms(100);

#if CFG_SYSVIEW
  //SEGGER_SYSVIEW_Conf();
#endif

#ifdef USE_TINYUSB
  //Adafruit_TinyUSB_Core_init();
  //Serial.begin(115200);
#endif

  //setup();

  nrf_pwr_mgmt_init();
  uint32_t err_code;
  err_code = nrfx_gpiote_init();
  APP_ERROR_CHECK(err_code);

  nrfx_gpiote_in_config_t in_config = NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(false); // Set low_accu to true to use PORT_EVENT.
  //in_config.pull = NRF_GPIO_PIN_PULLUP; //I do have a pull up resistor on that pin
  err_code = nrfx_gpiote_in_init(g_ADigitalPinMap[PIN_nMAG_SNS], &amp;amp;in_config, in_pin_handler); // in_pin_handler = IN_EVENT
  nrfx_gpiote_in_event_enable(g_ADigitalPinMap[PIN_nMAG_SNS], true);

  //while(!test) {
		nrf_pwr_mgmt_run();
  //}

  while(1); //Normal Run loop

  for (;;)
  {
    loop();
    tud_task(); // tinyusb device tasks
    if (serialEventRun) serialEventRun();
  }

  return 0;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Thank you Jorgen for your fast answer.&lt;/p&gt;
&lt;p&gt;The above code snippet does not work since I can reach directly the while(1) line meaning something might&amp;nbsp;have caused an exit from system ON mode.&lt;/p&gt;
&lt;p&gt;When I uncomment the while(!test) brackets&amp;nbsp;, it work perfectly and I only reach the while(1) line when a wake up port event is triggered.&lt;/p&gt;
&lt;p&gt;I must add I manually check that no Wake up event has happened (oscillo + IO for testing within interrupt handler) and I ran this code without debugging.&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Wake up from sleep in system ON mode</title><link>https://devzone.nordicsemi.com/thread/291942?ContentTypeID=1</link><pubDate>Fri, 29 Jan 2021 09:50:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e9ef468-862a-4c35-90b1-ab81d40e412f</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;If the chip wakes to check the conditional loop, it sounds like the event is at least waking the chip from System ON mode. This should be the same for both cases, however, there could be some issues with the triggering of the interrupt/event handler.&lt;/p&gt;
&lt;p&gt;Can you post the code snippets for the configuration of the GPIO(TE) and both the working and the non-working loop options?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>