johnsondavies

Help getting watchdog to work

3 posts in this topic

I am trying to set up a watchdog timer on the MSP430F5529 LaunchPad, and I can't seem to get it to work.

My code is:

void watchdogenable (int interval) {
  WDTCTL = WDTPW | WDTCNTCL | interval;
}

void watchdogreset () {
  WDTCTL = WDTPW | WDTCNTCL | (WDTCTL & 0x07);
}

void setup() {
  Serial.begin(9600);
  Serial.println("Start");
  watchdogenable(1);
}

int count = 0;

void loop() {
  Serial.println(count++);
  delay(1000);
}

It prints:

Start
0

and then gets no further before being reset by the watchdog 8 seconds later. I would expect it to count up to 8.

If I take out the delay() statement it seems to work properly.

Any suggestions?

Share this post


Link to post
Share on other sites

With SMCLK running at about 1 MHz, and a divider of 1 = WDTIS__128M, the expiration should happen after about 134 seconds.

Anyway, Energia uses the watchdog interval timer interrupt to implement micros() and delay().

Share this post


Link to post
Share on other sites
6 minutes ago, Clavier said:

Anyway, Energia uses the watchdog interval timer interrupt to implement micros() and delay().

Thanks. So there's no way I can use the watchdog in an Energia project (and use delay() etc)?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now