Fmilburn 446 Posted June 2, 2016 Share Posted June 2, 2016 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. manhdan and chicken 2 Quote Link to post Share on other sites
hmjswt 9 Posted June 2, 2016 Share Posted June 2, 2016 Hallo, This is nice. Thanks. Henk Siewert Quote Link to post Share on other sites
abecedarian 330 Posted June 2, 2016 Share Posted June 2, 2016 @@Fmilburn - Are you suggesting periodic resets as a manner of practice? As in, even if things are working, reset just "because"? Quote Link to post Share on other sites
spirilis 1,265 Posted June 2, 2016 Share Posted June 2, 2016 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... Quote Link to post Share on other sites
Fmilburn 446 Posted June 2, 2016 Author Share Posted June 2, 2016 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. abecedarian and dubnet 2 Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.