Reset using watchdog

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

Reset using watchdog

2,580 Views
biafra
Senior Contributor I

Hi everyone,

In the past I've reported a problem on using watchdog (see WDOG unlock causes reset‌). The problem was bypassed, but now i'ts come back on a new project.

I explain it again: I use a custom board based on K66, MCUXpresso 11.0.0, SDK 2.6 and FreeRTOS 10.2.0.

If I call the WDOG_Init() function after the os starts (at the beginning of the first task), the controller resets when it executes the WDOG_Unlock() function.

If I call the WDOG_Init() function before the os starts, this function is executed with no error, but the controller 

resets when it executes the WDOG_Refresh() function, called by the first task.

/******************************************************/

void main( void )

{

   ...

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

   vTaskStartScheduler();

}

 

void FirstTask( void * )

{

   InitWDOG(); //init wdog <<<<<<<<<<<<<<<< CONTROLLER RESETS

   ...

}

/******************************************************/

/******************************************************/

void main( void )

{

   ...

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

   InitWDOG(); //init wdog <<<<<<<<<<<<<<<< INSTRUCTION EXECUTED

   vTaskStartScheduler();

}

 

void FirstTask( void * )

{

   ...

   WDOG_Refresh(); //refresh wdog <<<<<<<<<<<<<<<< CONTROLLER RESETS

   ...

}

/******************************************************/

What can I check?

Many thanks

Biafra

10 Replies

2,190 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Dear francescobianchini‌,

 I will suggest to check the example from the SDK frdmk66f_wdog, there mention how to do enable the WDOG example, I tried to merge the examples of WDOG and freertos_hello and it was possible to refresh the MCU if the time until the refresh of the WDOG is shorter than the WDOG timeout.

Remember that the scheduler took some time until the access of the first task, so try to set the timeout the enough time until the refresh is done.

I hope this helps you.

Best Regards,

Alexis Andalon

2,190 Views
biafra
Senior Contributor I

Hi nxf46116‌,

Many thanks for your answer.

I already checked the SDK wdog example and it works well, but it doesn't use os.

I don't think it's a refresh timeout problem because the wdog timeout is 3 s.

But the strange thing is that the init InitWDOG() function works if it's called by main before os starts, and it doesn't work if it's called by the first task.

Many thanks

Biafra

2,190 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Dear francescobianchini‌,

Check the code attached. I set the WDOG timer in the first task and refresh it in the other.

However, I will suggest to think about use the WDOG with FreeRTOS. For this you will need to have a good control of how much time all your task will need until the task that refresh the WDOG is called again. If in the system there's an anomaly and a task take more time, all the system will be reset.

Best Regards.

Alexis Andalon

2,190 Views
biafra
Senior Contributor I

Hi nxf46116‌,

Many thanks for your suggestion.

I've tested your code and for me the behaviour is always the same: the first time I try to unlock or refresh the wdog after the os started, the cpu resets.

I've made a change, I've moved the code before os starts.

If I unlock or refresh the wdog before os starts, I can continue to step the code until the task tries to refresh the wdog, then the cpu resets.

I've tested two different board and they behave the same way.

Many thanks

Biafra

2,190 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Dear francescobianchini‌,

I see that your using the FreeRTOS V10.2.0, unfortunately the last version that we support and test is the 10.0.1. I use the 10.0.1 version for the code that I attached. Could you test this using the supported version?

Best Regards,

Alexis Andalon

2,190 Views
biafra
Senior Contributor I

Hi nxf46116‌,

Many thanks for your answer.

I've tested with FreeRTOS 10.0.1, but the behaviour is still the same.

One question: why do you say that FreeRTOS 10.2.0 is unsupported? It comes with SDK 2.6.

Many thanks

Biafra

2,190 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Dear Francesco, 

You're right, the last version isn't the 10.0.1, is the 1.4.0. I found this in the MCUXpresso SDK Release Note Supporting LPCXpresso54608, LPCXpresso54618, and LPCXpresso54628. I'm sorry for my confusion.

About your problem, could you check the following registers an let me know the value after the first reset? 

-RCM_SSRS0

-RCM_SSRS1

Best Regards,

Alexis Andalon

2,190 Views
biafra
Senior Contributor I

Hi nxf46116‌,

After the first reset these are the register values:

- RCM_SRS0 -> 0x20

- RCM_SRS1 -> 0x00

- RCM_SSRS0 -> 0xE2

- RCM_SSRS1 -> 0x08

Many thanks

Biafra

2,190 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Dear Francesco,

Checking this registers I found one strange things. In the SSRS1 the SMDM_AP bit is enabled.

pastedImage_1.png

This says that the debugger is causing a reset. If you desconect your debug this problem is still present?

Also, do you have one of our developments boards? I would like to know if you can replicate this issue with one of our boards.

Best Regards,

Alexis Andalon

1,871 Views
davithakobyan
Contributor III

Hi,

I have a problem with MK10 custom board similar to the one described in this thread. The watchdog is initially disabled in the SystemInit function.

Later in the code (not in the main function) when the attempt to unlock the watchdog (i.e. WDOG->UNLOCK = WDOG_UNLOCK_WDOGUNLOCK(0xC520) ) cases  a reset. The reset reason registers are as follows:

SRS0 = 0x20

SRS1 = 0

This tells that the reset was caused by the watchdog timeout, however the watchdog has not yet been enabled, just the unlock operation was started. When the unlock attempt is moved as the first instruction in the main function this does not cause a reset.

What is wrong with the watchdog? Can this be related to clock configuration? The only thing which is done with MK10 compared between these two cases of unlocking the watchdog, i.e. in the main function and in another function is that in the latter case the clocks of MK10 are configured to use oscillator and PLL (similar to configuration posted here: https://community.nxp.com/t5/Kinetis-Microcontrollers/MK10-MCG-Clock-Configuration/m-p/557440).

So what can be wrong with the watchdog unlocking?

0 Kudos