<?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 to detect cause of Reset</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/48446/how-to-detect-cause-of-reset</link><description>Hello, 
 
 I am using nRF52832, SDK_15.3.0, S132 SoftDevice and Segger for flashing the image. I am using ‘ble_app_blinky’. 
 
 1) As per below link, do I need to skip GPIO initialization when chip wakeup from System OFF or even peripheral, ble and other</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 11 Jun 2019 15:22:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/48446/how-to-detect-cause-of-reset" /><item><title>RE: How to detect cause of Reset</title><link>https://devzone.nordicsemi.com/thread/192140?ContentTypeID=1</link><pubDate>Tue, 11 Jun 2019 15:22:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d803c4a2-54cc-43ed-9e1d-548b69d9d1e7</guid><dc:creator>Jimmy Wong</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;You can store the err_code on the flash (particular region) inside the app_error_handler.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://github.com/jimmywong2003/nrf5-debug-save-error-code-flash-app"&gt;https://github.com/jimmywong2003/nrf5-debug-save-error-code-flash-app&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void app_error_save_and_stop(uint32_t id, uint32_t pc, uint32_t info)
{
...
        case NRF_FAULT_ID_SDK_ERROR:
                m_error_data.p_error_info = (error_info_t *)info;
                m_error_data.err_code     = m_error_data.p_error_info-&amp;gt;err_code;
                m_error_data.line_num     = m_error_data.p_error_info-&amp;gt;line_num;
                m_error_data.p_file_name  = m_error_data.p_error_info-&amp;gt;p_file_name;
                path_addr=(uint32_t *)m_error_data.p_error_info-&amp;gt;p_file_name;


                // Erase page:
                flash_page_erase(flash_addr);
                flash_word_write(flash_addr, m_error_data.err_code);
                flash_addr++;
                flash_word_write(flash_addr, m_error_data.line_num);
                flash_addr++;
                for(store_length=0; store_length&amp;lt;1000;)
                {&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;When you print out the reset reason (NRF_POWER-&amp;gt;RESETREAS) after just system power up,&lt;/p&gt;
&lt;p&gt;&lt;img height="224" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1560266385453v1.png" width="481" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;if the reset reason is 0, most likely it is caused by the POR (Power on reset ) or BOR (Burst on reset).&lt;/p&gt;
&lt;p&gt;If it is non-zero value, you can refer to the table as below (inside the Product specification).&lt;/p&gt;
&lt;p&gt;&lt;img height="503" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1560266489340v3.png" width="543" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to detect cause of Reset</title><link>https://devzone.nordicsemi.com/thread/192114?ContentTypeID=1</link><pubDate>Tue, 11 Jun 2019 14:09:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a15bcce-58fc-4aee-973b-6fa68a9b4d98</guid><dc:creator>cbd</dc:creator><description>&lt;p&gt;You&amp;#39;ll certainly need to reinitialise the SoftDevice and your BLE.&lt;/p&gt;
&lt;p&gt;Personally I prefer to run through as much initialisation as possible, but depending on your application there may be things that you skip e.g. GPIO lines that you set to specific states before power off, that you wish to retain their state without interruption on power-up.&lt;/p&gt;
&lt;p&gt;Anything reliant on RAM will need to be initialised on restart from System OFF as its not retained &lt;strong&gt;unless&lt;/strong&gt; you&amp;#39;ve set it to remain powered through use of RAM[n].POWER registers on shutdown.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to detect cause of Reset</title><link>https://devzone.nordicsemi.com/thread/192097?ContentTypeID=1</link><pubDate>Tue, 11 Jun 2019 13:14:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e8d911d-b50a-4c4d-b9d4-eb26759aaf30</guid><dc:creator>beemavishnu</dc:creator><description>&lt;p&gt;Thank you for confirmation.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Also can you please let me know your inputs on above query 1 regarding skipping of initialization.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to detect cause of Reset</title><link>https://devzone.nordicsemi.com/thread/192094?ContentTypeID=1</link><pubDate>Tue, 11 Jun 2019 13:11:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ee5aedb-d0da-48c5-85aa-ccd0f5fe02be</guid><dc:creator>cbd</dc:creator><description>&lt;p&gt;Perhaps it&amp;#39;s because you&amp;#39;re running the reset detection after initialising the SoftDevice.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m running the following as my first lines in main, before any hardware or SoftDevice initialisation without problems:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;    ret_code_t err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();
    NRF_LOG_INFO(&amp;quot;INIT START&amp;quot;);

    int32_t reset_reason = NRF_POWER-&amp;gt;RESETREAS;
    NRF_LOG_INFO(&amp;quot;Reset reason = 0x%08x.\n&amp;quot;, reset_reason);
    NRF_POWER-&amp;gt;RESETREAS = NRF_POWER-&amp;gt;RESETREAS;
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to detect cause of Reset</title><link>https://devzone.nordicsemi.com/thread/192091?ContentTypeID=1</link><pubDate>Tue, 11 Jun 2019 13:04:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e99711db-64d1-4dc8-90f6-cad164148bfb</guid><dc:creator>beemavishnu</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;As shown below, I initialized NRF logging functionality.&lt;/p&gt;
&lt;p&gt;First reset cause is working fine. But if I enable code at last I am getting error messages and code hangs.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Also can you please let me know your inputs on above query 1.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;int main(void)
{
    // Initialize.
    log_init();

    #if 0
    uint32_t u32Reset_reason = NRF_POWER-&amp;gt;RESETREAS;
    NRF_LOG_INFO(&amp;quot;Reset Status1 %x&amp;quot;, u32Reset_reason);
    NRF_POWER-&amp;gt;RESETREAS = NRF_POWER-&amp;gt;RESETREAS; // Clear reset reason by writting 1.
    #endif

    leds_init();
    timers_init();
    buttons_init();
    power_management_init();
    ble_stack_init();
    gap_params_init();
    gatt_init();
    services_init();
    advertising_init();
    conn_params_init();
    
    #if 1
    uint32_t u32Reset_reason = NRF_POWER-&amp;gt;RESETREAS;
    NRF_LOG_INFO(&amp;quot;Reset Status2 %x&amp;quot;, u32Reset_reason);
    NRF_POWER-&amp;gt;RESETREAS = NRF_POWER-&amp;gt;RESETREAS; // Clear reset reason by writting 1.
    #endif

    // Start execution.
    NRF_LOG_INFO(&amp;quot;Blinky example started.&amp;quot;);
    advertising_start();

    // Enter main loop.
    for (;;)
    {
        idle_state_handle();
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks &amp;amp; Regards&lt;/p&gt;
&lt;p&gt;Vishnu Beema&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to detect cause of Reset</title><link>https://devzone.nordicsemi.com/thread/192088?ContentTypeID=1</link><pubDate>Tue, 11 Jun 2019 13:00:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5a12de09-0a0f-46e7-bb37-49a6980d4d41</guid><dc:creator>cbd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I&amp;#39;d recommend that you read the register before doing anything else.&lt;/p&gt;
&lt;p&gt;You can always store the value to then use once you&amp;#39;ve initialised the rest of your system.&lt;/p&gt;
&lt;p&gt;With the code that you&amp;#39;re using above, have you initialised the NRF logging functionality first?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>