<?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>Feed watchdog in Zephyr idle thread</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/106855/feed-watchdog-in-zephyr-idle-thread</link><description>Hi all, 
 Is there any way to use the Zephyr idle thread to feed the watchdog? I do that with freeRTOS and is an elegant way to feed the watchdog. 
 The other way is to create a task with a very low priority (just one step above the idle thread priority</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 09 Jan 2024 11:55:46 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/106855/feed-watchdog-in-zephyr-idle-thread" /><item><title>RE: Feed watchdog in Zephyr idle thread</title><link>https://devzone.nordicsemi.com/thread/463338?ContentTypeID=1</link><pubDate>Tue, 09 Jan 2024 11:55:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e4e187ee-8c7d-47b3-891d-9eb69c8d5394</guid><dc:creator>Learner</dc:creator><description>&lt;p&gt;Thank you Pedro for your response.&lt;/p&gt;
&lt;p&gt;Understood.&lt;/p&gt;
&lt;p&gt;My second comment was about the WDT CRV register size (32 bits).&amp;nbsp;This will allow&amp;nbsp;the absolute maximum WDT timeout&amp;nbsp;to be set to 131071 seconds&amp;nbsp;i.e.&amp;nbsp;36.4 hours.&lt;/p&gt;
&lt;div&gt;Kind regards&lt;/div&gt;
&lt;div&gt;Mohamed&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Feed watchdog in Zephyr idle thread</title><link>https://devzone.nordicsemi.com/thread/463276?ContentTypeID=1</link><pubDate>Tue, 09 Jan 2024 07:47:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:153612d4-d8c1-4b67-89d1-ab7a045db900</guid><dc:creator>Pedro</dc:creator><description>&lt;p&gt;Hi Mohamed,&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;WDT_MAX_WINDOW&amp;nbsp;&lt;/strong&gt;defines the WDT window time, in ms, i.e. the maximum time WDT can be without feeding it. In my example, if WDT is more than 10000ms without feeding, it triggers a reset.&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Pedro.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Feed watchdog in Zephyr idle thread</title><link>https://devzone.nordicsemi.com/thread/462760?ContentTypeID=1</link><pubDate>Thu, 04 Jan 2024 16:15:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2752045a-92a1-4fda-b3f1-bd7bb12bf4f7</guid><dc:creator>Learner</dc:creator><description>&lt;p&gt;Thank you Pedro.&lt;/p&gt;
&lt;p&gt;Much appreciated.&lt;/p&gt;
&lt;p&gt;Am I right in assuming&amp;nbsp;&lt;strong&gt;#define WDT_MAX_WINDOW&amp;nbsp; 10000U&lt;/strong&gt; is in [ms] i.e. the maximum timeout is 10 seconds? This is not the absolute maximum timeout period.&lt;/p&gt;
&lt;p&gt;I&amp;nbsp;believe&amp;nbsp;the absolute maximum timeout period allowed is dictated by the size of the CRV register which is 0xFFFFFFFF * 32768 seconds.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards&lt;/p&gt;
&lt;p&gt;Mohamed&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Feed watchdog in Zephyr idle thread</title><link>https://devzone.nordicsemi.com/thread/462740?ContentTypeID=1</link><pubDate>Thu, 04 Jan 2024 14:59:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5cc50049-23df-4fc6-9ed2-bf0d20a45b4c</guid><dc:creator>Pedro</dc:creator><description>&lt;p&gt;Hi Mohamed,&lt;/p&gt;
&lt;p&gt;Yes, I&amp;#39;m using hardware watchdog.&lt;/p&gt;
&lt;p&gt;Use this for reference:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;drivers/watchdog.h&amp;gt;
#include &amp;lt;logging/log.h&amp;gt;

#define WDT_MAX_WINDOW  10000U

LOG_MODULE_REGISTER(wdt);

static const struct device *wdt = DEVICE_DT_GET(DT_NODELABEL(wdt0));
static int wdt_channel_id;

int wdt_wdtSetup() {
	int err;

	if (!device_is_ready(wdt) || wdt == NULL)
	{
		LOG_WRN(&amp;quot;Watchdog not ready&amp;quot;);
		return -EIO;
	}

	struct wdt_timeout_cfg wdt_config = {
	    /* Reset SoC when watchdog timer expires. */
	    .flags = WDT_FLAG_RESET_SOC,

	    /* Expire watchdog after max window */
	    .window.min = 0U,
	    .window.max = WDT_MAX_WINDOW};

	wdt_channel_id = wdt_install_timeout(wdt, &amp;amp;wdt_config);
	if (wdt_channel_id &amp;lt; 0)
	{
		LOG_ERR(&amp;quot;Watchdog install error.&amp;quot;);
		return wdt_channel_id;
	}

	err = wdt_setup(wdt, WDT_OPT_PAUSE_HALTED_BY_DBG);
	if (err)
	{
		LOG_ERR(&amp;quot;Watchdog setup error&amp;quot;);
		return err;
	}

	return 0;
}

void wdt_wdtFeed() {
	wdt_feed(wdt, wdt_channel_id);
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Remember to enable wdt in prj.conf&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;CONFIG_WATCHDOG=y
CONFIG_WDT_LOG_LEVEL_DBG=y
CONFIG_WDT_DISABLE_AT_BOOT=n&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;Pedro.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Feed watchdog in Zephyr idle thread</title><link>https://devzone.nordicsemi.com/thread/462579?ContentTypeID=1</link><pubDate>Wed, 03 Jan 2024 16:58:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:042fd0df-8da7-40e4-860a-4fa19d2c49a9</guid><dc:creator>Learner</dc:creator><description>&lt;p&gt;Hi Pedro,&lt;/p&gt;
&lt;p&gt;Are you using the hardware watchdog ?&lt;/p&gt;
&lt;p&gt;I am looking for examples on how to configure it and use it to prevent lock-ups.&lt;/p&gt;
&lt;p&gt;All the examples I found were about task_watchdog.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;zephyr\samples\drivers\watchdog&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;zephyr\samples\subsys\task_wdt&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Thank you.&lt;/p&gt;
&lt;p&gt;Kind regards&lt;/p&gt;
&lt;p&gt;Mohamed&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Feed watchdog in Zephyr idle thread</title><link>https://devzone.nordicsemi.com/thread/462460?ContentTypeID=1</link><pubDate>Wed, 03 Jan 2024 10:42:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f8f6c746-62a7-48dc-b8d2-39e7088890a4</guid><dc:creator>Pedro</dc:creator><description>&lt;p&gt;Thank you Terje!&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I will take your advices.&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Pedro.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Feed watchdog in Zephyr idle thread</title><link>https://devzone.nordicsemi.com/thread/461623?ContentTypeID=1</link><pubDate>Fri, 22 Dec 2023 17:08:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:98996e1a-aea3-4420-af04-9479ebadb19b</guid><dc:creator>tesc</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The idle thread in Zephyr does nothing, so no, you cannot use that one for feeding the watchdog.&lt;/p&gt;
&lt;p&gt;You could do it from a very low priority thread (as you suggest), or from main, or signal from other threads to main and do it in main whenever you get the signals, or use another scheme.&lt;/p&gt;
&lt;p&gt;The important thing when using watchdogs, is to use them in a way which is useful for your use case. Typically that means signaling (or feeding) from the processes that should not freeze, and in such a way that even only one such process freezing would trigger the watchdog reset.&lt;/p&gt;
&lt;p&gt;Regards,&lt;br /&gt;Terje&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>