STM32MCU Basics
STM32MCU Basics
1.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:
1.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 are 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
1.4 Cortex-M architecture
The Cortex-M portfolio includes different architectures where the main ones embedded in STM32
microcontrollers are the following:
The '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):
Armv6- Armv8-M
Armv6-M Armv7-M Armv7-M Armv7-M
Instruction set M Mainline
architecture
Thumb, Thumb-2
Pipeline stages 3 2 3 3 3 6
Memory
No Yes Yes Yes Yes Yes
Protection Unit
Maximum MPU
0 8 8 8 16 16
regions
Floating point
No No No Yes Yes Yes
hardware
AXI4, AHB
AHB Lite, AHB Lite,
Bus protocol AHB Lite AHB Lite AHB5 Lite, APB,
APB APB
TCM
Maximum #
32 32 240 240 480 240
external interrupts
1.5 STM32 Features
1.5.1 STM32 peripherals
Over the time, new peripherals are embedded to answer emergent requests on the market.
The peripheral characteristics are not frozen, the very first STM32 devices are being improved to
enable new features or fix some limitations.
The peripherals like low-power voltage detector, clock security system (CSS) and watchdogs help
supporting safety-critical applications.
The code security may be ensured thanks to some protection features of the Flash memory.
SWD (Serial Wire Debug) which can be added using 2 pins: it is designed for
micro debugging
1.5.3 STM32 resources
A dedicated webpage is available on ST website for each STM32 family. 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.
- 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.
256 Kbytes to 2
STM32F7 Cortex-M7 216 MHz
Mbytes
High
Performance
64 Kbytes to 2
STM32F4 Cortex-M4 180 MHz
Mbytes
128 Kbytes to 1
STM32F2 Cortex-M3 120 MHz
Mbyte
512 Kbytes to 2
STM32L4+ Cortex-M4 120 MHz
Mbytes
Ultra-low-power
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.
The MCUs also permit the user to run an operating system, which allows different processes to run
simultaneously. Even though they are less powerful, those features make them quite attractive for
numerous small embedded devices.
Microcontroller Microprocessor
2.2 MCUs Application
An embedded device is a combination of:
Hardware which are MCU various electronics components like sensors, and
Software which has the role of application control to perform specific tasks like analog
acquisitions for measurements and digital signal processing for controls.
As a microcontroller integrates many components on a single chip, it is well fit for small device.
Moreover, this simplifies the design while reducing the overall cost. There are lots of embedded
applications available in the market that require small processing solutions.
That is why we find MCUs:
in our today’s life (washing machine, TV, alarm clocks, remote control, IoT, touch screen
controller…)
for our health (heartbeat, blood glucose meters, energy meter, speedometer...)
security (temperature control, monitoring, cameras, alarms…).
2.3.2 Cost
Due to their small design, the microcontrollers cost less to produce and to maintain. The cost to
manufacture can be under $0.10 per unit, and the average price for a 32-bit microcontroller is less
than 1$.
Another point is that the MCU is efficient, if it does not work correctly it can easily be reprogrammed
depending on the designed application or if the application for its use needs some changes.
2.3.3 Reusable
As mentioned in the previous section, another advantage of the microcontroller is that it is
programmable so the same MCU can be reusable in different cases, options and applications just by
reprogramming it for debug. So, to change a parameter or some data there is no need to buy
another MCU, it is just about reprogramming the same MCU.
Warning
It is important to say that the previously mentioned points are not the only reasons why to use an
MCU, there are many others such as: the integrity of the MCU, add-ons having small size with
powerful features...
The first thing you need to identify is which core and family of MCU required? Moreover, the Flash
memory and RAM sizes in microcontrollers are critical options required to select the suitable ones
for graphic application. Also, it is recommended to focus on:
Display resolution
Color depth
Expected performance.
Power consumption
Memory size
Clocks frequency
Various Low-power modes: Low-power run mode, Sleep mode, Low-power sleep mode, Stop
mode, and Standby mode.
Wake-up time
Wake-up sources, that allow reducing the average current consumption of the application.
Switched-Mode Power Supply (SMPS) to reduce MCU’s current consumption
Direct memory access controller (DMA), useful to improve performance and reduce the power
Supply voltage range
Note that for Low-power applications, it is important to take into consideration current consumption,
state retention, wake-up time, wake-up sources, and any additional functionality or peripherals that
can operate in low-power mode to minimize the energy consumption.
Make a special note that the selection is based on multiple criteria and depends on the requirements
of application and which peripherals do you need:
Performance
Memory requirements
Number of Motor and Advanced Timer
OPAMP (Operational voltage amplifier)
Motor speed
Does it require a 16-bit Timer
Graphical display, so you need LCD peripheral
3.4 ST-MCU-FINDER
Thanks to the ST-MCU-FINDER tool that allows an easy search of STM32 MCU with multiple criteria
including core type, CPU frequency, memory, price, package, temperature grade and peripherals
such as control, timers, analog, connectivity, multimedia and security.
The ST-MCU-FINDER tool offers a graphic selector and simulator features that allows you to
achieve the desired performance and optimization required to select the MCU or MPU that best fits
your application needs.
In addition, this tool offers the possibility to access to data and technical documentation for a
selected device (including datasheets, reference manuals, application notes, user manuals,
programming manuals, errata sheets).
ST-MCU-FINDER tool is integrated in STM32CubeIDE and STM32CubeMX tools to select an MCU
or a development board.
You can select the device you need based on many choices as MCU Selector, Board Selector or
Cross selector and according to the requirement of your application. For example, the selection of
MCU for TouchGFX application using ST-MCU-FINDER requires the following peripherals:
DMA2D
CRC
FMC SDRAM
LTDC
select the "'MCU Selector"', which is recommended when using custom hardware to filter by
Part Number Search, Core, Series, Line, Package, price, IOs, Eeprom, Flash, RAM, Frequency
and Peripheral.
use the "'Board Selector'" for ST Discovery or Evaluation boards to match the right MCU on the
board and filter by criteria such as: Part Number Search, Type (Discovery, Evaluation Board,
Nucleo), MCU Series, Price, Oscillator Frequency and Peripheral.
use the Cross selector (PC version only) to make a comparison of a reference MCU with
approaching MCUs.
buy devices online from any mobile device or directly from the developer’s desktop
environment.
It is important for the microcontroller selection to look at the electrical characteristics, available in the
datasheet. However, this is not enough, as it is recommended to review the evaluation platform and
software tools available for an MCU.
4.2 Boards type
4.2.1 STM32 Nucleo boards
The highly affordable STM32 Nucleo boards are low-cost and easy-to-use platform developments
which allow to try out new ideas and to quickly create prototypes with any STM32 MCU because:
Cheaper
Software examples available
Extension connectors give access to most of the device’s I/Os and make the connection of add-
on hardware possible.
ST-Link debugger/programmer integrated
Access directly to GPIO
ARDUINO® connector compliant
4.2.2 STM32 Discovery kits
STM32 Discovery kits allow users to easily develop applications with the high-performance
microcontrollers. They allow either for beginners or for experienced users to get quickly started.
They are as well a cheap and complete solution for the evaluation of the outstanding capabilities of
STM32 MCUs and MPUs. They carry out the necessary infrastructure for a demonstration of specific
device characteristics; and comprehensive software examples allow to fully benefit from the devices
features and added values:
Extension connectors give access to most of the device’s I/Os and make the connection of add-
on hardware possible.
Software examples available
ARDUINO® connector compliant
Dedicated to a STM32 version
ST-Link debugger/programmer integrated
Function used to exploit main STM32 hardware functions
Display available on some boards
4.2.4 Board Features
Custom No
STMicroelectronics offers some software programs that allow the users to program and allow the
application using the boards and the MCUs:
STM32CubeIDE
STM32CubeMX
STM32CubeMonitor
X-CUBE-MCSDK...
STM32CubeMX
STM32CubeIDE
STM32CubeProg
STM32CubeMonitor
4.3.2 STM32Cube firmware
STM32Cube is a set of tools and embedded software bricks available free of charge to enable fast
and easy development on the STM32 platform which simplifies and speeds up developers’ work.
4.3.3 Hardware tools
The ST-LINK/V3 is an in-circuit debugger for the STM8 and STM32 microcontrollers. Most of the
time it is embedded on the board. If not you can use the STLinks-V3mini or STLinks-
V3SET standalone devices.