<?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 interrupt cannot wake sd_app_evt_wait?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/24053/gpiote-interrupt-cannot-wake-sd_app_evt_wait</link><description>I have tried to use sd_app_evt_wait() to sleep cpu, and use gpiote interrupt to wake up cpu from sleep.
However, gpiote interrupt cannot wake up cpu.
When I use __WFE(), gpiote interrupt can wake up cpu.
And even if I use sd_app_evt_wait(), log print</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 21 Aug 2017 14:01:50 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/24053/gpiote-interrupt-cannot-wake-sd_app_evt_wait" /><item><title>RE: gpiote interrupt cannot wake sd_app_evt_wait?</title><link>https://devzone.nordicsemi.com/thread/94700?ContentTypeID=1</link><pubDate>Mon, 21 Aug 2017 14:01:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8689f38-0580-40a0-9d1b-a2b04a77ef9a</guid><dc:creator>Haruki Kawakami</dc:creator><description>&lt;p&gt;I tried &lt;code&gt;volatile&lt;/code&gt;, and it works well!!
Still it is strange why __WFE() works well without volatile.
I cannot understand compiler behavior. Can you explain?
Anyway, thank you for your answer!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: gpiote interrupt cannot wake sd_app_evt_wait?</title><link>https://devzone.nordicsemi.com/thread/94699?ContentTypeID=1</link><pubDate>Mon, 21 Aug 2017 13:13:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0e29ecf4-b43f-49cf-b731-1b730886cba1</guid><dc:creator>Turbo J</dc:creator><description>&lt;p&gt;You forgot the C optimizer:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;volatile int s_is_resp_ready;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Without the &lt;code&gt;volatile&lt;/code&gt;, the optimizer will replace the&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;while(!s_is_resp_ready)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;with an unconditional loop. Look at the disassembly if you can.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: gpiote interrupt cannot wake sd_app_evt_wait?</title><link>https://devzone.nordicsemi.com/thread/94698?ContentTypeID=1</link><pubDate>Mon, 21 Aug 2017 11:10:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cad488fe-fdfc-4c1a-b77c-917bbfadfe75</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Haruki&lt;/p&gt;
&lt;p&gt;I tested the code with the ble_app_uart example, and I had no issues getting the GPIOTE interrupt to work, also when using sd_app_evt_wait().&lt;/p&gt;
&lt;p&gt;I made some minor changes to the code, to use the button 4 input for testing, but otherwise it is pretty much the same:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static void sf_gpiote_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
    printf(&amp;quot;gpiote interrupt\r\n&amp;quot;);
     //s_is_resp_ready = true;
}


static void gpiote_init()
{
     /* config interrupt */
    nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_HITOLO(false);
    config.pull = NRF_GPIO_PIN_PULLUP;

    if(!nrf_drv_gpiote_is_init())
        nrf_drv_gpiote_init();

    nrf_drv_gpiote_in_init(BSP_BUTTON_3, &amp;amp;config, sf_gpiote_handler);
    nrf_drv_gpiote_in_event_enable(BSP_BUTTON_3, true);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If the log is delayed it could be because you are using the log library in deferred mode?
In this mode the printing will be delayed until NRF_LOG_PROCESS() is called.&lt;/p&gt;
&lt;p&gt;Do you have a scope available?&lt;br /&gt;
Then you could try to toggle an output pin in the interrupt instead, and look on the scope if the pin is toggled after the input changes.&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: gpiote interrupt cannot wake sd_app_evt_wait?</title><link>https://devzone.nordicsemi.com/thread/94697?ContentTypeID=1</link><pubDate>Wed, 16 Aug 2017 01:20:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64cf47d2-4936-40b8-b1f6-2d01dcac3d40</guid><dc:creator>Haruki Kawakami</dc:creator><description>&lt;p&gt;code is like below.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    /* config interrupt */
    nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_HITOLO(false);

    if(!nrf_drv_gpiote_is_init())
        nrf_drv_gpiote_init();

    nrf_drv_gpiote_in_init(INT_N, &amp;amp;config, sf_gpiote_handler);
    nrf_drv_gpiote_in_event_enable(INT_N, true);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;is this collect?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: gpiote interrupt cannot wake sd_app_evt_wait?</title><link>https://devzone.nordicsemi.com/thread/94696?ContentTypeID=1</link><pubDate>Fri, 04 Aug 2017 09:02:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:69ef82d5-bc97-49c4-980e-f85d01db432d</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Can you show me the code used to initialize the GPIOTE channel?&lt;/p&gt;
&lt;p&gt;sd_app_evt_wait() is using WFE under the hood, so there shouldn&amp;#39;t be a big difference between the two, except sd_app_evt_wait() is running the recommended sleep sequence:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;__WFE();
__SEV();
__WFE();
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If you only run __WFE(); once then you might not go to sleep at all, if there is already an event pending.&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>