0

Software reset a Feather M0
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Software reset a Feather M0

by roadfun on Wed Oct 04, 2017 10:13 am

Is there a way to either reset the M0 from software or at least completely restart the software running on the M0? I've found ways to do it for the typical Arduinos but nothing specific to the M0.

Thanks.

roadfun
 
Posts: 133
Joined: Tue Apr 05, 2011 6:21 pm

Re: Software reset a Feather M0

by adafruit_support_mike on Thu Oct 05, 2017 1:38 am

That's an impressively well-hidden detail of the ARM support code.

The ARM core is really just a hardware design companies can license to build their own chips, but there's a standard set of code to work with the core called the 'Cortex Microcontroller System Interface Standard' or 'CMSIS'. All devices that contain an ARM core should interact with the CMSIS in the same way.

One command in the CMSIS suite is NVIC_SystemReset(), which should do what you want.

'NVIC' is the ARM core's 'Nested Vector Interrupt Controller'. Resets are triggered by interrupts, so the NVIC is responsible for that kind of behavior. 'Nested' means interrupts have priority levels, and higher-priority interrupts can suspend lower-priority ones.

You have to wade through a *lot* of "your princess is in another castle" documentation to find all of that.

adafruit_support_mike
 
Posts: 45751
Joined: Thu Feb 11, 2010 2:51 pm

Re: Software reset a Feather M0

by roadfun on Thu Oct 05, 2017 7:33 am

I had visited many castles in search of my princess. I discovered references to CMSIS and also to a few about twiddling register bits but not the call you provided. This is a *huge* help! Going to give it a try today.

roadfun
 
Posts: 133
Joined: Tue Apr 05, 2011 6:21 pm

Re: Software reset a Feather M0

by adafruit_support_mike on Fri Oct 06, 2017 3:37 am

Yeah, I think the path to that one led through a book on the ARM M0+ architecture for a general description of the NVIC and CMSIS, the SAMD21 datasheet for the hooks relevant to the chip itself, the ARM M0+ reference manual and programmer's manual for the kinds of interrupt that exist, and finally the CMSIS documentation itself.

The microcontroller architecture is great, but the documentation tends to be fragmented.

adafruit_support_mike
 
Posts: 45751
Joined: Thu Feb 11, 2010 2:51 pm

Re: Software reset a Feather M0

by roadfun on Fri Oct 06, 2017 6:10 am

“You’re in a maze of twisted little passages, all alike”. Thanks again, I implemented that call yesterday and it seems to be working perfectly.

roadfun
 
Posts: 133
Joined: Tue Apr 05, 2011 6:21 pm

Re: Software reset a Feather M0

by PaulRowntree on Fri Oct 06, 2017 6:31 am

How do you find where code marvels like this live, to see what others are available?

PaulRowntree
 
Posts: 198
Joined: Sun Apr 03, 2016 12:41 am

Re: Software reset a Feather M0

by adafruit_support_mike on Sat Oct 07, 2017 2:21 am

I had to buy the book: _The Definitive Guide to ARM Cortex-M0 and Cortex-M0+ Processors_ by Joseph Yiu. It's a good description of all the stuff that doesn't show up in a specific chip's datasheet, like, "how does the microcontroller actually work?"

You can get the SAMD21 datasheet from Atmel/Microchip, and there are versions linked from the Downloads page of the Feather M0 tutorials.

The rest is ARM's own documentation. You have to register to get access, but it doesn't cost anything and they don't fill your inbox with spam.

That's where you're likely to be eaten by a Grue.. it's like they wrote a single useful reference with lots of cross-references for each processor family, split them out so each chapter was a separate document, gave all the chapters that cover the same kind of information the same name, combined chapers that say mostly the same thing into single documents referenced from everywhere, published new versions of various chapters every couple of years but kept all the names the same, built a website that breaks the pages into a deeply-nested one-print-page-per-webpage monstrosity, then buried the links to PDFs of a whole chapter (including all the older versions) in the deepest parts of the link tree.

Even when you've adventured long enough to collect all the PDFs, you can expect to have four or five documents open at the same time when you're trying to track down a specific piece of information.

The processor designs are great, and ARM was involved in the business deal that put the Arduino organization back on its feet, so they generate good karma in lots of ways. Entry-level documentation just isn't at the top of the list.

adafruit_support_mike
 
Posts: 45751
Joined: Thu Feb 11, 2010 2:51 pm

Re: Software reset a Feather M0

by jaycollett on Wed Oct 11, 2017 12:13 pm

roadfun wrote:“You’re in a maze of twisted little passages, all alike”. Thanks again, I implemented that call yesterday and it seems to be working perfectly.


Do you mind sharing your code? I'm having some issues with my feather and this seems like a possible band-aid until I can debug what's happening...

jaycollett
 
Posts: 60
Joined: Thu Jan 07, 2010 10:53 pm

Re: Software reset a Feather M0

by roadfun on Wed Oct 11, 2017 12:26 pm

It's just a single call. So whenever you decide you want to do a reset you call this:
Code: Select all | TOGGLE FULL SIZE
    NVIC_SystemReset();

roadfun
 
Posts: 133
Joined: Tue Apr 05, 2011 6:21 pm

Re: Software reset a Feather M0

by jaycollett on Wed Oct 11, 2017 12:32 pm

roadfun wrote:It's just a single call. So whenever you decide you want to do a reset you call this:
Code: Select all | TOGGLE FULL SIZE
    NVIC_SystemReset();


Wow, sometimes it the simplest things that get over-engineered...thank you!

jaycollett
 
Posts: 60
Joined: Thu Jan 07, 2010 10:53 pm

Re: Software reset a Feather M0

by gertvb on Thu Dec 07, 2017 3:54 am

Thanks everyone!!

This is really a great help

gertvb
 
Posts: 6
Joined: Fri Jan 16, 2015 3:35 am

Please be positive and constructive with your questions and comments.