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.

MSP430F5418A watchdog

Other Parts Discussed in Thread: MSP430F5418A

Hi all,

I'm currently working with MSP430F5418A . And I wanna use the WDT module to generate PUC signal in case of some program problems. I set the timer interval to

1s. It means if I don't clear the WDTCNT in 1s, the module will generate PUC. Is it?

How do I clear the WDTCNT? By setting the WDTCNTCL bit in WDTCTL in the WDT ISR?

Thanks

Best regards,

NIck

  • Nick Carter said:
    1s. It means if I don't clear the WDTCNT in 1s, the module will generate PUC. Is it?

    In watchdog mode yes. In counte rmode, no PUC is generated but a normal interrupt.

    Nick Carter said:
    How do I clear the WDTCNT?


    WDTCTL = WDTPW|WDTCNTCL;
    (warning, don't use WDTCTL |= WDTCNTCL: since the passwotrd is read as 0x6900 but must be written as 0x5a00. So any bit operation on WDTCTL will cause a password violation reset)

    Nick Carter said:
    By setting the WDTCNTCL bit in WDTCTL in the WDT ISR?

    In watchdog mode, no interrupt is triggered. The reset is the interrupt. In counte rmode, it is not necessary to reset the counter, as it simply continues ocunting until next interrupt.

    The key is to place the above statement for clearing the counter at a place in your code where you know that is will be (if everything's okay) executed at least once every second (including sleep times!).

    You can even cascade this:
    In one of my projects I use multiple threads. Each of these threads has a global variable, which is set at some poitn during thread execution to a certain value. In my tierm interrupt (which is executed one a millisecond) I decrement these global variables. As long as none of them reaches zero, I reset the watchdog. If one or mroe of these global variables reaches zero, I doN't reset the watchdog durign this interrupt.

    So if any one of all the threads doesn't set its 'watchdog variable' back to a value it thinks it fits before the watchdog expires, the watchdog will reset the MSP, even if the timer interrupt was still executed properly.

    This can also be used for individual functions. If you know that a certain function should be executed every second, set its timeout variable to 60000, and if it isn't executed within one second again, the tiemr intrrupt wills top clearing the watchdog.

    The watchdog timeoue itself can be chose much shorter,a s it only has to span two timer interrupt cycles.

  • Hi Gross,

    Thank you for your detailed reply. I got it and know how to use the WDT module.

    Thanks

    Best regards

    Nick

**Attention** This is a public forum