Debugging the RTWDOG RT1020 on MCUXpresso

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

Debugging the RTWDOG RT1020 on MCUXpresso

1,956 Views
ikuzmych
Contributor II

Currently, I have what I believe to be functional code implementing the RTWDOG. However, when I run the debugger on MCUXpresso, my code stops when I expect it to be at the set timeout value. But when the MCU supposedly resets, my debugger pauses and waits for me to manually resume it so that it runs the program again. How can I properly debug my RTWDOG so that it automatically resets the MCU and runs on its own without me having to forcefully resume it in the debugger? Is there perhaps a different debug mode I should be aware of? Currently, my watchdog is configured to have waitMode on, debug and stop mode off. However, even when I enable debug mode I get the same results. Any tips would be greatly appreciated, thanks!

0 Kudos
Reply
11 Replies

1,934 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @ikuzmych ,

  Do you try to add a breakpoint at the rest handler, whether that works when the RTWDOG reset happens?

kerryzhou_0-1653883247073.png

   Do you test the SDK code directly when the reset happens?

  Please try it again, you also can share some debug screen to demonstrate your issues.

Best Regards,

kerry

 

0 Kudos
Reply

1,932 Views
ikuzmych
Contributor II

What is the rest handler for? I mainly had issues in running the debug console. Each time the RTWDOG reset the MCU, the debugger paused. Even when I flashed my program to my dev board and gave it power, upon reset it did not begin re-running the program

0 Kudos
Reply

1,930 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @ikuzmych ,

    So, you mean, when the RTWDOG reset happens, the code can't work any more, can't print the information?

   Can you reproduce the issues with the SDK?

Best Regards,

Kerry

0 Kudos
Reply

1,922 Views
ikuzmych
Contributor II

Hi Kerry, so this is my output on the debug console when refreshing the RTWDOG every certain period of time. I use a print statement before and after the refresh to confirm that the rtwdog is behaving as expected and that the counter is incrementing.

ikuzmych_0-1654195353496.png

However, this is my result when I turn off the refresh and force the rtwdog to reset the mcu. As you can see, my code just sort of stops running, essentially shutting down, and does not reset and re-initialize the program. The counter does increment and it resets at the value that I expect it to. My current debug mode is "Debug using LinkServer probes"

ikuzmych_1-1654195593616.png

Is there perhaps a different debugger I can use? And yes you said it completely right. The code does not print any more information after resetting the MCU. I expect it to essentially print out the exact same messages, which it does not do. Any help would be great, thanks!

0 Kudos
Reply

1,908 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @ikuzmych ,

   If you just download the code which didn't refresh the RTWDOG to the flash, then run it directly, whether it can reset or not? I mean, don't use the debugger.

   From your attached picture, seems your RTWDOG counter still increase, whether it is not reset?  If yes, just the debug mode meet issues, check this bit:

kerryzhou_0-1654488665219.png

You need to set DBG=1 when debug.

Wish it helps you!

Best Regards,

Kerry

 

0 Kudos
Reply

1,903 Views
ikuzmych
Contributor II

Should I set enableStop and enableWait to be low and enableDebug to be high? This is my current config:

/**
* config->enableRtwdog = true;
* config->clockSource = kRTWDOG_ClockSource1;
* config->prescaler = kRTWDOG_ClockPrescalerDivide256;
* config->workMode.enableWait = false;
* config->workMode.enableStop = false;
* config->workMode.enableDebug = false;
* config->testMode = kRTWDOG_TestModeDisabled;
* config->enableUpdate = true;
* config->enableInterrupt = false;
* config->enableWindowMode = false;
* config->windowValue = 0U;
* config->timeoutValue = 0x0180U;
*/

To debug it in MCUX do I need to also enable test mode bit to be high, or just debug and ignore wait/stop?

 

0 Kudos
Reply

1,899 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @ikuzmych ,

  If you need to run in the low power mode, then you need to enable:enableStop and enableWait 

  I think, you can enable all of them, as it won't influence your normal work.

  You don't need to enable the test mode.

kerryzhou_0-1654764516791.png

Best Regards,

Kerry

 

0 Kudos
Reply

1,892 Views
ikuzmych
Contributor II

ikuzmych_0-1654809655613.png

When running in debug mode I am still getting this strange error after the watchdog resets. How could I go about fixing this and allowing my dev board to reset entirely and run from the start as expected?

0 Kudos
Reply

1,885 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @ikuzmych ,

   If you don't debug it, just download code to the flash, whether you can get the function:

code run from main ->print->rtwdog reset->code run from main ->print...

 Set the timeout a little longger, eg, 5s.

  If download to the flash works without the debugger, just debug meet issues, it may also related to the IDE.

 

Best Regards,

Kerry

0 Kudos
Reply

1,880 Views
ikuzmych
Contributor II

I tried flashing but could not get any sort of result I liked. When I used the flash console to read what was currently on the dev board it simply stopped as before and would not run again as expected. I have no idea how to fix this and flashing it does not seem to entirely work

0 Kudos
Reply

1,867 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @ikuzmych ,

  Please share with me your modified code, it is based on the SDK:

SDK_2_11_0_EVK-MIMXRT1020\boards\evkmimxrt1020\driver_examples\rtwdog

  Please share the project, then I will help you to check it on my side.

Best Regards,

Kerry

0 Kudos
Reply