Hi there, I am trying to use the MSP430 watchdog in watchdog mode but am currently having no success.
I have this little program to demostrate. It is meant to prove that I can correctly reset the Watchdog counter before it resets the device, but it failes and is always resetting.
Your intention at that point is (I think) to send the WDTCTL the password 0x5A00 plus the bit pattern so that (a) the WDT will use the SMCLK and generate a RST after 32768 counts, (b) with the WDT couner cleared, (c) without NMI enabled, (d) without NMI edge select, and (e) without holding the WDT. Thus what you need to do is:
WDTCTL = 0x5A08;
If you look at the TI header file, WDT_MRST_32 is defined to be 0x5A08. So:
WDTCTL = WDT_MRST_32;
is the same as:
WDTCTL = 0x5A08;
and will have exactly the same effect. It does not include the WDTHOLD bit. It does not include the WDTNMI bit or the WDTNMIES bit.
BUT, the actual code you used include the additional term +~WDTHOLD.
This, means +0xFF7F and you get the same effect as:
WDTCTL = 0x5A08 + 0xFF7F;
which is the same as:
WDTCTL = 0x5987;
This is not what you wanted and the password part is wrong too!
(I think) in your mind, ~WDTHOLD means without the WDTHOLD bit. But the c-compiler took it as “all the other bits except the WDTHOLD bit”. When you add that, the you changed everything!