2

I have an MSP-EXP430G2ET launchboard which has msp430g2553 microcontroller. I bought it for my embedded systems course.

Lately we learned to use timers and the last lab work was using the watchdog timer in time interval mode. But while doing that I figured out my ACLK was not working properly. I check the datasheet and guide for the board and It has ACLK if I'm not mistaken. By the way when I touch the pins of the board LED blinks at different frequencies.

This is the code that I used for the watchdog timer to light a LED with a period.

#include <msp430.h>

int main(void)
{
    WDTCTL = WDTPW | WDTCNTCL | WDTIS0 | WDTSSEL | WDTTMSEL;// config watchdog timer aclk 1ms

    P1DIR |= BIT0 | BIT6; // P1.0 and P1.6 is configured as output
    P1OUT = ~BIT0 | ~BIT6; // Led P1.0 and P1.6 are turned off

    while (1){
        if (IFG1&BIT0 != 0){
            P1OUT ^= BIT0 | BIT6;
            IFG1 &= ~WDTIFG;
        }
    }
}

This code does not work. LED does not light up.

Steve Friedl
  • 3,929
  • 1
  • 23
  • 30
  • I'm not familiar with MSP430, but looking at the [docs](http://www.ti.com/lit/ug/slau399f/slau399f.pdf), isn't `WDTIS0` setting a `WDT period` of `Watchdog clock source /(2^31)`? If `ACLK` is `32.768 KHz` you will have a WDT period of `18h:12m:16s` – LPs Dec 05 '19 at 14:26
  • Thanks for the reply , I checked now and I think this documents model number is different. The one I use has only 2 bit WDTISx. And making it 0 will make the 32.768Khz clock to divide 32768 which makes it 1 second. –  Dec 05 '19 at 16:07

1 Answers1

0

From the code snippet nothing looks outrageously wrong so without a device at my disposal I will take 4 stabs in the dark.

  1. Make sure the correct msp430 is chosen in your project. msp430.h can lead to any of the msp430 headers depending on a define, a wrong one can mess with your project.
  2. I would advise using the WDT_ADLY_XXX defines to set WDT_CTL. They're more legible.
  3. It is advised that you place the watchdog in hold (WDTPW|WDTHOLD) before changing it's settings. It may be freaking out and resetting your device while you attempt to set it up.
  4. P1OUT = ~BIT0|~BIT6 has wrong operator prescience. Each NOT is done before the OR. This does not have the same effect as ~(BIT0|BIT6) which ORs them together and then NOTs.
foreverska
  • 585
  • 3
  • 20