Atlas Robotics
MicrocontrollersIntermediate

What is STM32? Professional ARM microcontrollers widely used in industry

Atlasbot · 20/8/2026 · 11 min read

What is STM32? Professional ARM microcontrollers widely used in industry
STM32 has many chip lines from cheap M0 to high-performance M7

When a project needs high reliability, precise real-time performance, or deeper hardware control than the Arduino/ESP32 abstraction allows, the STM32 — the ARM Cortex-M microcontroller line from STMicroelectronics — is the most popular choice, especially in industrial environments.

What is STM32

STM32 is not a single chip but a whole family of microcontrollers based on the ARM Cortex-M core, divided into several lines according to performance segments — from Cortex-M0 (simple, cheap) to Cortex-M7 (high performance, can run up to several hundred MHz with specialized floating-point computing units). This variety allows choosing the right chip to suit each project's requirements and budget, instead of "one size fits all" like the basic Arduino ecosystem.

  • Very detailed technical documentation — each chip has a reference manual hundreds to thousands of pages long, accurately describing each register, latency, electrical characteristics — important for applications requiring high reliability.
  • Rich dedicated peripherals — multiple independent timers, multiple high-resolution ADC/DAC channels, CAN bus communication (common in industrial/automotive), and many detailed power saving features.
  • Stable supply, diverse distributors — important for high-volume production, unlike hobby boards that can have supply interruptions.

HAL vs direct register manipulation

STM32 can be programmed at two different levels of abstraction:

  • HAL (Hardware Abstraction Layer) — the official library of STMicroelectronics, the abstraction level is similar to Arduino but more detailed and flexible (eg: HAL_GPIO_WritePin() seen in the previous GPIO article) — suitable for fast development, easy to read.
  • Direct register manipulation (register-level) — write directly to hardware registers according to memory addresses described in the reference manual — maximum performance, precise control of each clock cycle, but requires a deep understanding of the specific chip architecture and is much more difficult to read.

In short: STM32 allows choosing the appropriate level of abstraction — HAL for speed of development, direct registers for maximum performance/control — unlike Arduino which only has 1 fixed level of abstraction.

Configuration tool: STM32CubeMX

STMicroelectronics provides STM32CubeMX — a tool to configure pins and peripherals with a graphical interface (choose which pin to use as UART, which pin to use as PWM...), then automatically generate initialization code (init code) according to the selected configuration - significantly reducing the effort of manually checking registers when starting a new project.

Technical details

Formulas

The actual clock given to the CPU/peripherals on the STM32 is not a fixed value but is calculated through the frequency multiplier/divider PLL (Phase-Locked Loop) — this is why "clock tree" is a must-understand concept when configuring the STM32 (mentioned in the Common Errors section below):

Fout = Fin × (N / M) / P

For example: external quartz Fin = 8MHz, configuration N = 336, M = 8, P = 2 (typical STM32F4)
Fout = 8MHz × (336 / 8) / 2 = 168MHz

STM32CubeMX pre-calculates these coefficients through the graphical interface, no need to calculate them yourself — but understanding the formula helps read why changing the external quartz (Fin) and forgetting to reconfigure N/M/P will cause the entire system to run at the wrong speed.

Parameters

Popular STM32 series by performance segment:

LineCoreMaximum clock speedTypical RAM
STM32F0Cortex-M0~48MHzFew KB – 32KB
STM32F1 (VD: "Blue Pill")Cortex-M3~72MHz20KB
STM32F4Cortex-M4 (with FPU)~168-180MHzUp to 384KB
STM32H7Cortex-M7 (with FPU)~400-480MHzUp to several MB

Register / Bit / Byte

Before a peripheral (GPIO, UART, Timer...) can operate, the clock assigned to it must be manually turned on via register RCC (Reset and Clock Control) — this is the most common runtime error for newbies: configuration code GPIOx_MODER is completely correct (see GPIO article) but that port is "silent" just because we forgot to turn on the clock for that port in RCC first. (Example: RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN; to enable GPIOA clock on STM32F4).

Protocol

CAN bus (Controller Area Network), CAN 2.0B standard, maximum transmission speed ~1Mbps — many STM32 series have a built-in CAN controller right on the chip, which is an industrial/automotive standard protocol for communication between multiple control boards on the same system, better anti-interference than conventional UART thanks to the error detection mechanism built into the protocol.

Practical applications

The STM32 is often responsible for the motor speed PID control loop in dedicated motor drivers of AMR robots — where a stable micro-second response latency is needed that is difficult to meet with an Arduino (8-bit, slower) or running on an MPU (not strictly real-time). For industrial robot systems with multiple control boards (for example, each wheel has its own motor control board), the built-in CAN bus on the STM32 allows these boards to exchange commands/status with each other more reliably than conventional UART, especially in strong electromagnetic interference environments near high-power motors.

Practical example: compare HAL code with Arduino

// Arduino — highly abstract, no need to specify specific ports
digitalWrite(13, HIGH);

// STM32 HAL — specify port (GPIOA) and pin (GPIO_PIN_5)
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET);

This small difference reflects the design philosophy: Arduino completely hides the "port" concept, STM32 HAL still keeps the port/pin concept clear — necessary because STM32 has many ports (GPIOA, GPIOB, GPIOC...) with behavior/speed that can vary depending on the chip line.

Common mistakes

  • The learning curve is much steeper than with Arduino — newcomers switching from Arduino to STM32 are often overwhelmed by the long reference manual and concepts of clock trees, DMA, interrupt vectors — it is recommended to start with HAL and STM32CubeMX instead of direct registers from the beginning.
  • Choosing the wrong chip line that doesn't have enough necessary peripherals — For example, choosing a cheap M0 series chip for a project that needs many ADC or CAN bus channels that that line does not support — you should clearly determine the peripheral requirements before choosing a specific chip.
  • Incorrect clock tree configuration — STM32 has a complex clock system with many different sources and frequency dividers for each peripheral — incorrect configuration causes the timer/UART to run at the wrong speed even though the logic code is completely correct, an error that is difficult to debug without understanding the clock tree.
  • Forget that not all pins are equally "versatile" — although the GPIO on the STM32 is very flexible (discussed in the GPIO article), not all pins support all alternate functions — you need to look up the correct datasheet/CubeMX to know which pins support the function you need.

Conclusion

The STM32 is the right choice when a project needs high reliability, deep hardware control, or is geared toward high-volume production — at the cost of a larger initial learning curve than the Arduino/ESP32. The next article in this category is about the Raspberry Pi Pico — a different approach, trying to keep the Arduino-style ease of use but on a more powerful chip platform.

Get new articles and lessons by email

When a new technical article or course module is published, Atlas Robotics sends you a short email. No spam.

Unsubscribe any time with the link in each email. See our Privacy policy.

What is STM32? Professional ARM microcontrollers widely used in industry — Atlas Robotics