Hi everyone,
I'm having trouble on configuring WDOG.
I'm using a custom board based on MK66, MCUXpresso 10.1.1 and SDK 2.3.
I need to use the WDOG timer: since it is disabled in the startup function SystemInit(), I need to enabled it at the beginning of my program (after hardware init):
WDOG_GetDefaultConfig( &WdogConfig );
WdogConfig.clockSource = kWDOG_AlternateClockSource;
WdogConfig.prescaler = kWDOG_ClockPrescalerDivide5;
WdogConfig.workMode.enableStop = true;
WdogConfig.timeoutValue = WDOG_TIMEOUT_VAL;
WDOG_Init( WDOG, &WdogConfig );
I step the program through WDOG_Init() -> WDOG_Unlock(): reset occurs at the first instruction of the unlocking sequence:
base->UNLOCK = WDOG_FIRST_WORD_OF_UNLOCK;
The ALLOWUPDATE bit in the STCTRLH register is set (by the SystemInit() function), the WDOG bit in SRS0 register is set (indicating the reset cause is the WDOG timer) and the RSTCNT register increments every reset.
I've no idea, what can I check?
Many thanks
Biafra
Hi Biafra,
The watchdog issues a reset, that is, interrupt-then-reset if enabled, to the system for any of these invalid unlock sequences:
• Write any value other than 0xC520 or 0xD928 to the unlock register.
• ALLOW_UPDATE is set and a gap of more than 20 bus clock cycles is inserted between the writing of the unlock sequence values.
So don't follow the code step by step. This will cause a reset.
Regards,
Jing