whatever9:
My application is like a game that is being played until the interrupt occurs, and then it's a "game over" and I want the game to re-initialize.How do I do a software reset?
I looked up the reset topic and people were using this code:
void softReset()
{
asm volatile (" jmp 0");
}This gives me a compiler error that "jmp 0" is a bad instruction. I'm using the Arduino Due, so maybe the inline assembly instructions are different?
Link:
http://www.nongnu.org/avr-libc/user-manual/group__avr__watchdog.html
<avr/wdt.h>: Watchdog timer handling
Defines
#define wdt_reset() asm volatile ("wdr")
#define wdt_enable(value)
#define wdt_disable()
#define WDTO_15MS 0
#define WDTO_30MS 1
#define WDTO_60MS 2
#define WDTO_120MS 3
#define WDTO_250MS 4
#define WDTO_500MS 5
#define WDTO_1S 6
#define WDTO_2S 7
#define WDTO_4S 8
#define WDTO_8S 9
#include <avr/wdt.h>
and in your interrupt routine
wdt_enable(WDTO_1S);
will do WDT *software reset" in 1 second