@kerryzhou what do you mean by
write the refresh operation at least 2ms
At least every 2ms? or at least 2ms apart?
I ask because I'm having problems with the watchdog. It doesn't want to refresh. I'm also clocking it with the LPO with preescaler = 1 and a timeout period of 1000 ticks (1 second).
I'm just starting with the peripheral tests on a new project using the MK10DN512VLQ10 and the only code I have is main with this:
int main(void)
{
/* Init board hardware. */
BOARD_InitBootPins ();
BOARD_InitBootClocks ();
BOARD_InitBootPeripherals ();
#ifndef BOARD_INIT_DEBUG_CONSOLE_PERIPHERAL
/* Init FSL debug console. */
BOARD_InitDebugConsole ();
#endif
PRINTF ("\n\nHello World\n");
/* Force the counter to be placed into memory. */
volatile static uint32_t i = 0;
/* Enter an infinite loop, just incrementing a counter. */
while (1)
{
WDOG_Refresh(WATCHDOG_PERIPHERAL);
PRINTF ("i = %lu\n", (uint32_t)i);
i++;
/* 'Dummy' NOP to allow source level single stepping of
tight while() loop */
__asm volatile ("nop");
}
return 0;
}
I have single-stepped through the code and made sure that WDOG_Init(WATCHDOG_PERIPHERAL, &Watchdog_config); in peripherals.h is indeed being executed and the watchdog being initialized.
These are my watchdog peripheral configurations generated with the peripherals config tool:
const wdog_config_t Watchdog_config = {
.clockSource = kWDOG_LpoClockSource,
.prescaler = kWDOG_ClockPrescalerDivide1,
.timeoutValue = 1000UL,
.enableWindowMode = false,
.windowValue = 0UL,
.enableUpdate = true,
.enableWdog = true,
.workMode = {
.enableWait = true,
.enableStop = false,
.enableDebug = false
},
.enableInterrupt = false
};
Do you know what would be the problem? Am I refreshing the watchdog too frequently?
Thanks!!