Home / Learn Chip Programming / ARM Cortex-M Architecture: M0 to M7
ARM Cortex-M Architecture: M0 to M7
The core inside STM32, RP2040, nRF52 and hundreds of other chips.
Theory in plain words
What it is
Cortex-M is a 32 bit RISC core family with Thumb-2 instructions, a nested vectored interrupt controller (NVIC), SysTick timer, and a fixed memory map. M0/M0+ are smallest, M3/M4 add speed and DSP/FPU, M7 adds cache and dual issue, M33 adds TrustZone.
Why we use it
One core architecture means one toolchain and the same debug interface for almost every modern MCU. Learn it once, use it everywhere.
How it works
Registers R0-R12, SP (MSP/PSP), LR, PC, xPSR. On reset the core loads SP and PC from the vector table. Interrupts push 8 registers automatically and return with a special LR value.
Where it is used
- STM32, RP2040, nRF52, SAMD, LPC
- Bare-metal and RTOS firmware
- Interviews: exception model
Exception entry
Because hardware saves the registers, an ISR is a normal C function: no special attribute needed on Cortex-M.
| Core | Max clock (typ) | FPU | MPU | Typical chip |
|---|---|---|---|---|
| M0+ | 48 to 133 MHz | no | optional | RP2040, STM32G0 |
| M3 | 72 to 120 MHz | no | opt | STM32F1 |
| M4F | 80 to 180 MHz | single | opt | STM32F4, nRF52 |
| M7 | 216 to 600 MHz | double | yes | STM32F7/H7, i.MX RT |
| M33 | 110 to 250 MHz | single | yes | STM32L5/U5, RP2350 |
- MSP / PSP: main stack for exceptions, process stack for RTOS tasks.
- Thread vs handler mode: your main code is thread mode; ISRs run in handler mode.
- Priorities: lower number = more urgent. NVIC supports preemption levels.
- SysTick: 24 bit down counter for the RTOS tick, same on every Cortex-M.
Quick quiz
1. How many registers does hardware push on exception entry?
R0-R3, R12, LR, PC, xPSR.
2. Lower priority number means...
Priority 0 is highest.