Go Down

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

mbedford

Hello All,

I have a need to perform a software reset via code.  This was nice and easy on all other boards besides the Due as you would just do this:
Code: [Select]
#include <avr/wdt.h>

void software_Reboot()
{
  wdt_enable(WDTO_15MS);
  while(1)
  {
  }
}


Then, all you had to do was call the method software_Reboot and the Arduino would reset.  This was perfect and exactly what I am looking for.  However, this does not work on the Due.  First of all, it appears that avr/wdt.h does not exist for the Due.

Anybody have a quick and easy way to reset the Due from code, similar to above, but that works for the Due?

Thanks!

Mike

PaulS

Quote
I have a need to perform a software reset via code.
That is extremely unlikely. More likely, you need to fix the real problem with your code.
The art of getting good answers lies in asking good questions.

AWOL

#2
Sep 01, 2015, 01:32 pm Last Edit: Sep 01, 2015, 01:33 pm by AWOL
Quote
it appears that avr/wdt.h does not exist for the Due.
(my emphasis)
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

mbedford

Quote
More likely, you need to fix the real problem with your code.
PaulS, how can you make that snide remark when you have no clue why I would need to do a reset?  There are some good reasons why one might need to do a reset even with perfect code.

Very unproductive.....thanks for nothing.

earx

check out section 14.4.4.4 of the SAM3X/A manual: http://www.keil.com/dd/docs/datashts/atmel/sam3xa/doc11057.pdf

this describes the software reset procedure.

gjt211

Hi all,

Not sure if this helps, but it helped me. I was looking for a way to properly reset the Due without using a pin, the WDT, or the jump to 0. After lots of searching the web and pouring over the SAM datasheet, the following is code should will work on any ARMv7-M architecture such as the SAM3X used on the DUE.

Add these defines to the start of your code;
Code: [Select]
//Defines so the device can do a self reset
#define SYSRESETREQ    (1<<2)
#define VECTKEY        (0x05fa0000UL)
#define VECTKEY_MASK   (0x0000ffffUL)
#define AIRCR          (*(uint32_t*)0xe000ed0cUL) // fixed arch-defined address
#define REQUEST_EXTERNAL_RESET (AIRCR=(AIRCR&VECTKEY_MASK)|VECTKEY|SYSRESETREQ)


The SYSRESETREQ is bit 2 in the AIRCR register and needs to be set to request a reset. Before this can be done, 0x05FA needs to be put into AIRCR register VECTKEY bits16:31 or the write to SYSRESETREQ will be ignored.
The final line simply puts it all together to create the actual command to reset REQUEST_EXTERNAL_RESET and could be renamed as you desire.


Use this command when you want to reset the DUE.
Code: [Select]
REQUEST_EXTERNAL_RESET;

This worked for me, but I did need to add some delay (I used 1000mS) after a Serial.println("Something to print"); as it reset before the data got out to the terminal.

Hope this helps some of you.

terryz

This Due reset code worked perfectly, thank you!

bhayanisunny

Hi gjt211,

I tried your method to write to AIRCR Register like what you showed.

But I am not able to get the RESET. By RESET, I am expecting that the setup() function will be re-executed.

I am using your code with the Native USB Port.

Please do let me know if I am doing anything wrongly.

Awaiting your reply.

Thanks,
Sunny

jot4p

Hi,

I use ntp server to update clock (RTC).

Reset works fine but my connection to ftp server not work.. it's possible to reset ethernet shield with this code ?

thanks

alarmsiren

#9
Mar 20, 2017, 12:00 am Last Edit: Mar 20, 2017, 12:05 am by alarmsiren
I've found a dead simple method for resetting the Arudino Due:

Code: [Select]
RSTC->RSTC_CR = 0xA5000005; // Reset processor and internal peripherals


Seriously, that's it.

If you want the external reset pin to also get pulled low (e.g. to reset external peripherals, like jot4p's ethernet shield) just change it to:

Code: [Select]
RSTC->RSTC_MR = 0xA5000801; // Set RST pin to go low for 256 clock cycles on reset
RSTC->RSTC_CR = 0xA5000013; // Reset processor, internal peripherals, and pull external RST pin low.


The relevant section of the datasheet is pages 223-233.

Go Up