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.

MSP430FR5969: How to restore watch dog timer to default

Part Number: MSP430FR5969


I have a program which uses the delay(int) function for timing.

It works fine UNTIL I need to stop the watchdog timer to perform more precise timing by setting WDTCTL = WDTPW + WDTHOLD as per multiple examples.

After I have turned it off I run some timing tests that work.

However now my delay(int) command hangs the system and it won't recover.

I've tried every setting I can think of (including turning on the watch dog timer in multiple different ways) but I can't get the delay function to work again after turning off the watch dog timer.

What registers need to be set to restore the watch dog timer to default (power on) operation? Based on the register map it sure seems like WDTCTL = WDTPW should be all that's needed unless there are defaults that are not documented.

  • Hi

    WDTCTL = WDTPW + WDTHOLD is Stop WDT;

    delay_cycles(x) is stopping in the code and waiting for x MCLK cycles.

    Could you please help to check the feature of  delay_cycles(x) on the msp430fr59xx_1.c sample code example on MSP430FR59xx, MSP430FR58xx Code Examples (Rev. L)

    Thanks!

  • The reset value of WDTCTL is (WDTPW|WDTIS2) [Ref User Guide (SLAU367P) Fig 24-2] . Setting it to (WDTPW|0) puts it in Reset mode with a very long delay [Ref UG Table 24-2].

    If you're using the WDT to implement a delay, I don't think you want either of these settings. What does your delay() function look like?

  • The obvious thing to do is to read WDTCTL before stopping it. Then mask off the password byte, OR in the correct password, and write it back when you want to start it again. That will restore its previous settings. Even if it was stopped.

  • Thank you for that. Unfortunately the behavior is still the same. Delay function works until I stop the watchdog timer, then hangs the system after I call it after the watchdog timer is stopped and restarted.

    void delay(uint32_t milliseconds)
    {
    uint32_t start = micros();
    while(milliseconds > 0) {
    if ((micros() - start) >= 1000) {
    milliseconds--;
    start += 1000;
    }
    __bis_SR_register(LPM0_bits+GIE);
    }
    }

    This is from wiring.c, which is an arduino file for msp430.

    Okay, I had some luck:

        WDTCTL = WDTPW + WDTHOLD; //Stop watchdog timer

        TA0CCR0 = 0; //Initially, Stop the Timer
        TA0CCTL0 |= CCIE; //Enable interrupt for CCR0.
        TA0CTL = TASSEL_2 + ID_0 + MC_2; //Select SMCLK, SMCLK/1 , Continuous Mode

        WDTCTL = WDTPW + WDTIS2; //Start watchdog timer

    This, combined with using '__delay_cycles' instead of 'delay' appears to work.

  • I tried re-implementing my function with delay_cycles() instead of delay() and the behavior is the same. The function works until I stop the watchdog timer and then it hangs on subsequent calls.

**Attention** This is a public forum