Go Down

Topic: Arduino DUE - software reset (Read 1 time) previous topic - next topic

estratos

Does anybody know how to restart a program on Arduino DUE programmatically? I tried jumping to address 0x80000 but this simply halts the program.

Thanks in advance.

ard_newbie

#1
Oct 11, 2017, 08:42 pm Last Edit: Oct 11, 2017, 08:47 pm by ard_newbie
You can find most of the relevant information to trigger a software reset in Sam3x datasheet RSTC section. There are several ways to trigger a reset, depending on the "deepness" of the Reset.

Here is a code you can use to trigger a software Reset:

Code: [Select]

void setup(){
  Serial.begin(250000);
  Serial.println("Ready to Reset");
 }

void loop(){
  delay(2000);
 __DSB;
 SCB->AIRCR = ((0x5FA << SCB_AIRCR_VECTKEY_Pos) | SCB_AIRCR_SYSRESETREQ_Msk);//software reset
//RSTC->RSTC_CR = RSTC_CR_KEY(0xA5) | RSTC_CR_PERRST | RSTC_CR_PROCRST;
//NVIC_SystemReset();
 
}



estratos

Thanks @ard_newbie for your reply,

I indeed tried similar approaches but all of them bring the board to an undefined state where serial comms are not restarted. Anyway, thanks so much for your help.

ard_newbie

#3
Oct 13, 2017, 03:23 pm Last Edit: Oct 14, 2017, 07:44 am by ard_newbie
I suspect there is an issue somewhere in your code because you (normally) don't have to trigger a software Reset. Post your code (between code tags).


However, if Serial outputs weird characters after a Reset, you can try :

1/ To force a Reset of UART registers just before the Serial.begin() in setup():

UART->UART_CR = UART_CR_RSTRX
                 | UART_CR_RSTTX
                 | UART_CR_RSTSTA;

2/ Before triggering a software Reset in loop(), write:

Serial.flush();
Serial.end();
__DSB;
__DMB;
__ISB;

fnb111

You can find most of the relevant information to trigger a software reset in Sam3x datasheet RSTC section. There are several ways to trigger a reset, depending on the "deepness" of the Reset.

Here is a code you can use to trigger a software Reset:

Code: [Select]

void setup(){
  Serial.begin(250000);
  Serial.println("Ready to Reset");
 }

void loop(){
  delay(2000);
 __DSB;
 SCB->AIRCR = ((0x5FA << SCB_AIRCR_VECTKEY_Pos) | SCB_AIRCR_SYSRESETREQ_Msk);//software reset
//RSTC->RSTC_CR = RSTC_CR_KEY(0xA5) | RSTC_CR_PERRST | RSTC_CR_PROCRST;
//NVIC_SystemReset();
 
}



Thanks for this. It works like a charm.

Go Up