How to Reset an ARM Cortex-M with Software

There are cases when I need to do a reset of the device by software. For example I have loaded the application image with the bootloader, and then I need to perform a reset of the microcontroller to do a restart. As a human user I can press the reset button on the board. But how to do this from the software and application running on the board, without user manual intervention? Or if I simply want to reset the system for whatever reason?

Performing a Software System Reset with Kinetis Design Studio

Performing a Software System Reset with Kinetis Design Studio

Using Watchdog Timeout

In the past I have used the following approach for other microcontroller (e.g. the Freescale S08 and S12 devices):

  1. Setting up a watchdog timer
  2. Then when I want to do a reset, I do *not* kick (serve) the watchdog timer any more
  3. As a result, the WDT (watchdog timer) or COP (Computer operating properly) will timeout, and will reset the part

That approach is working, but well is not the easiest way. Especially as on ARM Cortex-M there is a better way :-).

Using ARM System Reset

The ARM Cortex-M which includes the Freescale Kinetis series cores have a System Reset functionality available in the AICR (Application Interrupt and Reset Control Register):

AIRCR Register (Source: ARM Infocenter)

AIRCR Register (Source: ARM Infocenter)

So all I need to write a 0x05FA to VECTKEY with a 1 to SYSRESETREQ :-).

The easiest way is if I used the KinetisTools Processor Expert component from SourceForge (see “McuOnEclipse Releases on SourceForge“):

KinetisTools Processor Expert Component

KinetisTools Processor Expert Component

This componet offers a SoftwareReset() function which I can use in my application. It is defined like this in the component:

void KIN1_SoftwareReset(void)
  /* Generic way to request a reset from software for ARM Cortex */
  /* See
     To write to this register, you must write 0x5FA to the VECTKEY field, otherwise the processor ignores the write.
     SYSRESETREQ will cause a system reset asynchronously, so need to wait afterwards.
  for(;;) {
    /* wait until reset */

So all what you need is to have such a piece of code in your application to do a system reset.

That component features as well an optional command line interface. That way I can reset the target with a command from the shell 🙂

Reset System from the Shell

Reset System from the Shell


To reset an ARM Cortex M by software, I can use the AIRCR register. Either I can do this directly, or using my KinetisTools component for Processor Expert :-).

As an additional note: there is a sticky ‘System Reset Status’ register available (I think on most Kinetis devices) which reports the reason for the reset. A good idea is to read that register at startup time and e.g. print the reset reason to the console (Thanks Charles for that cool idea!).

Happy resetting 🙂



27 thoughts on “How to Reset an ARM Cortex-M with Software

  1. Pingback: McuOnEclipse Components: 05-July-2015 Release | MCU on Eclipse

  2. I am extrapolating from this that KDS provides no command to reset the processor from either the menu system or the toolbar? I have spent most of my career using classical embedded tools and am still sometimes taken aback by the things Eclipse cannot do.

    I have used one other Eclipse derivative (Code Composer Studio) and that feature was built in.


  3. Ok, I did find that, but the description text: (Restart a process or debug target without terminating and re- launching) was so abstruse, I didn’t recognize it.

    Thanks, Erich!


  4. This reset usualy works for us, but sometimes it doesn’t… I’ve noticed that the user guide says: SYSRESETREQ -> asserts a proc_reset_signal.
    This is intended to force a large system reset of all major components **except for debug**.

    What does it mean? Debug means that I am currently debugging using a JTAG, or does it mean that I am running a “debug” configuration compiled image?

    Also, I’ve found that the AIRCR register has two more bits:
    VECTRESET & VECTCLRACTIVE, which we should reset whenever we write to this register, “otherwise behavior is Unpredictable”. Can this be the case…?



    • Hi Lior,
      it means that it does not reset the debug logic on the chip (has nothing to do with hardware).
      I have not seen any issues on my side with the proposed way.

      I see this note:

      SYSRESETREQ is cleared by a system reset, which means that asserting VECTRESET at the same time may cause SYSRESETREQ to be cleared in the same cycle as it is written to. This may prevent the external system from seeing SYSRESETREQ. It is therefore recommended that VECTRESET and SYSRESETREQ be used exclusively and never both written to 1 at the same time.


      • Thanks, Erich!
        So, in other words, is it recommended to clear both bits (VECTRESET & VECTCLRACTIVE) at the same time that I set SYSRESETREQ – in order to prevent it to interfere with the reset action?


  5. Hey,
    I’ve noticed that maybe there is another option for Cortex-M3, which is to use RSTC_CR.
    Have anyone tried this option?



  6. Pingback: Debugging ARM Cortex-M0+ HardFaults | MCU on Eclipse

  7. HI! I had a problem with de watchdog. I initialize the watchdog, I do not refresh in the loop and the core doesn t reset. All the registers are initialize ok beacause y see them in the debuger.
    ¿Does anyone know if there is another register to enable the clock or something similar?


    • Which device, and which debugger? The watchdog functions depend on the device implementation, and I have seen debuggers which disable the watchdog (so you can debug).
      Do you have the same if you run the board without the debugger?


  8. Hi, thanks for your great posts! I’m getting an error when I try to Generate Processor Expert Code:
    “Description Resource Path Location Type
    Generator: FAILURE: at line 72: “Shell”/Shell has not assigned the component (file: Drivers\sw\KinetisTools.drv) WT4 KIN1 Processor Expert Problem”

    If I tick the checkbox to use a shell (and add the required components for that) then it builds just fine. The problem seems to only occur when I try to use the KinetisTools without a shell. Any suggestions?


What do you think?

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.