WDOG unlock causes reset

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

WDOG unlock causes reset

1,476 Views
biafra
Senior Contributor I

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

4 Replies

1,006 Views
jingpan
NXP TechSupport
NXP TechSupport

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

1,006 Views
biafra
Senior Contributor I

Hi Jing,

I stepped into the code because the processor resets.

If I step over (F6 button) the WDOG_Init() function or run, the processor resets. The WDOG_Init() function is the SDK one with no changes: it disables the interrupts before the unlocking sequence and it enables them back at the end of configuration.

Is there something else to verify?

Many thanks

Biafra

1,006 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

I made a example. It works fine.

Regards,

jing

1,003 Views
biafra
Senior Contributor I

Hi jingpan‌,

This thread is old, this year the project changed and didn't need the watchdog anymore, but I started a new project and the problem came again.

In the new project I'm using a custom board based on MK66, MCUXpresso 11.0.0 and SDK 2.6 and Freertos 10.2.0.

I've made some further tests and I have some news: if I use the main function of your project, WDOG_Init() is executed with no problem. So I inserted the wdog init in different position of my code: it works until WDOG_Init() is called before the os start, but it doesn't work it's called at the beginning of the first task.

------------------------ This example works -------------------------------

void main( void )

{

   ...

   xTaskCreate( ... ); //create first task

   InitWDOG(); //init wdog

   vTaskStartScheduler();

}

------------------------------------------------------------------------------------

------------------------ This example doesn't work -------------------------------

void main( void )

{

   ...

   xTaskCreate( ... ); //create first task

   vTaskStartScheduler();

}

void FirstTask( void * )

{

   InitWDOG(); //init wdog

   ...

}

------------------------------------------------------------------------------------

Do you have any advice to test?

Many thanks

Biafra