<?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: S32K146 WDOG_EWM_IRQHandler in S32K</title>
    <link>https://community.nxp.com/t5/S32K/S32K146-WDOG-EWM-IRQHandler/m-p/2260419#M55315</link>
    <description>&lt;P&gt;Hopefully this explanation below will help others.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the example code; it helped a lot.&amp;nbsp;&lt;SPAN&gt;My handler code was being executed but the debugger does not halt at a breakpoint in the&amp;nbsp;WDOG_EWM_IRQHandler. I think this is down to the way the WDOG resets the CPU after the 128 bus cycles that the debugger cannot prevent.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The example code is difficult to see working since the IRQ handler toggles an LED rapidly for about 4ms and then the reset happens so the LED turns off.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have modified the example code (after changing S32K144 references to S32K146) to add some variables. Inserting a breakpoint at the start of Reset_Handler, i.e. before C variables are initialised allowed me to see the values that these variables reached after the previous CPU reset.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I changed RCM_WSDOG_INT to 0 (so the code uses&amp;nbsp;WDOG_EWM_IRQHandler and not&amp;nbsp;RCM_IRQHandler).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I added the following variables at the top of main.c&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;int wdog_called;
int wdog_cs;
int wdog_detected;
int wdog_loop;

int main_loop;&lt;/LI-CODE&gt;&lt;P&gt;I modified the "WDOG_EWM_IRQHandler" function (my additions start with /**/ comment)&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void WDOG_EWM_IRQHandler(void)
{
/**/wdog_called++;
/**/wdog_cs = WDOG-&amp;gt;CS;
    if(WDOG-&amp;gt;CS &amp;amp; 0x4000)           // [14] FLG Watchdog Interrupt Flag
    {
/**/    wdog_detected++;
        // WDOG-&amp;gt;CS |= 0x4000;      // Clear the flag
        while(1)
        {
/**/        wdog_loop++;
            PTD-&amp;gt;PTOR |= (1 &amp;lt;&amp;lt; 15); // Toggle RED LED until reset
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;I modified the "main" function (my additions start with /**/ comment)&lt;/P&gt;&lt;LI-CODE lang="c"&gt;...
    while(1)
    {
/**/    main_loop++;
    }
...&lt;/LI-CODE&gt;&lt;P&gt;I then set the breakpoint on the start of the&amp;nbsp;&lt;SPAN&gt;Reset_Handler function&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I then programmed the dev board and it stopped at "main" (part of the debug configuration settings)&lt;/P&gt;&lt;P&gt;I created watch expressions for my variables&lt;/P&gt;&lt;P&gt;I then pressed F8 (run) and the debugger halted at Reset_Handler at which point I could see the following values&lt;/P&gt;&lt;LI-CODE lang="c"&gt;wdog_called   int 1
wdog_cs       int 0x65e0 (Hex)
wdog_detected int 1
wdog_loop     int 142
main_loop     int 2096993&lt;/LI-CODE&gt;&lt;P&gt;This was the proof that&amp;nbsp;WDOG_EWM_IRQHandler was being called. Note 0x65e0 includes 0x4000 (the FLG bit)&lt;/P&gt;&lt;P&gt;I then put a breakpoint on the "wdog_detected++;" line and ran again&lt;/P&gt;&lt;P&gt;The debugger halted at Reset_Handler and I got the following values&lt;/P&gt;&lt;LI-CODE lang="c"&gt;wdog_called   int 1	
wdog_cs       int 0x65e0 (Hex)	
wdog_detected int 0	
wdog_loop     int 0	
main_loop     int 2097011	&lt;/LI-CODE&gt;&lt;P&gt;This was the proof that&amp;nbsp;WDOG_EWM_IRQHandler was being called and that the debugger tried to stop at the "wdog_detected++;" line but could not get control of the CPU before the WDOG reset the CPU. This failure to stop at any breakpoint in&amp;nbsp;WDOG_EWM_IRQHandler was why I originally thought it was not executing&amp;nbsp;my&amp;nbsp;WDOG_EWM_IRQHandler.&lt;/P&gt;</description>
    <pubDate>Thu, 11 Dec 2025 17:33:25 GMT</pubDate>
    <dc:creator>DarrenD</dc:creator>
    <dc:date>2025-12-11T17:33:25Z</dc:date>
    <item>
      <title>S32K146 WDOG_EWM_IRQHandler</title>
      <link>https://community.nxp.com/t5/S32K/S32K146-WDOG-EWM-IRQHandler/m-p/2259327#M55282</link>
      <description>&lt;P&gt;How do I enable the WDOG_EWM_IRQHandler?&lt;/P&gt;&lt;P&gt;I thought I only needed to set WDOG.CS[INT] = 1 and enable NVIC entry 22 (WDOG_EWM_IRQn) to force a call to WDOG_EWM_IRQHandler whenever WDOG.CNT reaches WDOG.TOVAL to allow me to do some tidy up code before the CPU resets 128 bus clock cycles later. This comes from reading 23.1.4 Watchdog Timeout Reaction&lt;/P&gt;&lt;P&gt;I am using an S32K146EVB-Q144 dev board running at 80MHz&lt;/P&gt;&lt;P&gt;My WDOG settings are (21us watchdog using 8MHz SIRC)&lt;BR /&gt;WDOG.WIN = 0&lt;BR /&gt;WDOG.TOVAL = 168&lt;BR /&gt;WDOG.CS = 0x27E0 (UPDATE=1, INT=1, EN=1, CLK=3, RCS=1, CMD32EN=1)&lt;/P&gt;&lt;P&gt;My NVIC settings are&lt;BR /&gt;S32_NVIC.ISER[0] = 0x0040_0000 (bit 22 set)&lt;BR /&gt;S32_NVIC.ISPR[0] = 0x0000_0000&lt;BR /&gt;S32_NVIC.IP[22] = 16 (priority = 1)&lt;/P&gt;&lt;P&gt;I have interrupts enabled&lt;BR /&gt;General Regsiters -&amp;gt; primask = 0&lt;BR /&gt;General Regsiters -&amp;gt; basepri = 0&lt;/P&gt;&lt;P&gt;I have my void WDOG_EWM_IRQHandler(void) code written with a breakpoint on the first line of code&lt;/P&gt;&lt;P&gt;I ran some wait loop code while WDOG.CNT &amp;lt; 160 and then stopped at a breakpoint. I then single-stepped on a few instructions via the OpenSDA debugger on my dev board and monitor WDOG.CNT incrementing towards 168 (I saw 166) and then it reset to Reset_Handler. I do not see WDOG.CS change to show FLG=1, nor the interrupt firing&lt;/P&gt;&lt;P&gt;What am I missing?&lt;BR /&gt;Thanks&lt;BR /&gt;Darren&lt;/P&gt;</description>
      <pubDate>Wed, 10 Dec 2025 15:25:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K146-WDOG-EWM-IRQHandler/m-p/2259327#M55282</guid>
      <dc:creator>DarrenD</dc:creator>
      <dc:date>2025-12-10T15:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: S32K146 WDOG_EWM_IRQHandler</title>
      <link>https://community.nxp.com/t5/S32K/S32K146-WDOG-EWM-IRQHandler/m-p/2259477#M55287</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/201492"&gt;@DarrenD&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can refer to the example in the thread &lt;A href="https://community.nxp.com/t5/S32K-Knowledge-Base/Example-S32K144-WDOG-RCM-interrupt/ta-p/1107039" target="_blank" rel="noopener"&gt;Example S32K144 WDOG RCM Interrupt&lt;/A&gt;. It should give you a good reference for your application.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR, VaneB&lt;/P&gt;</description>
      <pubDate>Wed, 10 Dec 2025 20:53:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K146-WDOG-EWM-IRQHandler/m-p/2259477#M55287</guid>
      <dc:creator>VaneB</dc:creator>
      <dc:date>2025-12-10T20:53:57Z</dc:date>
    </item>
    <item>
      <title>Re: S32K146 WDOG_EWM_IRQHandler</title>
      <link>https://community.nxp.com/t5/S32K/S32K146-WDOG-EWM-IRQHandler/m-p/2260419#M55315</link>
      <description>&lt;P&gt;Hopefully this explanation below will help others.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the example code; it helped a lot.&amp;nbsp;&lt;SPAN&gt;My handler code was being executed but the debugger does not halt at a breakpoint in the&amp;nbsp;WDOG_EWM_IRQHandler. I think this is down to the way the WDOG resets the CPU after the 128 bus cycles that the debugger cannot prevent.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The example code is difficult to see working since the IRQ handler toggles an LED rapidly for about 4ms and then the reset happens so the LED turns off.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have modified the example code (after changing S32K144 references to S32K146) to add some variables. Inserting a breakpoint at the start of Reset_Handler, i.e. before C variables are initialised allowed me to see the values that these variables reached after the previous CPU reset.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I changed RCM_WSDOG_INT to 0 (so the code uses&amp;nbsp;WDOG_EWM_IRQHandler and not&amp;nbsp;RCM_IRQHandler).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I added the following variables at the top of main.c&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;int wdog_called;
int wdog_cs;
int wdog_detected;
int wdog_loop;

int main_loop;&lt;/LI-CODE&gt;&lt;P&gt;I modified the "WDOG_EWM_IRQHandler" function (my additions start with /**/ comment)&lt;/P&gt;&lt;LI-CODE lang="c"&gt;void WDOG_EWM_IRQHandler(void)
{
/**/wdog_called++;
/**/wdog_cs = WDOG-&amp;gt;CS;
    if(WDOG-&amp;gt;CS &amp;amp; 0x4000)           // [14] FLG Watchdog Interrupt Flag
    {
/**/    wdog_detected++;
        // WDOG-&amp;gt;CS |= 0x4000;      // Clear the flag
        while(1)
        {
/**/        wdog_loop++;
            PTD-&amp;gt;PTOR |= (1 &amp;lt;&amp;lt; 15); // Toggle RED LED until reset
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;I modified the "main" function (my additions start with /**/ comment)&lt;/P&gt;&lt;LI-CODE lang="c"&gt;...
    while(1)
    {
/**/    main_loop++;
    }
...&lt;/LI-CODE&gt;&lt;P&gt;I then set the breakpoint on the start of the&amp;nbsp;&lt;SPAN&gt;Reset_Handler function&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;I then programmed the dev board and it stopped at "main" (part of the debug configuration settings)&lt;/P&gt;&lt;P&gt;I created watch expressions for my variables&lt;/P&gt;&lt;P&gt;I then pressed F8 (run) and the debugger halted at Reset_Handler at which point I could see the following values&lt;/P&gt;&lt;LI-CODE lang="c"&gt;wdog_called   int 1
wdog_cs       int 0x65e0 (Hex)
wdog_detected int 1
wdog_loop     int 142
main_loop     int 2096993&lt;/LI-CODE&gt;&lt;P&gt;This was the proof that&amp;nbsp;WDOG_EWM_IRQHandler was being called. Note 0x65e0 includes 0x4000 (the FLG bit)&lt;/P&gt;&lt;P&gt;I then put a breakpoint on the "wdog_detected++;" line and ran again&lt;/P&gt;&lt;P&gt;The debugger halted at Reset_Handler and I got the following values&lt;/P&gt;&lt;LI-CODE lang="c"&gt;wdog_called   int 1	
wdog_cs       int 0x65e0 (Hex)	
wdog_detected int 0	
wdog_loop     int 0	
main_loop     int 2097011	&lt;/LI-CODE&gt;&lt;P&gt;This was the proof that&amp;nbsp;WDOG_EWM_IRQHandler was being called and that the debugger tried to stop at the "wdog_detected++;" line but could not get control of the CPU before the WDOG reset the CPU. This failure to stop at any breakpoint in&amp;nbsp;WDOG_EWM_IRQHandler was why I originally thought it was not executing&amp;nbsp;my&amp;nbsp;WDOG_EWM_IRQHandler.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2025 17:33:25 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/S32K146-WDOG-EWM-IRQHandler/m-p/2260419#M55315</guid>
      <dc:creator>DarrenD</dc:creator>
      <dc:date>2025-12-11T17:33:25Z</dc:date>
    </item>
  </channel>
</rss>

