watchdog on KM34Z why does not work?

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

watchdog on KM34Z why does not work?

954 Views
manfredeggersdo
Contributor I

Hello,

I want to use the watchdog on MKM34Z256 and tried code like that:

*************

     PRINTF("RESET");

    WDOG_GetDefaultConfig(&config);
    config.clockSource = kWDOG_LpoClockSource;

    config.prescaler = kWDOG_ClockPrescalerDivide1;
    config.enableUpdate = true;
    config.enableInterrupt = false;
   config.enableWindowMode = false;
    config.timeoutValue = 0x7ffU;
    WDOG_Init(wdog_base,&config);

    WDOG_Refresh(wdog_base);
    while(1)
    {
        WDG_Timer = GetTimerOutputValue(wdog_base);

        PRINTF(" %d", WDG_Timer);
        WaitLoop(3500000);
    }

*************

Normally I would suggest, that the I would receive via UART something like that:

RESET 0 1 2 3 4

...

2047

RESET 0 1 2...

but I only get

RESET 0 0 0 0 0... and no Watchdog Reset.

Does that mean that the Watchdog has no Clock?

Must I Enable the LPO in a different way?

Thank You!

With best regards

Manfred

0 Kudos
7 Replies

745 Views
manfredeggersdo
Contributor I

Hello Kerry,

MANY THANKS!

I tried in a different way - but this was the problem:

* In system_MKM34Z7.h the DISABLE_WDOG was really defined to 1. But for the reason, that my code don't booted after changing to zero, I decide to initialize the Watchdog in sytem_MKM34z7.c in function SystemInit.

I do initialize the watchdog in this position like I want to use, but with cleared WDOGEN - for the reason, that I do not use the watchdog in every case.

* I setted SIM_SOPT1 bit 18 and 19 to 1, before I initialize the Watchdog for using.

Background: On my own PCB is no external XTAL mounted

So it works fine.

It looks like:

1. the watchdog must be initialized very early in code first time (regardles of using or not)

2. SIM_SOPT1 18&19 must configured for delivering a clock before the Watchdog is be initialized to use and regardless if the LPO or ALT clock is used in WDOG_STCTRLH .

Thank you for the hints!

With best regards

Manfred

0 Kudos

744 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hello Manfred Eggersdorf,

   Thank you for your completely feedback.

 1. Actually, the watchdog must be feeded or disabled before it is timeout. So, you may feel it should be very early.

  2. You must make sure the watchdog clock is working if you want the WDOG works normally.

 

Wish it helps you!

If your problem is solved, please help me to mark the correct answer to close this question.

Have a great day,
Kerry

 

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

744 Views
manfredeggersdo
Contributor I

Hello Kerry,

sorry, I tried so many things, that I postet the WDOG_STCTRLH with alternate clock trial.

Using the LPO makes no difference.

Perhaps we shall think fom beginning:

The CPU is a MKM34Z256VLL7 on an own PCB - using internal Clock source, no external XTAL is mounted.

IDE is Kinetis Design Studio - SDK2.0 - free RTOS.

Debug Probe is a changed TWR-KM34Z75M, where I disconnected the TWR CPU and use the onboard SWR port.

This works fine since some month.

In my code I first initialize the Clock and ports, then I tried this code in different variations:


        WDOG_GetDefaultConfig(&config);
        config.enableWdog = true;
        config.clockSource = kWDOG_LpoClockSource;
        config.workMode.enableDebug = true;
        config.workMode.enableStop = true;
        config.prescaler = kWDOG_ClockPrescalerDivide8;
        config.enableUpdate = true;
        config.enableInterrupt = false;
       config.enableWindowMode = false;
        config.timeoutValue = 0x7ffU;
        WDOG_Init(wdog_base,&config);
         WaitWctClose(wdog_base);
        WaitLoop(3500000);

        while(1)
        {
            LED_YELLOW_TOGGLE();
            WDG_Timer = GetTimerOutputValue(wdog_base);
            WDGstatel = wdog_base->STCTRLL;
            WDGstateh = wdog_base->STCTRLH;
            PRINTF("Timer: %d \r\n", WDG_Timer);
            PRINTF("StateL: %016b \r\n", WDGstatel);
            PRINTF("StateH: %016b \r\n", WDGstateh);
            WaitLoop(3500000);
        }

Which repeated deliveres:

Timer: 0 <CR><LF>
StateL: 0000000000000001 <CR><LF>
StateH: 0100000001110001 <CR><LF>

...

...and now I do not have any idea... ;-)

Best Regards

Manfred

0 Kudos

745 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hello Manfred Eggersdorf,

   Thank you for your details.

   I already test the KSDK2.2-TWR-KM34Z75M freertos code about the watchdog,  the watchdog works on my side.

   Now, let's use the same code, and follow my way to test it:

1. Download the newest ksdk sample code for KM34 chip.

  Welcome to MCUXpresso | MCUXpresso Config Tools 

SDK Builder, choose the board as TWR-KM34Z75M, then generate the code and download it.

2. Open the freertos code, the code path which I used is : SDK_2.2_TWR-KM34Z75M\boards\twrkm34z75m\rtos_examples\freertos_hello\kds

3. modify the code

1) don't disable the watchdog after reset

   system_MKM34Z7.h, line 84, define disable_wdog as 0.

pastedImage_2.png

  2) Run the code, you will find it always in the reset handler

   Check the register:

   pastedImage_3.png

pastedImage_4.png

pastedImage_5.png

pastedImage_6.png

pastedImage_7.png

   You can find the RCM_SRS0[WDOG] =1, it means the reset is caused by the watchdog, so the watchdog works.

You can follow my steps and test the ksdk2.2 freertos code in the twr-km34z75m board at first, after it works, you can test it on your own board.

 The watchdog in MKM34Z256VLQ7 and MKM34Z256VLL7 is the same.

Please test it again, any updated information, please kindly let me know!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

745 Views
manfredeggersdo
Contributor I

Hello Kerry,

Thank you for your reply.

The value of the WDOG_STCTRLH register is: 0100000000110011 - so I would think, the WDOGEN is enabled.

In my code I do first initialize many things, clock (internal), ports... Is it correct, that I can initialize the watchdog after that?

Or - other thought - is it possible, that something has disabled the LPO?

Thank you!

Manfred

PS: I' using free RTOS - perhaps there is a problem?

0 Kudos

745 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hello Manfred Eggersdorf,

WDOG_STCTRLH register is: 0100000000110011

pastedImage_1.png

pastedImage_2.png

Your clock is using the alt clock,

pastedImage_3.png

You need to check the according clock source, whether you have the clock?

I think you can configure it to use LPO directly, because LPO is alway enabled.

free RTO is no relationship with the watchdog, please check your watchdog clock source.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

745 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hello Manfred Eggersdorf,

   Please check register: WDOG_STCTRLH[WDOGEN], whether the WDOG is enabled or not?

   If it is disabled, please check your code, after reset, whether you do the disable watchdog code? If yes, comment it, then try it again.

Any updated question, just let me know!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos