<?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>Watchdog Timer Implementation</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/71624/watchdog-timer-implementation</link><description>Hello, 
 I am transmitting 1 byte BLE data across a central and peripheral and the central does other things like control PWM, sample SAADC (scan mode), GPIO pins interrupts etc. I need to ensure that my application is not stuck while doing any of those</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 03 Mar 2021 14:17:38 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/71624/watchdog-timer-implementation" /><item><title>RE: Watchdog Timer Implementation</title><link>https://devzone.nordicsemi.com/thread/297553?ContentTypeID=1</link><pubDate>Wed, 03 Mar 2021 14:17:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8946c4e-71ec-4e86-8d4b-62603fdb4a05</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Yes, as mentioned at the page you linked: &amp;quot;An interrupt at priority level&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span&gt;&lt;span&gt;0&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;sets up and performs the flash activity. The CPU is halted for most of the time in this interrupt&amp;quot;.&lt;/p&gt;
&lt;p&gt;Note that 90ms is the maximum time for a page erase. When I have tested this, I have seen typical times in the range of 2-3 ms for a flash page erase operation to complete.&lt;/p&gt;
&lt;p&gt;Whenever the softdevice is enabled, all flash write/erase operations needs to go through the softdevice. The softdevice will schedule flash access according to the priorities described on &lt;a href="https://infocenter.nordicsemi.com/topic/sds_s132/SDS/s1xx/multilink_scheduling/priorities_and_events_intro.html"&gt;this page&lt;/a&gt;. Performing flash access directly when softdevice is enabled will most likely cause an assert, as the CPU is halted during the operation, preventing the softdevice from handling its timing-critical tasks. FDS runs on top of Fstorage, which have &lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.0.2/lib_fstorage.html#lib_fstorage_backends"&gt;separate backends for use with and without softdevice&lt;/a&gt;. The Fstorage softdevice backend will use the softdevice flash API for flash operations.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Watchdog Timer Implementation</title><link>https://devzone.nordicsemi.com/thread/297488?ContentTypeID=1</link><pubDate>Wed, 03 Mar 2021 12:21:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2d30716b-b7e5-4730-9b3f-36cec199fd95</guid><dc:creator>Charan</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fsds_s132%2FSDS%2Fs1xx%2Fprocessor_avail_interrupt_latency%2Fprocessor_usage_patterns.html&amp;amp;cp=4_7_3_0_15_2"&gt;In this website&lt;/a&gt;, its written that interrupt processing when erasing a flash page is 90ms. Does that mean that the control will be with the softdevice for the whole 90ms?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Moreover, when is this used? Peer manager uses the fds library right?? So, when will the softdevice use the flash. For storing bond information??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Watchdog Timer Implementation</title><link>https://devzone.nordicsemi.com/thread/295812?ContentTypeID=1</link><pubDate>Tue, 23 Feb 2021 11:58:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c71911cf-dd5e-4c09-ad19-e051e445cb77</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Yes, that should be fine.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Watchdog Timer Implementation</title><link>https://devzone.nordicsemi.com/thread/295807?ContentTypeID=1</link><pubDate>Tue, 23 Feb 2021 11:37:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:657c24cc-36f1-4e97-b6c9-924c2be7121d</guid><dc:creator>Charan</dc:creator><description>&lt;p&gt;Ok, I read in the forums that if I have any code in main() and call&amp;nbsp;nrf_pwr_mgmt_run(), the code inside main() will execute for every event. Now if kick the dog inside main itself, that should suffice right?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Watchdog Timer Implementation</title><link>https://devzone.nordicsemi.com/thread/295384?ContentTypeID=1</link><pubDate>Fri, 19 Feb 2021 15:03:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8199ce95-3392-4f12-a610-ecc7f2f294ff</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;You need to put an endless loop inside main(). If you do not do this, the CPU will continue executing random code from flash until it crashes.&lt;/p&gt;
&lt;p&gt;The loop can be used to execute tasks when other tasks are idel, or you can put the CPU into sleep (System ON mode) to save power.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Watchdog Timer Implementation</title><link>https://devzone.nordicsemi.com/thread/295355?ContentTypeID=1</link><pubDate>Fri, 19 Feb 2021 13:43:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a2427fd8-26b9-4b9a-a8aa-7c02d7404ff8</guid><dc:creator>Charan</dc:creator><description>&lt;p&gt;Ok, I got the idea now. And if I am not wrong, the main() will only be executed once whenever the CPU wakes up right?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Watchdog Timer Implementation</title><link>https://devzone.nordicsemi.com/thread/295285?ContentTypeID=1</link><pubDate>Fri, 19 Feb 2021 10:06:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6e36270b-d090-47b4-94ee-65e0f9b428c9</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;There is no problem with feeding the watchdog in interrupt context if you only want to prevent lockups in higher priority interrupt tasks. The problem first arises if you get a lockup in main thread or an interrupt context with lower priority than where you feed the watchdog.&lt;/p&gt;
&lt;p&gt;Lets say that you decide to feed the watchdog using app_timer, and you run app timer at priority 5. If you now get a lockup in a handler running at priority 0-5, the app_timer interrupt will not be able to run, as you are already stuck in a higher priority interrupt. This will lead to a watchdog timeout and will trigger a reset. If you get a lockup at priority 6-7, or in the main thread, the app_timer interrupt will preempt the execution of the thread where the lockup happens, to feed the watchdog. Since the watchdog is feed as normal, you will not get a watchdog timeout, and the watchdog is therefore ineffective for the lower priority tasks.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Watchdog Timer Implementation</title><link>https://devzone.nordicsemi.com/thread/295262?ContentTypeID=1</link><pubDate>Fri, 19 Feb 2021 07:33:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8a0b666-a41a-4155-87c3-6cf08e6697b5</guid><dc:creator>Charan</dc:creator><description>[quote userid="14926" url="~/f/nordic-q-a/71624/watchdog-timer-implementation/295020#295020"]Why would you need additional Watchdog for the event handlers if you also have a system-level watchdog running?[/quote]
&lt;p&gt;I wanted to monitor each and every event handler separately but yes, as you said that would be redundant given that I have a system level timer. Although, why should I set a flag and trigger in main() for a system-level watchdog. Suppose, I directly kick the dog in the timer handler and if midway through that particular timer_handler() softdevice interrupts, once the softdevice is done with it&amp;#39;s execution, wouldn&amp;#39;t it come back to that timer_event handler and finish it&amp;#39;s process??&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Watchdog Timer Implementation</title><link>https://devzone.nordicsemi.com/thread/295020?ContentTypeID=1</link><pubDate>Thu, 18 Feb 2021 09:17:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f4980d07-9c19-4a75-8ee2-52b9f076fa6f</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;No, there is only a single&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/wdt.html?cp=4_2_0_39#concept_ywz_4xw_sr"&gt;Watchdog timer&lt;/a&gt;&amp;nbsp;instance available in the chip. Why would you need additional Watchdog for the event handlers if you also have a system-level watchdog running?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Watchdog Timer Implementation</title><link>https://devzone.nordicsemi.com/thread/294985?ContentTypeID=1</link><pubDate>Thu, 18 Feb 2021 07:30:36 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:75741c90-37fc-4aad-8052-fa926d9f0f7b</guid><dc:creator>Charan</dc:creator><description>&lt;p&gt;Hmm Ok&lt;/p&gt;
&lt;p&gt;Is it possible to create two watchdog timer, one for every event handler and one which is in system level (so that softdevice isn&amp;#39;t stuck).&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Watchdog Timer Implementation</title><link>https://devzone.nordicsemi.com/thread/294562?ContentTypeID=1</link><pubDate>Tue, 16 Feb 2021 09:36:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:053d207f-b374-4336-80bc-b4800301410c</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;&lt;span&gt;Yes, using app_timer or a separate RTC instance should work.To make sure that the watchdog prevents lockups at any interrupt priority, you can set a flag in the RTC/app_timer handler (which runs in interrupt context) and kick the dog in the main loop if the flag is set.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Watchdog Timer Implementation</title><link>https://devzone.nordicsemi.com/thread/294561?ContentTypeID=1</link><pubDate>Tue, 16 Feb 2021 09:35:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d753cee-35ed-4e83-b7a0-30aef86740c4</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Yes, using app_timer or a separate RTC instance should work.To make sure that the watchdog prevents lockups at any interrupt priority, you can set a flag in the RTC/app_timer handler (which runs in interrupt context) and kick the dog in the main loop if the flag is set.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Watchdog Timer Implementation</title><link>https://devzone.nordicsemi.com/thread/294518?ContentTypeID=1</link><pubDate>Tue, 16 Feb 2021 06:07:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8015c4b4-42b7-45df-b6f7-7c19ffce5d17</guid><dc:creator>Charan</dc:creator><description>&lt;p&gt;Thanks Jorgen for your answer&lt;/p&gt;
&lt;p&gt;I just have a follow up question. Although right now it&amp;#39;s not needed for my project but if it&amp;#39;s needed, how do I implement a system level watchdog? Should I use app_timer() and kick the dog or is there any other method?&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Watchdog Timer Implementation</title><link>https://devzone.nordicsemi.com/thread/294454?ContentTypeID=1</link><pubDate>Mon, 15 Feb 2021 16:50:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:26c60d99-8bd3-426e-9aaf-476b39da0a76</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Your suggested solution sounds fine to me, if you do not need system-level watchdog, but only cares about certain interrupts/functions/tasks. The softdevice will have the highest priority in your application, so you will always have to account for the softdevice interrupts when calculating/measuring the maximum worst-case delay for the Watchdog timeout.&amp;nbsp;You can find the timing specifications for softdevice interrupts in&amp;nbsp;&lt;a title="Processor usage patterns and availability" href="https://infocenter.nordicsemi.com/topic/sds_s132/SDS/s1xx/processor_avail_interrupt_latency/processor_usage_patterns.html?cp=4_7_3_0_15_2"&gt;Processor usage patterns and availability&lt;/a&gt;&amp;nbsp;in the softdevice specifications.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Jørgen&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>