Jump to content
Sign in to follow this  
Fmilburn

Resetting a MSP430 from within Energia

Recommended Posts

I have an Energia project that seems to go astray under rare and seemingly random circumstances - it can occur anywhere from hours to months apart and I haven't been able to pin the cause down.  It starts right up again after a reset.  It isn't critical if it is down for a minute or so but I am usually not around to reset it manually.  However, I can monitor things in the firmware and tell when things are not working correctly.

 

In this situation it is easy enough to force a reset from Energia by writing to the watchdog timer and control register with an improper password.  For example, in the following sketch the green LED will not turn on and the red LED will start flashing again after the reset.

void setup()
{
  pinMode(RED_LED, OUTPUT);
  pinMode(GREEN_LED, OUTPUT);
  digitalWrite(RED_LED, LOW);
  digitalWrite(GREEN_LED, LOW);
}

void loop()
{
  unsigned int i;
  for (i = 1; i < 5; i++) {
    digitalWrite(RED_LED, HIGH);
    delay(500);
    digitalWrite(RED_LED, LOW);
    delay(500);
  }

  WDTCTL = 0x00;                         // causes a reset

  for(; {
    digitalWrite(GREEN_LED, HIGH);       // this line is never reached
  }
}

Note:  This is not using the watchdog timer in the normal fashion as Energia uses it for other timing functions.  It is just a easy way to force a reset if needed.

Share this post


Link to post
Share on other sites

Thanks for the feedback.

 

 

@Fmilburn - Are you suggesting periodic resets as a manner of practice? As in, even if things are working, reset just "because"?

No, I have never had reason to consider doing this before and it is the result of a specific issue.   The example may be misleading.   A reset would be initiated in the project only if an error situation is detected.  Although now that I think about it, giving it a kick in the seat of the pants every once in a while just to let it know who is boss might be good :)

 

 

Of course it raises the question of whether a hardware reset is doing more for you than you think e.g. delatching stuck logic gates from electrical issues in the project...

Agreed.  The problem is of an intermittent and infrequent nature and I haven't been able to trap it and determine the cause.  In fact, and I should have mentioned this in the first post, it has not reoccurred since this idea occurred to me.

 

I thought it an interesting approach though and did a quick search of 43oh and didn't see it anywhere else, although I could have overlooked it, and thought it worth posting.

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
Sign in to follow this  

×