This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C123FH6PM: Watchdog timer behavior on TM4C targets

Part Number: TM4C123FH6PM

This question came up during a code review of code written several years ago.

Most of our development team is familiar to a watchdog, when starved, simply resetting the controller.  Usually a bit in a register is set to indicate a WDOG reset.

TM4C controllers are the first I have used that can be used as timers, etc..

One behavior I programmed to is that if you are using a WDOG as a WDOG, when you first enable the WDOG peripheral, you end up in the WDOG ISR.

So I ended up with code that reads like:

BOOL waitingForFirstWDOG_Hit = TRUE;
void WDOG_Init(void) {
    ROM_SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0);

    if(ROM_WatchdogLockState(WATCHDOG0_BASE) == true)
    {
        ROM_WatchdogUnlock(WATCHDOG0_BASE);
    }
    ROM_WatchdogStallEnable(WATCHDOG0_BASE);
    ROM_WatchdogIntClear(WATCHDOG0_BASE);
    ROM_WatchdogReloadSet(WATCHDOG0_BASE, SysCtlClockGet()/10);
    ROM_IntEnable (INT_WATCHDOG);  // This will generate an immediate interrupt, so first ISR call needs to IntClear
    ROM_WatchdogEnable(WATCHDOG0_BASE);
}

static void Watchdog_timer_ISR(void) {

if (waitingForFirstWDOG_Hit) {

ROM_WatchdogIntClear(WATCHDOG0_BASE);

waitingForFirstWDOG_Hit = FALSE;

}

else {

numAbnormalResets++;

EEPROM_Write16(ADDR_numAbnormalResets, numAbnormalResets);

// TODO: Watchdog_timer_ISR write fault

ROM_SysCtlReset();

}

}

(Apologies for code paste.  It is not working for me today.)

It works. The question is, why do you end up in the WDOG upon enabling the WDOG?  I am pretty sure the code is from an example.  I tried to avoid the first interrupt, but did not find a way.

  • Hi John,

    Do you get the same behavior if you use the driver library, that is call the Watchdog functions without the "ROM_" prefix?
  • Thanks for the reply. (I am no longer getting email notification of replies. hence, the delayed reply.)
    I do not have time to investigate ROM_* vs. * calls right now.
    Is there a reason to suspect a difference in behavior?
  • Hi John,
    I was wondering if any of the ROM_ functions were corrected in the later versions of the TivaWare library. I checked by using the latest version of the library with the ROM_ functions you called and there was no issue. I like using the MAP_ version of the functions because then it will use the ROM_ version if it exists (and is defined in the header file) or the TivaWare version if not. However, I understand that in an established project you would prefer to get a linker error if we deprecated a ROM_ function in the library.

    Back to your original question. I started with the "watchdog" example in "C:\ti\TivaWare_C_Series-2.1.4.178\examples\boards\dk-tm4c123g\watchdog" and modified it to match the sequence in the snippet of code you attached. I was not able to reproduce the early interrupt you described. (I was limited to using a TM4C123"G" instead of an "F" device.)
  • I will find time in the group to retest our WDT code. It has been tested to reset our processor under expected conditions. But the WDT feature, though simple, needs to be understood well.
    I will mark this as answered and our issue ticket as 'look at this again'.