K64F mbed5.2 Watchdog timer WDT?

Solved
cswiger's picture
cswiger
Junior(1)

Posting here as have googled in desperation and unable to find any modern mbed 5 watchdog timer solutions that work? 

Everything I can find dates back to 2014 such as this one https://developer.mbed.org/users/loopsva/code/WDT_K64F/docs/tip/

which however fails to compile with missing:  

WDOG_UNLOCK, WDOG_TOVALH, WDOG_TOVALL

 

Guess we have to roll our own kludgy non-standard WDT here? I'm trying this:

 

Ticker OneSecTicker;
int watchdogTicks = 0;
void OneSecFunction()
{
  // called once a second - bTimerExpiredFlag should go true every 30 seconds and immediately 
  // be reset if all is well.   If it stays true for another 30 seconds give up and reset
  if(bTimerExpiredFlag) {
     watchdogTicks++;
  } else {
     watchdogTicks = 0;
  }

  if(watchdogTicks > 30)  NVIC_SystemReset();

}

 

 

main() {

   ...

    //create a 1 seconds watchdog timer check
    OneSecTicker.attach(OneSecFunction,1.0f);

  ...

}

 

LightCollector's picture
LightCollector
Moderator(20)

Hi,  Please re-post this question in the software forum for the kit.

 

Or probably even better, also try the folks in the ARM/mbed forums, they are the ones who can fix the mbed libraries.  I will poke an ARM mbed person for you but be patient, it can take a while to get a response sometimes.

 

In the mean time the answer may lie at least somewhat in the mbed RTOS library.  With which you can run threads, use timers and other standard OS constructs.

 

Thank you

LightCollector's picture
LightCollector
Moderator(20)

If that still doesn't work it was suggested to just directly access the registers:

WDOG->UNLOCK
WDOG-> TOVALH
WDOG-> TOVALL
WDOG-> REFRESH
WDOG-> STCTRLH

Hope that helps!  Best Regards