<?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 handle watchdog reset flag in application code?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/97429/how-to-handle-watchdog-reset-flag-in-application-code</link><description>Hello, 
 I have been working on a custom PCB powered by the nRF52832 microcontroller. It has custom bootloader, softdevice s132 and application code present on board, since we need the custom bootloader to perform OTA updates to the controller. We have</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 10 Mar 2023 06:00:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/97429/how-to-handle-watchdog-reset-flag-in-application-code" /><item><title>RE: How to handle watchdog reset flag in application code?</title><link>https://devzone.nordicsemi.com/thread/414522?ContentTypeID=1</link><pubDate>Fri, 10 Mar 2023 06:00:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c7321f5-4b78-41b9-b347-b92748df24a9</guid><dc:creator>Aashyk</dc:creator><description>&lt;p&gt;Solution for this problem is using NRF_POWER-&amp;gt;GPREGRET register in the bootloader when watchdog reset flag is set in the NRF_POWER-&amp;gt;RESETREAS register. This works since the NVIC_systemreset() doesn&amp;#39;t reset the GPREGRET register. The documentation on which registers get reset when NVIC_systemreset() is called would be very&amp;nbsp;helpful for future&amp;nbsp;reference.&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;pre class="ui-code" data-mode="c_cpp"&gt;int reset_reason = NRF_POWER-&amp;gt;RESETREAS;
if (reset_reason &amp;amp; (1UL &amp;lt;&amp;lt; 1)) { // 2nd bit for watchdog reset and 3rd bit for softreset
 // The watchdog timer caused the reset
 NRF_POWER-&amp;gt;GPREGRET = 0x10; //Custom magic number chosen for watch dog reset
}&lt;/pre&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>