<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to determine which task triggered watchdog timeout? in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-determine-which-task-triggered-watchdog-timeout/m-p/398867#M13378</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That looks useful for determining what happened after the fact, but is there a more consistent way for the running firmware to detect which watchdog timer expired? I suppose I could force it by having a different interrupt function for each task I'm using Watchdog with rather than a generic one. But I'm definitely running into issues where a watchdog expires sometime when a short delay or something is occurring, and mqx_idle_task gets attributed with the expiry and is reset. In the meantime I went with a more scotched earth policy of just rebooting the whole device instead of trying to reset specific tasks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 02 Dec 2015 15:29:48 GMT</pubDate>
    <dc:creator>ironsean</dc:creator>
    <dc:date>2015-12-02T15:29:48Z</dc:date>
    <item>
      <title>How to determine which task triggered watchdog timeout?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-determine-which-task-triggered-watchdog-timeout/m-p/398865#M13376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I'm using MQX 4.2 and CodeWarrior 10.6.4 with a Freescale FRDM K64F development board. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I recently implemented watchdog timers in several of my tasks in my firmware, but am running into an issue determining which task caused the timer to expire.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I based my implementation on a combination of this example (&lt;A href="https://community.nxp.com/thread/318809" rel="nofollow noopener noreferrer" target="_blank"&gt;MQX Watchdogs for Multiple Tasks&lt;/A&gt; ) and the MQX watchdog example application. However, it seems that even &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/DavidS" rel="nofollow noopener noreferrer" target="_blank"&gt;DavidS&lt;/A&gt;​ might be uncertain which method is best for determining the task which caused the timer expiry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14448548980061221" data-renderedposition="197_8_882_48" jivemacro_uid="_14448548980061221" modifiedtitle="true"&gt;&lt;P&gt;printf("\nWatchdog expired for task: 0x%P", td_ptr);&lt;/P&gt;&lt;P&gt;printf("\nTask Index = %x", ((_mqx_uint *)td_ptr)[3]); //DES added increment td_ptr address to point to TASK_ID&lt;/P&gt;&lt;P&gt;printf("\nTask Index = %x", _task_get_id()); //DES added&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I settled with the _task_get_id() method, but it seems to fail in certain situations. For instance, if a task somehow delays or blocks and then the watchdog timer expires, that expiry gets attributed to the MQX_Idle_task. I've also had the timer expire during a socket operation and get attributed to the TCP/IP task. This doesn't work well with my watchdog implementation which does the following:&lt;/P&gt;&lt;P&gt;1) reads the task_id of the expired task.&lt;BR /&gt;2) sets a variable to that task ID so it can be reset by the main task.&lt;BR /&gt;3) log the error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14448553943564016 jive_text_macro" data-renderedposition="434_8_882_304" jivemacro_uid="_14448553943564016"&gt;&lt;P&gt;void handle_watchdog_expiry(void&amp;nbsp;&amp;nbsp; *td_ptr)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;uint32_t error_data[2];&lt;/P&gt;&lt;P&gt;printf("\nTask Index = %x", _task_get_id()); //DES added&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Watchdog_resets++;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (watchdog_resets &amp;gt; 5 || _task_get_id() == 0x10003 ) //check if main task, as that will lock all&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;SCB_AIRCR = SCB_AIRCR_VECTKEY(0x5FA) | SCB_AIRCR_SYSRESETREQ_MASK; &lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;expired_task = _task_get_id();&lt;/P&gt;&lt;P&gt;error_data[0] = _task_get_id();&lt;/P&gt;&lt;P&gt;error_data[1] = ETC_WATCHDOG_RESET_TASK;&lt;/P&gt;&lt;P&gt;_lwmsgq_send(error_log, error_data, 0);&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Which causes the main task to reset the expired task (or resets the full system if the main task is the one to fail the watchdog timer)&lt;/P&gt;&lt;PRE __default_attr="c++" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14448554718029415" data-renderedposition="780_8_882_96" jivemacro_uid="_14448554718029415"&gt;&lt;P&gt;if (expired_task != MQX_NULL_TASK_ID)&lt;/P&gt;&lt;P&gt;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp; _task_restart(expired_task, NULL, FALSE);&lt;/P&gt;&lt;P&gt;&amp;nbsp; expired_task = MQX_NULL_TASK_ID;&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; _time_delay(150);&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is, when the task is read as the idle task, or the TCP/IP task, the main task can't restart it properly, nor restart the actual problem task. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So my question is this:&lt;/P&gt;&lt;P&gt;Is there a better way to determine which task's watchdog timer expired in a generic watchdog handling ISR?&lt;/P&gt;&lt;P&gt;Or should I change it so each task has a task specific ISR which is set as each task sets up the watchdog timer, bypassing any reading of the current task.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sean&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Oct 2015 20:47:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-determine-which-task-triggered-watchdog-timeout/m-p/398865#M13376</guid>
      <dc:creator>ironsean</dc:creator>
      <dc:date>2015-10-14T20:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine which task triggered watchdog timeout?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-determine-which-task-triggered-watchdog-timeout/m-p/398866#M13377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Sean,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could use the KLOG. &lt;/P&gt;&lt;P&gt;Information taken from the MQXUG.pdf&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kernel Log&lt;/P&gt;&lt;P&gt;Kernel log lets an application log any combination of:&lt;/P&gt;&lt;P&gt;• Function entry and exit information for all calls to MQX functions.&lt;/P&gt;&lt;P&gt;• Function entry and exit information for specific function calls.&lt;/P&gt;&lt;P&gt;• Context switches.&lt;/P&gt;&lt;P&gt;• Interrupts.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You may take a look at it. Please let me now if that helps.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;/P&gt;&lt;P&gt;Sol &lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 20 Oct 2015 23:16:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-determine-which-task-triggered-watchdog-timeout/m-p/398866#M13377</guid>
      <dc:creator>soledad</dc:creator>
      <dc:date>2015-10-20T23:16:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to determine which task triggered watchdog timeout?</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-determine-which-task-triggered-watchdog-timeout/m-p/398867#M13378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That looks useful for determining what happened after the fact, but is there a more consistent way for the running firmware to detect which watchdog timer expired? I suppose I could force it by having a different interrupt function for each task I'm using Watchdog with rather than a generic one. But I'm definitely running into issues where a watchdog expires sometime when a short delay or something is occurring, and mqx_idle_task gets attributed with the expiry and is reset. In the meantime I went with a more scotched earth policy of just rebooting the whole device instead of trying to reset specific tasks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Dec 2015 15:29:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/How-to-determine-which-task-triggered-watchdog-timeout/m-p/398867#M13378</guid>
      <dc:creator>ironsean</dc:creator>
      <dc:date>2015-12-02T15:29:48Z</dc:date>
    </item>
  </channel>
</rss>

