AnsweredAssumed Answered

K70 Watchdog does NOT reset some times.

Question asked by David Lynch on Oct 26, 2015
Latest reply on Nov 20, 2015 by David Lynch

I am trying to impliment/Test the watchdog on a K70.

Code below.

 

I am getting the opposite problem most everyone else sees.

 

About 2/3 of the time the Watchog fires and restarts the system and I can verify that the WDOG_RSTCNT has incremented.

About 1/3 of the time the K70 hangs at while(1); forever.

 

 

 

static void

watchdog_unlock(void) {

    /* unlock watchdog */

    WDOG_UNLOCK = WDOG_UNLOCK_WDOGUNLOCK(0xC520); /* Key 1 */

    WDOG_UNLOCK = WDOG_UNLOCK_WDOGUNLOCK(0xD928); /* Key 2 */

}

 

 

static void

watchdog_delay(uint16_t nCount) {

    uint16_t delay = 0;

    for (delay=0;delay<nCount*10;delay++) {

        NULL;

    }

    return;

}

 

 

static void

watchdog_refresh(void) {

    _int_disable();

    WDOG_REFRESH = 0xA602;

    WDOG_REFRESH = 0xB480;

    _int_enable();

}

 

 

static uint32_t wdog_to = 125*2;

void

OS_WatchdogInitialize(void) {

    _int_disable();

    watchdog_unlock();

    watchdog_delay(1);

    WDOG_TOVALH = wdog_to >> 16;

    WDOG_TOVALL = wdog_to & 0xffff;

    WDOG_STCTRLH = WDOG_STCTRLH_DISTESTWDOG_MASK     // Disable functional test

            | WDOG_STCTRLH_WDOGEN_MASK;

 

    // 14 DISTESTWDOG

    // 12:13 BYTESEL

    // 11 TESTSEL

    // 10 TESTWDOG

    // 7 1 WAIT_EN = 0

    // 6 1 STOP_EN = 0

    // 5 0 DBG_EN = 0

    // 4 1 ALLOWUPDATE = 1

    // 3 0 WINEN = 0

    // 2 0 IRQSTEN = 0

    // 1 1 CLKSRC = 0

    // 0 1 WDOGEN = 0

    WDOG_WINL = WDOG_WINH = 0;

    WDOG_PRESC = 0x700;

    _int_enable();

    _time_delay(4);

}

 

 

void watchdog_test() {

    int lc = 0;

    OS_WatchdogInitialize();

    while (1) {

        watchdog_refresh();

        if (lc++ > 150) {

            while(1);

        }

    }

}

                                                                                                                                64,1          Bot

Outcomes