The reset sequence in ARM Cortex-M0 microcontrollers involves several steps that initialize the processor and peripherals to a known state. On power-up or when a reset pin is asserted, the Cortex-M0 goes through the following reset sequence:
1. Processor Reset
When the power supply ramps up or the reset pin is asserted, the processor immediately resets. This causes the program counter to be set to 0x00000000, the stack pointer to be set to 0x00000000, and all registers to be cleared to 0. The processor is now in a known state ready to start executing code.
2. System Initialization
After the processor resets, system initialization code provided by the MCU vendor runs to set up various system components. This typically includes:
- Configuring the clock system to provide appropriate clocks to the processor, peripherals, and external memory.
- Initializing static and dynamic memory controllers.
- Checking and initializing external RAM.
- Configuring peripheral power gates, reset control, and enabling clocks.
- Other system component configurations.
The system initialization code runs out of on-chip boot ROM or flash and executes with the stack pointer set to 0x00000000. Initialization code provided by the MCU vendor tailors the SoC for the specific chip variant and board design.
3. Vector Table Initialization
After the system initialization phase completes, the Cortex-M0 processor initializes its vector table. The vector table contains the reset value for the stack pointer and the exception/interrupt handler routines. To initialize the vector table, the processor performs the following steps:
- Load the stack pointer (SP) from the first word in the vector table. This sets the active stack pointer.
- Clear all exception/interrupt bits in the Nested Vectored Interrupt Controller (NVIC). This clears any pending interrupts.
- For each exception handler, load the address of the handler routine from the vector table into the Vector Address Register (VTOR).
After vector table initialization, the stack pointer and exception handlers are set up. The processor stack is now ready for normal use.
4. CMSIS System Initialization
At this point, the Cortex Microcontroller Software Interface Standard (CMSIS) system initialization code runs. The CMSIS system initialization code is provided by the MCU vendor or can be written by the user. It performs the following steps:
- Initialize system tick timer.
- Initialize CMSIS kernel (if used).
- Initialize heap memory (if dynamic allocation is used).
- Initialize \ content for .bss (zero-init) and .data (non-zero init) sections.
- Call into user/application initialization code.
After CMSIS system initialization completes, the processor and peripherals are fully configured. The system is now ready to run the user application.
5. Application Initialization and Main()
Once initialization completes, the reset handler calls the application main() function (if defined). The application main() function then executes user initialization code such as:
- Creating application tasks/threads.
- Launching initial processes.
- Enabling application interrupts.
- Starting scheduler (if RTOS is used).
- Transitioning into the main application.
After the main() function returns, the processor enters the main application loop. This executes the main body of the application’s code.
Reset Sources
There are several sources that can trigger a microcontroller reset sequence:
- Power-on Reset – Occurs when the power supply ramps up at initial power-up. Resets the entire system.
- External Reset Pin – Activated by driving the RST/NRESET pin low. Also resets the full system.
- Software Reset – Triggered by software writing to the Application Interrupt and Reset Control Register (AIRCR). Can reset just the core or entire system.
- Watchdog Reset – Caused by the watchdog timer expiring. Resets the full system.
- Brown-out Reset – Activated when the power supply voltage droops below a threshold. Resets the system.
- Debug Reset – Initiated by a debug host tool. Can reset just the core or full system.
The reset behavior may be slightly different depending on the type of reset initiated. However, in general the processor goes through a standard reset sequence to initialize itself.
Reset Configuration Options
There are several configuration options that impact the reset sequence behavior:
- Reset Vector – The address where the reset vector table is located. Typically at 0x00000000 in flash or 0x20000000 in SRAM.
- VTOR Register – Relocates the exception vector table address. Allows positioning the vector table other than the reset vector.
- AIRCR Register – Controls reset type (core only or system) and priority of exceptions taken after reset.
- Bootstrap Loader – Some MCUs allow a user-defined bootstrap loader to run before system initialization. This can customize early reset behavior.
- Clock Gating – Permit clocks to be gated off to various peripherals/CPU during reset to save power.
Consult the ARM Cortex-M0 user guide and MCU datasheet for the available reset configuration options. Careful configuration can optimize reset behavior for your particular application.
Debugging Reset Issues
If your Cortex-M0 application is not starting up correctly, there may be an issue with the reset configuration or sequence. Here are some techniques for debugging reset problems:
- Single step through reset code and analyze stack pointer/register values using a debugger probe to identify where code may be branching incorrectly.
- Inspect the vector table location and entries to ensure the stack pointer and exception handlers are configured correctly.
- Add debugging output (e.g. to spare GPIO pins) at different stages of the reset sequence to identify how far it gets before any issue.
- Use logic analyzer triggers on the reset pin and key signals to monitor the timing and interaction between hardware reset and code execution.
- Compare board schematics against reference designs to identify any discrepancies in reset circuitry.
- Review the datasheet and user guide to confirm correct configuration of boot pins and reset related peripheral registers.
Pay particular attention to stack pointer initialization, vector table configuration, clocking setup. and glitches on external reset signals. With careful debugging, any reset sequence issues can typically be identified and corrected.
Conclusion
In summary, the ARM Cortex-M0 microcontroller goes through a fixed reset sequence to initialize critical system components to known states. This involves processor reset, system initialization, vector table setup, CMSIS system initialization, and finally application start. Reset issues can be tricky to debug but methodically stepping through the reset sequence and analyzing behavior using debuggers and logic analyzers can help identify and correct any problems.
Properly configuring and verifying the reset sequence is key to building a robust Cortex-M0 based application. Following the standard reset procedure ensures peripherals, memory regions, interrupts, clocks, and I/O are initialized correctly so your application starts up successfully every time.