<?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>GPIOTE Port event triggered by the state of the pin, not an edge change.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/31298/gpiote-port-event-triggered-by-the-state-of-the-pin-not-an-edge-change</link><description>Hi, 
 
 I put my NRF52 to sleep (POWER OFF mode) and configure it to wake on GPIO port event like so: 
 
 
 This GPIO is set up on a reed switch. Occasionally, the NRF52 will try to sleep whilst the magnet is resting next to the reed switch. I.e REED_SWITCH_PIN</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 13 Mar 2018 15:40:25 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/31298/gpiote-port-event-triggered-by-the-state-of-the-pin-not-an-edge-change" /><item><title>RE: GPIOTE Port event triggered by the state of the pin, not an edge change.</title><link>https://devzone.nordicsemi.com/thread/124210?ContentTypeID=1</link><pubDate>Tue, 13 Mar 2018 15:40:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f0179ef-1189-495a-8dd7-97105515e394</guid><dc:creator>cirlam</dc:creator><description>&lt;p&gt;Yes, it could be kept both low and high whilst sleeping, but wanted to wake up only when&amp;nbsp;transitioning from high to low.&lt;/p&gt;
&lt;p&gt;I.e if the reed switch was already low&amp;nbsp;when entering sleep, I was expecting it to stay asleep until the reed switch has gone high (still asleep at this stage) and then gone low (high-&amp;gt;low transition waking the device up).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;However, your final suggestion does provide an acceptable solution (embarrassed I missed such a nice and simple fix!). Thank you for the help.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIOTE Port event triggered by the state of the pin, not an edge change.</title><link>https://devzone.nordicsemi.com/thread/124198?ContentTypeID=1</link><pubDate>Tue, 13 Mar 2018 14:50:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:21ce0fd5-8cdb-4221-8387-6fb4b25d591e</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;I&amp;nbsp;think may have misunderstood the requirement for this.&amp;nbsp;I assumed the REED input would always be kept low in system OFF. Could it also be kept high? In that case you must change the sense configuration based on pin state before entering system off. E.g., if pin is low, sense should be configured to sense for high level.&amp;nbsp;The sense mechanism can detect transition from high to low, or low to high, but not both (toggling).&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIOTE Port event triggered by the state of the pin, not an edge change.</title><link>https://devzone.nordicsemi.com/thread/124172?ContentTypeID=1</link><pubDate>Tue, 13 Mar 2018 13:19:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95802526-db06-4efa-8466-6378d5959cdf</guid><dc:creator>cirlam</dc:creator><description>&lt;p&gt;I have solved the issue of PIN 20 being latched incorrectly by making PIN&amp;nbsp;20 use a GPIOTE IN event&amp;nbsp;all the time, and REED_SWITCH_PIN (13) using the PORT event all the time.&lt;/p&gt;
&lt;p&gt;Now with a breakpoint on sd_power_system_off, everything looks normal - all PIN_CNF values are 0x00000002 or 0x00000003 with the exception of the REED_SWITCH_PIN which is 0x00030000.&lt;/p&gt;
&lt;p&gt;Latch registers when sleeping with the REED_SWITCH_PIN pulled high (by the external pullup)&amp;nbsp;are all clear.&lt;/p&gt;
&lt;p&gt;Latch registers when sleeping with the REED_SWITCH_PIN pulled steady state low indicate PIN13 is latched (as expected I think?).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The behaviour in the main question remains unfortunately.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIOTE Port event triggered by the state of the pin, not an edge change.</title><link>https://devzone.nordicsemi.com/thread/124145?ContentTypeID=1</link><pubDate>Tue, 13 Mar 2018 11:27:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7d0ff254-f91d-4cdf-bb05-edfb2c331e36</guid><dc:creator>cirlam</dc:creator><description>&lt;p&gt;I have checked the NRF_GPIO-&amp;gt;PIN_CNF[n] registers &amp;nbsp;- all are either configured as inputs (0x00000002) or outputs (0x00000003), apart from pin 13 (REED_SWITCH_PIN) which is 0x00030000 as expected.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;However, I noticed in the Latch register, PIN 20 is latched (nothing else is).&lt;/p&gt;
&lt;p&gt;Pin 20 is an interrupt pin from an accelerometer. At the start of the program this is enabled as a PORT event, but then disabled as below, before trying to sleep.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void turn_off_sensors(void) {
  nrf_drv_gpiote_in_event_disable(ACC_INT_PIN_1);
  nrf_drv_gpiote_in_uninit(ACC_INT_PIN_1);

  writeAccReg(LIS3DH_CTRL_REG1, 0x0F); //enter Accelerometer power down state
  while ((!acc_spi_xfer_done)) {
    power_manage();
  }

  nrf_drv_spi_uninit(&amp;amp;acc_spi);

  nrf_gpio_pin_clear(ACC_POWER_PIN);
  nrf_gpio_pin_clear(ACC_SS_PIN);

  nrf_gpio_cfg_default(ACC_INT_PIN_1);
  nrf_gpio_cfg_default(ACC_INT_PIN_2);
  nrf_gpio_cfg_default(ACC_SCK_PIN);
  nrf_gpio_cfg_default(ACC_MOSI_PIN);
  nrf_gpio_cfg_default(ACC_MISO_PIN);

  SEGGER_RTT_printf(0, &amp;quot;Sensors Off\n\r&amp;quot;);
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIOTE Port event triggered by the state of the pin, not an edge change.</title><link>https://devzone.nordicsemi.com/thread/124134?ContentTypeID=1</link><pubDate>Tue, 13 Mar 2018 11:03:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c233c271-49e5-420a-9afb-73433fa1a977</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;The GPIOTE module is&amp;nbsp;powered down in system OFF mode, but pin configurations are retained. To narrow down the problem I suggest to go through the pin configurations to make sure that only wake up pin is configured with sense enabled. One way of doing this is to place a breakpoint at the line where&amp;nbsp;sd_power_system_off(); is called, then read out the NRF_GPIO-&amp;gt;PIN_CNF[n] registers.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Peripheral viewer in Keil (From menu tab: View -&amp;gt;System Viewer -&amp;gt; P0)&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-8aff1c35e72942e7a5bbbd7f2e2f0e3a/pastedimage1520938899153v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIOTE Port event triggered by the state of the pin, not an edge change.</title><link>https://devzone.nordicsemi.com/thread/124121?ContentTypeID=1</link><pubDate>Tue, 13 Mar 2018 10:19:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e45ed6c-b59b-488d-b616-ca06fafe7e45</guid><dc:creator>cirlam</dc:creator><description>&lt;p&gt;Thanks for the quick response!&lt;/p&gt;
&lt;p&gt;After changing to your suggested code, the result is the same. The external pull up is a fixed resistor and PCB has been continuity checked, so I am pretty&amp;nbsp;confident it is not a hardware issue.&amp;nbsp;The problem in my question above occurs when the REED_SWITCH_PIN is shorted to ground, so the external pull up isn&amp;#39;t having any effect at this time.&lt;/p&gt;
&lt;p&gt;Earlier in the program, before I sleep the device, the REED_SWITCH_PIN is configured as a GPIOTE interrupt (In event, not port). I enable this at the very start of the program, and then before trying to sleep I disable this interrupt&amp;nbsp;and use the code in my original question. The code I use to enable/disable is below.&lt;/p&gt;
&lt;p&gt;Is it possible that the previous use&amp;nbsp;is causing problems?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void init_reed_switch(void) {
  uint32_t err_code;
  nrf_drv_gpiote_in_config_t in_config = GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
  in_config.pull = NRF_GPIO_PIN_NOPULL;
  err_code = nrf_drv_gpiote_in_init(REED_SWITCH_PIN, &amp;amp;in_config, reed_switch_handler);
  APP_ERROR_CHECK(err_code);
  nrf_drv_gpiote_in_event_enable(REED_SWITCH_PIN, true);
}

static void disable_reed_switch(void) {
  nrf_drv_gpiote_in_event_disable(REED_SWITCH_PIN);
  nrf_drv_gpiote_in_uninit(REED_SWITCH_PIN);
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: GPIOTE Port event triggered by the state of the pin, not an edge change.</title><link>https://devzone.nordicsemi.com/thread/123692?ContentTypeID=1</link><pubDate>Fri, 09 Mar 2018 13:32:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:989a79e2-0021-4e5d-ba23-194b7ca42d31</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The chip will wake up from system OFF if a level change is detected on a GPIO, so the chip should no wake up if the level is kept steady. Also note that the wake-up mechanism does not use the GPIOTE block, but is connected directly to the SENSE signal from the GPIO block.&lt;/p&gt;
&lt;p&gt;Please try the following and see if you get the same result:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;        /*Pins that are not needed in system OFF should be configured to reset state
          to avoid leakage currents and unexpected wakeups.*/
        nrf_gpio_cfg_default(PIN_x);
        nrf_gpio_cfg_default(PIN_y);
        ...
        
        /* Configure wakeup pin*/
        nrf_gpio_cfg_sense_input(WAKE_UP_PIN,
                                 NRF_GPIO_PIN_NOPULL, // Apply pull if input can become floating
                                 NRF_GPIO_PIN_SENSE_HIGH);
        sd_power_system_off(); // NOTE: chip will enter emulated system OFF if chip is in debug interface mode. &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Is the external pull up on the&amp;nbsp;REED_SWITCH_PIN input enabled when the device is in system OFF? I&amp;#39;m wondering if the input could be floating.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>