On this page you will find the basic knowledge for microcontrollers
1. Simple definition of a Microcontroller
A microcontroller (also called μC or MCU) is an embedded computer chip that controls most of the electronic gadgets and appliances people use on a daily basis.
It is a compact integrated circuit designed to govern a specific operation in an embedded system.
2. Microcontroller architecture
A typical microcontroller includes a processor, memory and Input/Output (I/O) peripherals on a single chip. Its components may be extended to include: Digital I/O, Analog I/O, Timers, Communication interfaces, Watchdog (a timer that is responsible for the detection of timed out or locked instruction).
A processor is a little chip present in the device that has the role of arranging the instructions and order the outputs.
The manufacturer defines the integrated peripherals and the hardware capabilities.
This is the basic layout of a microcontroller:
File:layout.jpg
3. STM32 overview
STMicroelectronics is manufacturing the STM32 MCUs which are based on the Arm® Cortex®-M processor. They are 32-bit RISC ARM processor cores, optimized for cost and power sensitive MCUs.
RISC ARM (Reduced Instruction Set Computer) is an instruction set that allows to divide the commands into several, simple and not complicated instructions that everyone is meant to realize small objectives.
The STM32 family offers a large range of devices combining:
- Full integration
- Ease of development thanks to the large ecosystem and professional development tools including free ones
- Very high performance thanks to ARM Cortex-M core and ST ART Accelerator™ for some families
- Real-time capabilities
- Digital signal processing
- Low-power and low-voltage operation
- Connectivity
- Graphic features
Several applications rely on STM32 (to be detailed in next chapter):
- Industrial control systems
- Human interface devices
- Smart metering
- Motor control
- Medical instruments
- Buildings & security (alarms, access control, power meters…)
- Consumer products (PC peripherals, GPS, gaming…)
- Internet of Things
- Connectivity
- …
4. Cortex-M architecture
The Cortex-M portfolio includes different architectures where the main ones embedded in STM32 microcontrollers are the following:
Nested Vectored Interrupt Controller is used to organize the interruptions in order to reduce the suspensions.
The Wakeup Interrupt Controller (WIC) is a way to detect an interruption and wake the processor from the sleep mode
Cortex-M comparison table (from ARM):
Feature | Cortex-M0 | Cortex-M0+ | Cortex-M3 | Cortex-M4 | Cortex-M33 | Cortex-M7 |
---|---|---|---|---|---|---|
Instruction set architecture | Armv6-M | Armv6-M | Armv7-M | Armv7-M | Armv8-M Mainline | Armv7-M |
Thumb, Thumb-2 | ||||||
Pipeline stages | 3 | 2 | 3 | 3 | 3 | 6 |
Memory Protection Unit | No | Yes | Yes | Yes | Yes | Yes |
Maximum MPU regions | 0 | 8 | 8 | 8 | 16 | 16 |
Trace (ETM or MTB) | No | MTB | ETMv3 | ETMv3 | MTB and/or ETMv4 | ETMv4 |
DSP | No | No | No | Yes | Yes | Yes |
Floating point hardware | No | No | No | Yes | Yes | Yes |
Bus protocol | AHB Lite | AHB Lite | AHB Lite, APB | AHB Lite, APB | AHB5 | AXI4, AHB Lite, APB, TCM |
Maximum # external interrupts | 32 | 32 | 240 | 240 | 480 | 240 |
CMSIS Support | Yes |
More details about Cortex-M processors are available on:
Arm Cortex-M Series Processors
Cortex-M resources
5. STM32 Features
5.1. STM32 peripherals
Over the time, new peripherals are embedded to answer emergent requests on the market.
Peripherals characteristics are not frozen; the very first STM32 devices are being improved to enable new features or fix some limitations.
Peripherals like low power voltage detector, clock security system (CSS) and watchdogs help supporting safety-critical applications.
Code security may be ensured thanks to some protection features of the Flash.
5.2. STM32 Packages
Power supply
It is required to power on your device to make it start working.
Oscillators
STM32 embeds an internal RC oscillator, but it is not accurate and stable as an external crystal.
Debug
After programming the MCU, the next step is to debug the code which means to reconsider it and try to resolve any defect that may interrupt the use of the MCU, and this is realized within a software program called Debugger.
While using a software IDE, a debugger is installed by default, but once developing the application of the MCU, a hardware debugger is needed. Depending on the supported debug system, it is possible to connect a debugger to the device and here are two examples:
- SWD (Serial Wire Debug) which can be added using 2 pins: it is designed for micro debugging
- JTAG (Joint Test Action Group) within 5 or 4 pins: it is designed for checking faults in boards in production.
5.3. STM32 resources
Each line in an STM32 family has its own web page on ST website. It contains all relevant documents and resources to guide the end-user on how to start developing with selected STM32 device and exploit it in an efficient way for user’s application.
The main relevant documents are:
- Datasheet (DS): the document describing the electrical characteristics of the product and its pinout
- Errata sheet (ES): the document that specifies the known limitations of the product and the ways to work them out if available.
- Reference manual (RM): the document providing the product specification and describing its registers
6. Varieties of STM32 MCUs
On 2020 Q2, there are already 16 Cortex-M based microcontroller families (or series).
The STM32 families are split into 4 groups divided as follows:
Family | Core | Max Frequency | Flash | |
---|---|---|---|---|
High Performance | STM32H7 | Cortex-M7 Cortex-M4 | 480 MHz 240 MHz | 1 to 2 Mbytes |
STM32F7 | Cortex-M7 | 216 MHz | 256 Kbytes to 2 Mbytes | |
STM32F4 | Cortex-M4 | 180 MHz | 64 Kbytes to 2 Mbytes | |
STM32F2 | Cortex-M3 | 120 MHz | 128 Kbytes to 1 Mbyte | |
Mainstream | STM32G4 | Cortex-M4 | 170 MHz | 32 to 512 Kbytes |
STM32F3 | Cortex-M4 | 72 MHz | 16 to 512 Kbytes | |
STM32F1 | Cortex-M3 | 72 MHz | 16 Kbytes to 1 Mbyte | |
STM32G0 | Cortex-M0+ | 64 MHz | 16 to 512 Kbytes | |
STM32F0 | Cortex-M0 | 48 MHz | 16 to 256 Kbytes | |
Ultra-low-power | STM32L5 | Cortex-M33 | 110 MHz | 256 to 512 Kbytes |
STM32L4+ | Cortex-M4 | 120 MHz | 512 Kbytes to 2 Mbytes | |
STM32L4 | Cortex-M4 | 80 MHz | 64 Kbytes to 1 Mbyte | |
STM32L1 | Cortex-M3 | 32 MHz | 32 to 512 Kbytes | |
STM32L0 | Cortex-M0+ | 32 MHz | 8 to 192 Kbytes | |
Wireless | STM32WB | Cortex-M4-Cortex-M0+ | 64 MHz -32 MHz | 256 Kbytes to 1 Mbyte |
STM32WL | Cortex-M4 | 48 MHz | 64 Kbytes to 256 Kbytes |
The STM32 portfolio continues to be extended with more integration and performance and more complex peripherals. All ones with generic or dedicated application field.
The previous table helps to select the family of MCUs suitable depending on application needs, but it’s required to review deeply the product characteristics and components to fine-tune the choice.
[[Category:STM32 step by step]]