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.

tm4c123 watchdog timer got reset 2 times of the expected settings

I set up the watchdog timer as following. It should be 2 seconds watchdog timeout. In the actual measurement of reset, we found the controller got reset after 4 seconds. It's twice longer than it is supposed to be. The code is below.

    //------------------------------------
    // Setup Watchdog

    // Enable the peripherals used by this example.
    SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0);

    // Check to see if the registers are locked, and if so, unlock them.
    if(WatchdogLockState(WATCHDOG0_BASE) == TRUE)
    {
        WatchdogUnlock(WATCHDOG0_BASE);
    }

    // Enable stall processor during debug
    WatchdogStallEnable(WATCHDOG0_BASE);

    // Initialize the watchdog timer.
    WatchdogReloadSet(WATCHDOG0_BASE, 2 * SysCtlClockGet());

    // Enable the reset.
    WatchdogResetEnable(WATCHDOG0_BASE);

    // Enable the watchdog timer.
    WatchdogEnable(WATCHDOG0_BASE);

    // Lock watchdog settings
    WatchdogLock(WATCHDOG0_BASE);

    // Clear watchdog
    Config::ClearWatchdog();

 

  • Hello Eric,

    The WDT Timer generates an Interrupt first. If the Interrupt is not processed then it generates a Reset. The time for each of the event to be generated is equal to the Load Count. Hence the reset would be after 4sec.

    Regards

    Amit

  • On my board, TM4C123 do not generate watchdog interrupt if set as normal interrupt. Here is the code,

    //Enable the Watchdog timer and go ahead
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0);
    // Enable the watchdog interrupt.
    //MAP_IntEnable(INT_WATCHDOG);
    // Disable watchdog during debug
    WatchdogStallEnable(WATCHDOG0_BASE);
    // Set the period of the watchdog timer.
    MAP_WatchdogReloadSet(WATCHDOG0_BASE, MAP_SysCtlClockGet() * 2);
    // Enable reset generation from the watchdog timer.
    MAP_WatchdogResetEnable(WATCHDOG0_BASE);
    MAP_WatchdogIntEnable(WATCHDOG0_BASE);
    // Enable the watchdog timer.
    MAP_WatchdogEnable(WATCHDOG0_BASE);


    //Don't reset the interrupt
    void WatchdogIntHandler(void)
    {
    MAP_WatchdogIntClear(WATCHDOG0_BASE); //This is the break point, which never hits.
    WatchdogIntCnt++; //the count never updates
    }

    //in the interrupt vector table,
    ADC0IntHandler, // ADC Sequence 0
    IntDefaultHandler, // ADC Sequence 1
    IntDefaultHandler, // ADC Sequence 2
    IntDefaultHandler, // ADC Sequence 3
    WatchdogIntHandler, // Watchdog timer
    Timer0AIntHandler, // Timer 0 subtimer A
    IntDefaultHandler, // Timer 0 subtimer B
    Timer1AIntHandler, // Timer 1 subtimer A
    IntDefaultHandler, // Timer 1 subtimer B
    Timer2AIntHandler, // Timer 2 subtimer A


    It resets the system if I don't feed the watchdog. So I know watchdog is working fine. All other interrupts work ok. I am using Quadrature Encoder, couple of UART interrupts and Timer interrupts. However the Watchdog interrupt never fires. Any hint?

  • Hello Pragnesh

    Why is the function MAP_IntEnable(INT_WATCHDOG); commented in the code?
  • Sorry about that. It could be bypassed while I was trying to find the interrupt issue. I took that in line but still no effect,

    void WatchdogIntHandler(void)
    {
    //Have a break point here.. Never hits.
    if(WatchdogIntCnt < 2)
    {
    MAP_WatchdogIntClear(WATCHDOG0_BASE);
    }
    WatchdogIntCnt++;
    }

    void FeedWatchdog(void)
    {
    MAP_WatchdogUnlock(WATCHDOG0_BASE);
    MAP_WatchdogIntClear(WATCHDOG0_BASE);
    MAP_WatchdogReloadSet(WATCHDOG0_BASE, MAP_SysCtlClockGet() * 2);
    MAP_WatchdogLock(WATCHDOG0_BASE);
    WatchdogIntCnt = 0;
    }

    void WatchdogInit(void)
    {
    TypeConversion Var;
    FRAM_ReadBytes(WATCHDOG_RESET_CNT, &Var.uC[0], 4);
    WatchdogResetCnt = Var.lng;

    //Enable the Watchdog timer and go ahead
    MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_WDOG0);
    // Enable the watchdog interrupt.
    MAP_IntEnable(INT_WATCHDOG);
    // Disable watchdog during debug
    WatchdogStallEnable(WATCHDOG0_BASE);
    // Set the period of the watchdog timer.
    MAP_WatchdogReloadSet(WATCHDOG0_BASE, MAP_SysCtlClockGet() * 2);
    // Enable reset generation from the watchdog timer.
    MAP_WatchdogResetEnable(WATCHDOG0_BASE);
    //MAP_WatchdogIntTypeSet(WATCHDOG0_BASE, WATCHDOG_INT_TYPE_NMI);
    MAP_WatchdogIntEnable(WATCHDOG0_BASE);
    // Enable the watchdog timer.
    MAP_WatchdogEnable(WATCHDOG0_BASE);
    MAP_WatchdogLock(WATCHDOG0_BASE);
    }

    ============
    //from the NVIC table
    IntDefaultHandler, // ADC Sequence 1
    IntDefaultHandler, // ADC Sequence 2
    IntDefaultHandler, // ADC Sequence 3
    WatchdogIntHandler, // Watchdog timer
    Timer0AIntHandler, // Timer 0 subtimer A
    IntDefaultHandler, // Timer 0 subtimer B
    Timer1AIntHandler, // Timer 1 subtimer A
    IntDefaultHandler, // Timer 1 subtimer B
    Timer2AIntHandler, // Timer 2 subtimer A
    IntDefaultHandler, // Timer 2 subtimer B

    Sorry for the delay.