<?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>How do we know which interrupt resulted in wakeup?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/69590/how-do-we-know-which-interrupt-resulted-in-wakeup</link><description>I want my system to sleep for some time, but its waking up and I am unable to understand which interrupt occurred. I want to know which interrupt caused the system to wake up. can u tell me a way to do so?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 17 Dec 2020 16:01:14 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/69590/how-do-we-know-which-interrupt-resulted-in-wakeup" /><item><title>RE: How do we know which interrupt resulted in wakeup?</title><link>https://devzone.nordicsemi.com/thread/285693?ContentTypeID=1</link><pubDate>Thu, 17 Dec 2020 16:01:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:872bd55c-c82f-4acd-bb06-2b2e9de76f8e</guid><dc:creator>Vidar Berg</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;You may try to do something like shown in the snippet below if it&amp;#39;s just for debugging.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static void idle_state_handle(void)
{
    ret_code_t err_code;
    static int pending_irq = -1;

    err_code = nrf_ble_lesc_request_handler();
    APP_ERROR_CHECK(err_code);

    if (NRF_LOG_PROCESS() == false)
    {
        
        CRITICAL_REGION_ENTER();
        nrf_pwr_mgmt_run();
        /* Check which interrupt is pending. Will not work properly if there are more than one pending */
        for (uint32_t i = POWER_CLOCK_IRQn; i &amp;lt;= FPU_IRQn; i++)
        {
            if (NVIC_GetPendingIRQ(i))
            {
                pending_irq = i; // Look up irq number in nrf52.h to find the IRQ source.
            }
        }
        CRITICAL_REGION_EXIT();

        if (pending_irq != -1)
        { 
            NRF_LOG_INFO (&amp;quot;Pending IRQ number: %d&amp;quot;, pending_irq);
            pending_irq = -1;
        }

        
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>