Software reset?
Hi
Maybe a silly question, but is it possible to perform a software reset on the Industruino ?
I did find the following routine which seems to reset the harware but when my program starts it behaves in a different manner.
asm volatile (" jmp 0");
Something is not quiet right but I'm not sure what..
Thanks
The watchdog is an hardware timer that needs resetting before it overlaps, otherwise it will reset the machine. The only thing wdt_reset() does is write a zero in a register. You can put your wdt_reset() wherever you like, as long as it gets called at least every 4 seconds. My solution is to do it when Enter is not pressed, so when I keep the Enter button pressed for more than four seconds the machine restarts.
Hello Gary,
here is how I do it in my projects.
I use Watchdog timer reset.
So first include the watchdog library:
#include <avr/pgmspace.h>
#include <avr/io.h>
#include <avr/wdt.h>
Then setup the Watchdog in setup():
void loop()
{
//Enable WDT timer
wdt_enable(8); //This is equal to WTDO_4S, which is available on AT90USB1286 but probably not reported in wdt.h file
}
Then I put this line at the beginning of ReadButtons():
buttonEnterState = !digitalRead(buttonEnterPin);
buttonUpState = !digitalRead(buttonUpPin);
buttonDownState = !digitalRead(buttonDownPin);
//Reset WDT if Enter not pressed
//After 8 seconds machine will reset (actually 4)
//Also in case it hangs for other reasons
if(buttonEnterState == LOW) wdt_reset();
So if you press the Enter key for more than 4 seconds, the machine will reset.
Hope this is useful!
Hi Gary,
The most reliable way to do this is through the hardware watchdog timer. Another way is defining the function
void (*resetFunc)(void) = 0;
but that does not do a full restart (documented elsewher).
You can read more about watchdog timers at https://industruino.com/page/wdt (sorry for formatting issues)
Your answer
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
Keep Informed
About This Forum
This community is for professionals and enthusiasts of our products and services.
Read GuidelinesQuestion tools
Stats
Asked: 3/11/17, 3:43 PM |
Seen: 3399 times |
Last updated: 3/15/17, 5:00 PM |
Thanks Stefano, Tom.
My program uses interrupts on CH1, CH2 and CH3 and timing is critical as I need to measure the time between inputs..
Would using the watchdog cause any unecessary delays ?
Thanks
Gary