Hopefully this explanation below will help others.
Thanks for the example code; it helped a lot. My handler code was being executed but the debugger does not halt at a breakpoint in the 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.
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.
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.
I changed RCM_WSDOG_INT to 0 (so the code uses WDOG_EWM_IRQHandler and not RCM_IRQHandler).
I added the following variables at the top of main.c
int wdog_called;
int wdog_cs;
int wdog_detected;
int wdog_loop;
int main_loop;
I modified the "WDOG_EWM_IRQHandler" function (my additions start with /**/ comment)
void WDOG_EWM_IRQHandler(void)
{
/**/wdog_called++;
/**/wdog_cs = WDOG->CS;
if(WDOG->CS & 0x4000) // [14] FLG Watchdog Interrupt Flag
{
/**/ wdog_detected++;
// WDOG->CS |= 0x4000; // Clear the flag
while(1)
{
/**/ wdog_loop++;
PTD->PTOR |= (1 << 15); // Toggle RED LED until reset
}
}
}
I modified the "main" function (my additions start with /**/ comment)
...
while(1)
{
/**/ main_loop++;
}
...
I then set the breakpoint on the start of the Reset_Handler function
I then programmed the dev board and it stopped at "main" (part of the debug configuration settings)
I created watch expressions for my variables
I then pressed F8 (run) and the debugger halted at Reset_Handler at which point I could see the following values
wdog_called int 1
wdog_cs int 0x65e0 (Hex)
wdog_detected int 1
wdog_loop int 142
main_loop int 2096993
This was the proof that WDOG_EWM_IRQHandler was being called. Note 0x65e0 includes 0x4000 (the FLG bit)
I then put a breakpoint on the "wdog_detected++;" line and ran again
The debugger halted at Reset_Handler and I got the following values
wdog_called int 1
wdog_cs int 0x65e0 (Hex)
wdog_detected int 0
wdog_loop int 0
main_loop int 2097011
This was the proof that 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 WDOG_EWM_IRQHandler was why I originally thought it was not executing my WDOG_EWM_IRQHandler.