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.

Watch Dog



Hi friends,

i have a doubt.

y we need to put this line   WDTCTL = WDTPW + WDTHOLD;

wht is the function of watchdog. y we need to stop this during the timer operations.

and

wht is the use of this line 

_BIS_SR(LPM3_bits);  

at the end of the code.

please reply me ASAP

by

S.Sivakumar

  •     "y we need to put this line   WDTCTL = WDTPW + WDTHOLD;"

    Watchdog Timer control: that is used to exit loop of infinity. It is a register that is set to max of 1 sec. It reset the controller when the interrupt is generated.

    It works like simple timer except reset instruction.and remember it doesn't work in all LPM.

    _BIS_SR(LPM3_bits);  

    _BIS_SR - it is register that is used to enable interrupt and low power modes.
    LMP3 activate low power mode 3 where CPU off,MCLK off,SMCLK off,DCO OFF and only ACLK(32.768 KHz external crystal ON.
  • The primary function of the watchdog timer (WDT_A) module is to perform a controlled system restart after a software problem occurs. If the selected time interval expires, a system reset is generated. If the watchdog function is not needed in an application, the module can be disabled.

    WDTPW is the password that unlocks the control register. WDTHOLD stops the timer.

    _BIS_SR(LPM3_bits);

    _BIS_SR() is an intrinsic instruction that tells the compiler to set the corresponding bits in the status register (SR, also called R2). Note the the inverse operation (Bit Clear) is _BIC_SR()

    LPM3_bits is a pre-processor macro that expands to include all the bits that get set for LPM3 low-power mode. These are SCG1+SCG0+CPUOFF on the 5xx & 6xx devices.

  • Brian Boorman said:
    The primary function of the watchdog timer (WDT_A) module is to perform a controlled system restart after a software problem occurs.

    Not if a software problem occurs. Even though many lazy programmers think it is a viable way to restart the system when it crashed due to a software bug or software design flaw.

    It is meant to reset the processor if it isn't running anymore. This includes of course rampaging code, but it's main purpose is to recover from a CPU hardware crash due to a (non-destructive) ESD or other hardware events that make the CPU stop working.

**Attention** This is a public forum