SoC
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
  • Arm Cortex M3
  • Contact
Reading: What will happen when reset is executed in ARM Cortex-M based microcontroller?
SUBSCRIBE
SoCSoC
Font ResizerAa
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Search
  • Home
  • Arm
  • Arm Cortex M0/M0+
  • Arm Cortex M4
Have an existing account? Sign In
Follow US
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
© S-O-C.ORG, All Rights Reserved.
Arm

What will happen when reset is executed in ARM Cortex-M based microcontroller?

Ryan Ryan
Last updated: September 13, 2023 3:48 am
Ryan Ryan 6 Min Read
Share
SHARE

When the reset is executed on an ARM Cortex-M based microcontroller, the processor will restart and reload the program counter to the start of the code memory. This resets the entire state of the microcontroller including all registers, peripherals, and program flow. The reset reinitializes the device to its power-on state.

Contents
Detailed Reset SequenceReset SourcesReset Handler ExecutionUsing ResetCommon Reset IssuesDebugging Reset IssuesSummary

Detailed Reset Sequence

Here are the key things that happen during a reset in an ARM Cortex-M microcontroller:

  • The Cortex-M processor core resets, which resets all core registers like program counter, stack pointer, and general purpose registers back to their initial values.
  • The Nested Vectored Interrupt Controller (NVIC) is reset, clearing any pending interrupts or active exception processing.
  • All peripherals like timers, UARTs, I/O ports are reset back to their default configuration. Any pending states are cleared.
  • Internal clocks used by the processor core, bus matrix, and peripherals are reinitialized.
  • The system clock source is switched to the default out of reset.
  • Flash memory and RAM controllers are reset, reinitializing any wait states or timings.
  • The program counter is set to point to the start of the code memory, which contains the reset vector table.
  • The Cortex-M processor executes the reset vector, starting execution at the reset handler function.

Reset Sources

There are several sources that can trigger a microcontroller reset:

  • Power-on reset – Generated on initial power-up of the microcontroller.
  • External reset pin – Activated by driving the nRESET pin low.
  • Software reset – Executed by software writing to the AIRCR register in the NVIC.
  • Watchdog reset – Caused by the watchdog timer expiring.
  • Brown-out reset – Triggered by the supply voltage falling below a safe operating level.
  • Debug reset – Issued by an external debugger tool.

Reset Handler Execution

After a reset, the Cortex-M processor will start executing code at the beginning of the reset handler function. This function is usually defined at the start of the code memory, pointed to by the reset vector.

A typical reset handler will perform tasks like:

  • Set up the stack pointer for the processor mode it will run in.
  • Copy initialized values from ROM to RAM if necessary.
  • Configure clock sources and PLLs.
  • Initialize memory controllers and wait states.
  • Configure I/O ports and peripherals.
  • Clear any pending interrupts.
  • Branch to the main application.

The reset handler runs with interrupts disabled initially. It needs to set up the necessary system state before it can re-enable interrupts and transition to the main application.

Using Reset

Resetting an ARM Cortex-M microcontroller is a useful technique for the following reasons:

  • Recover from crashes – A reset can bring the system out of a lock-up or malformed state.
  • Initialize on power-up – The first reset on boot puts the microcontroller in an initialized state.
  • Transition between firmwares – A reset synchronizes the system when changing firmware images.
  • Cleanup state – Resets peripheral states which can be useful when testing configurations.
  • Entry point for debugging – Debuggers use reset to halt execution and get control.

Here are some examples of how reset can be used:

  • Trigger a reset in firmware with a sysreset request when a severe error occurs.
  • Press an external reset button to revive a crashed system.
  • Use a watchdog reset to recover from a fault that hangs the processor.
  • Perform a debug reset through JTAG/SWD when debugging code.
  • Reset before jumping to a bootloader to update the main firmware image.

Common Reset Issues

Some common issues that developers may encounter with reset include:

  • Forgetting to reconfigure peripherals after reset, leading to defaults which may cause issues.
  • Neglecting to re-enable interrupts soon enough after reset, impacting system response.
  • Stack corruption from not initializing the stack pointer correctly on reset.
  • Leaving wake-up sources enabled that can wake processor immediately after reset.
  • Uninitialized variables if reset handler does not handle copied RAM variables.
  • Reset not deasserting and getting stuck in reset if reset duration is too short.

Debugging Reset Issues

Debugging reset related issues on Cortex-M microcontrollers can be performed by:

  • Single stepping through reset handler code to validate correct setup sequence.
  • Inspecting stack pointer alignment and RAM contents after reset.
  • Checking peripheral registers to confirm reset values.
  • Monitoring reset and clock signals using an oscilloscope.
  • Measuring reset duration and voltage thresholds.
  • Verifying reset vector loaded address is as expected.
  • Tracing through alternate reset paths like soft reset.
  • Testing reset with voltage supply perturbations.

Debuggers and development boards with external monitors and probes provide visibility into reset behavior. Monitoring tools like logic analyzers can capture reset timing characteristics.

Summary

In summary, reset is a fundamental mechanism used to restart ARM Cortex-M based microcontrollers in a known initialized state. It resets the processor core, peripherals, and interrupts while reinitializing clocks and memories. Executing the reset handler starts the software from a known point. Reset allows systems to recover from faults and provides an entry point for debuggers. Careful handling of reset ensures proper device operation.

Newsletter Form (#3)

More ARM insights right in your inbox

 


Share This Article
Facebook Twitter Email Copy Link Print
Previous Article What is the difference between ARM Cortex-M0 and M3?
Next Article What is ARM reset handler?
Leave a comment Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

2k Followers Like
3k Followers Follow
10.1k Followers Pin
- Sponsored-
Ad image

You Might Also Like

What is watchdog software used for?

Watchdog software refers to programs that monitor the status of…

8 Min Read

Will Arm Replace X64?

The short answer is that while Arm is making inroads…

5 Min Read

What are the 3 Major Components in ARM Processors?

ARM processors are central processing units (CPUs) based on the…

10 Min Read

ARM Cortex-M0 SPI outputting 16bit not 8bit

When configuring the SPI (Serial Peripheral Interface) on an ARM…

8 Min Read
SoCSoC
  • Looking for Something?
  • Privacy Policy
  • About Us
  • Sitemap
  • Contact Us
Welcome Back!

Sign in to your account