I am currently using the FSL to implement the watchdog timer on an MK64FX512VLQ12. I am setting the timeout to 5 seconds. I then use a test function that waits 10 seconds without refreshing the watchdog to cause it to trip. Most of the time the watchdog trips at 5 seconds as expected but sometimes it trips at times between 2 and 4 seconds. Could someone take a look at this and suggest what I might be doing wrong?
void Watchdog_Initialize( void )
{
wdog_config_t config;
WDOG_GetDefaultConfig( & config );
// Enable Watchdog timer with a timeout of 5 seconds.
config.timeoutValue = 5000;
config.enableWdog = true;
WDOG_Init( WDOG, & config );
}
void Watchdog_Reset( void )
{
WDOG_Refresh( WDOG );
}
void Watchdog_Test( int nModulo )
{
Watchdog_Reset();
Command_Print( "Triggering watchdog timer reset by waiting for 10 seconds" );
Timer_BeginCountdown( CountdownTimerMain, 10000 );
while( ! Timer_IsCountdownExpired( CountdownTimerMain ) )
{
asm( "NOP" );
}
Command_Print( "Failed to trigger watchdog timer reset after 10 seconds" );
}
Solved! Go to Solution.
It looks like the problem was caused by the watchdog being refreshed too quickly in a different area of the code before the text took place. I removed code from a wait loop that was essentially performing constant watchdog refreshes and the problem went away. The problem may be related to the following: https://community.nxp.com/t5/Kinetis-Microcontrollers/MKV4x-Watchdog-refresh-problem/m-p/776179/high...
It looks like the problem was caused by the watchdog being refreshed too quickly in a different area of the code before the text took place. I removed code from a wait loop that was essentially performing constant watchdog refreshes and the problem went away. The problem may be related to the following: https://community.nxp.com/t5/Kinetis-Microcontrollers/MKV4x-Watchdog-refresh-problem/m-p/776179/high...