STM32 Overview

Presented by Ing. Davide Giacalone, Advanced Research Engineer, SRA

STM32 is more than a CPU

The STM32 microcontroller family, exemplified by the STM32F7 Cortex-M7, offers extensive connectivity to various peripherals. These include:

STM32 Families Overview

STMicroelectronics offers a broad range of STM32 microcontrollers categorized by performance and power consumption:

High Performance

Mainstream

Ultra-low-power

Wireless

STM32F4 Series Comparison

Product line FCPU (MHz) Flash (KB) RAM (KB) ART Accelerator™ FSMC (NOR/ PSRAM/LCD) support QSPI DFSDM DAC DMA USB 2.0 OTG FS TFT LCD Controller MIPI DSI TRNG
STM32F469/479 180 Up to 2056 Up to 384 Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes
STM32F429/439 180 Up to 2056 Up to 256 Yes Yes Yes Yes Yes Yes Yes Yes No Yes
STM32F427/437 180 Up to 2056 Up to 256 Yes Yes Yes Yes Yes Yes Yes Yes No Yes
STM32F446 180 Up to 512 Up to 128 Yes No Yes No Yes Yes Yes No No Yes
STM32F407/417 168 Up to 1024 Up to 192 Yes Yes No No Yes Yes Yes Yes No No
STM32F401/411 84 Up to 512 Up to 128 Yes No No No No Yes No No No No

Note: Some devices are optimized for mixed-signal applications and include features like 16 and 32-bit timers, 12-bit ADC (0.41 µs), True Random Number Generator, and Batch Acquisition Mode. They support low voltage (1.7 to 3.6 V) and operate within a temperature range of -40 °C to 125 °C.

STM32 Tools

STMicroelectronics provides a comprehensive suite of tools to facilitate STM32 development:

Hardware Development Tools

STM32 Docs

STM32CubeMX

STM32CubeIDE

The STM32 ecosystem supports various STM32 series (L, F, G, H, W, MP) across different core architectures (Cortex-M0+, M3, M4, M7, M33). STM32CubeMX and STM32CubeIDE are available for Windows and macOS.

STM32 Boards

STMicroelectronics offers various development boards to support STM32 development, including:

These boards facilitate prototyping and development, offering features like integrated ST-Link debuggers, Arduino connectors, and expansion capabilities.

Board ST-Link ARDUINO connector Display
Custom No
STM32 Nucleo Yes (V2.1/V3) X
STM32 Discovery Yes (V2.1/V3) X X
STM32 Eval Yes (V2.1/V3) X X

STM32 Nucleo Structure

Each Nucleo board is based on one of the STM32 MCU product lines and offers two types of extension resources:

Nucleo boards feature an integrated ST-LINK/V2-1 debugger and programmer, supporting drag-and-drop flash programming and targeting on-board or external STM32-based applications.

The structure includes a Mini USB connector for power and debugging, the ST-LINK/V2-1, the STM32 microcontroller, Arduino connectors, and Morpho extension headers for expanded I/O access.

STM32 Nucleo Key Assets

Key features of the STM32 Nucleo boards include:

Enlarging the STM32 Nucleo Family

The STM32 Nucleo family is expanding to cover the entire STM32 portfolio, offering different pin counts and features:

Common features across the family include flexible board power supply (USB or external), integrated ST-LINK/V2-1 for drag-and-drop programming, one STM32 microcontroller, Arduino Uno connectors, Arduino Nano connectors, ST Zio connectors for easy add-on, ST morpho extension for direct access to all MCU I/Os, and optional Ethernet & USB OTG.

Examples of Nucleo Expansion Boards

Nucleo expansion boards offer specialized functionalities:

Examples include boards for proximity and light sensing, Wi-Fi connectivity, Sub-1GHz communication, NFC, LCD drivers, motor drivers, and audio microphones. For more information, visit: http://www.st.com/en/ecosystems/stm32-nucleo-expansion-boards.html

Outline of Development Process

The development process using STM32 tools typically involves the following steps:

The STM32 ecosystem supports a wide range of STM32 MCUs and MPUs, from ultra-low power to high performance, across various series (STM32L, STM32F, STM32G, STM32H, STM32W, STM32MP).

Create New Project – MCUs Selector

STM32CubeMX allows users to create new projects by selecting an MCU. The MCU selector provides filters for Part Number, Core, Series, Line, and Peripherals, enabling precise selection. A detailed list of MCUs with their specifications (Flash, RAM, frequency, etc.) is displayed.

For example, the STM32F401RE is an Arm Cortex-M4 MCU with DSP and FPU, operating up to 84 MHz, featuring 512 Kbytes of Flash memory and 96 Kbytes of SRAM.

Create New Project – Board Selector

Users can also create projects by selecting a specific development board. The Board Selector offers filters for Part Number, Vendor, Type, and MCU Series. The STM32 Nucleo boards, such as the NUCLEO-F401RE, are listed with their specifications and associated MCUs.

The STM32 Nucleo-64 boards provide an affordable and flexible platform for prototyping, integrating the ST-LINK debugger/programmer and supporting Arduino Uno V3 connectivity and ST morpho headers for expansion.

CubeMX View: Pinout & Configuration

The STM32CubeMX interface provides several key configuration views:

The Pinout view displays a graphical representation of the MCU's pins, allowing users to assign peripheral functions to specific pins. For instance, the STM32F401RETx LQFP64 package is shown with its pinout.

Pinout & Configuration View

Within the Pinout & Configuration view, users can select peripherals from categories (System Core, Analog, Timers, Connectivity, Multimedia, Computing, Middleware) and configure their modes. The MCU pinout section visually represents pin assignments.

Peripherals Configuration Section (Set Parameters)

In the Peripherals Configuration section, users select peripherals and configure their modes. STM32CubeMX automatically assigns and configures the necessary pins. For example, when configuring TIM1, users can set its mode, clock source, channel configurations (e.g., PWM Generation), counter settings (prescaler, mode, period), and trigger outputs.

MCU Pinout Section

For advanced users, the Chip view within STM32CubeMX allows direct mapping of peripheral functions to physical pins. This feature, coupled with the conflict solver, prevents unintended pin changes. Pin functionality assignment is crucial for defining how each pin behaves.

Peripherals Configuration Section (Set Interrupts)

The Peripherals Configuration section also allows users to set up interrupts. By navigating to the NVIC (Nested Vectored Interrupt Controller) settings, users can enable specific interrupts, configure their preemption priority and sub-priority, and manage interrupt activation. This is essential for handling events like timer overflows or external pin changes.

Hello World on UART (1/2)

To implement a "Hello World" application via UART, users first check the parameter settings for USART2 in STM32CubeMX. Key settings include Baud Rate (e.g., 115200), Word Length (8 Bits), Parity (None), and Stop Bits (1). The MCU pinout highlights the USART TX and RX pins (PA2 and PA3 for USART2).

Hello World on UART (2/2)

On STM32CubeIDE, the "Hello World" UART example requires defining the `_write` function to handle character transmission and then writing the `printf` function to output the message. The `_write` function typically uses HAL_UART_Transmit to send data over the specified UART peripheral.

/* USER CODE BEGIN PFP */
int _write(int fd, char* ptr, int len) {
    HAL_UART_Transmit(&huart2, (uint8_t *) ptr, len, HAL_MAX_DELAY);
    return len;
}
/* USER CODE END PFP */

/* USER CODE BEGIN 2 */
printf("hello\r\n");
/* USER CODE END 2 */

LED Blinking, Solution 1 (Not Precise)

A basic LED blinking example involves configuring a specific pin (e.g., PA5, connected to LD2) as a GPIO output in STM32CubeMX. The code then toggles the pin's status and adds a delay to control the blinking speed. This method provides a simple but not precisely timed blinking effect.

/* USER CODE BEGIN 2 */
while (1) {
    HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin);
    HAL_Delay(500);
}
/* USER CODE END 2 */

LED Blinking, with Timer and Interrupt (1/2)

For more precise LED blinking, timers and interrupts are utilized. This involves enabling Timer 10 in STM32CubeMX, setting its parameters (prescaler, counter period), and enabling the related interrupt. The NVIC settings are then configured to enable the Timer 10 global interrupt.

LED Blinking, with Timer and Interrupt (2/2)

This method involves declaring a global flag (`time_elapsed`), starting Timer 10 in interrupt mode using `HAL_TIM_Base_Start_IT()`, and redefining the `HAL_TIM_PeriodElapsedCallback` function to set the flag when the timer period elapses. The main loop then checks this flag to toggle the LED and reset the flag.

volatile uint8_t time_elapsed = 0;

void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
    if(htim == &htim10) {
        time_elapsed = 1;
    }
}

/* USER CODE BEGIN WHILE */
while (1) {
    if(time_elapsed) {
        time_elapsed = 0;
        HAL_GPIO_TogglePin(LD2_GPIO_Port, LD2_Pin);
    }
}
/* USER CODE END WHILE */

Led Blinking, with PWM

To achieve LED blinking with Pulse Width Modulation (PWM), specific pins are configured in STM32CubeMX. For example, PA5 can be set as TIM2_CH1. The clock source is enabled, and the counter period and pulse values are adjusted to generate the PWM signal. The code then starts the timer in PWM mode using `HAL_TIM_PWM_Start()`.

Button Interrupt (1/2)

To handle button presses using interrupts, the relevant pin (e.g., PC13, connected to the blue push button) is first checked and configured as GPIO_EXTI13 in STM32CubeMX. Subsequently, the EXTI line interrupts (e.g., EXTI line 15:10) are enabled within the NVIC settings.

Button Interrupt (2/2)

This involves declaring a global flag (`button_pressed`), redefining the `HAL_GPIO_EXTI_Callback` function to set this flag when the button is pressed, and managing the flag in the main loop. When the flag is set, the application can perform an action, such as printing a message.

volatile uint8_t button_pressed = 0;

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
    if(GPIO_Pin == GPIO_PIN_13) {
        button_pressed = 1;
    }
}

/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1) {
    if(button_pressed) {
        button_pressed = 0;
        printf("yes, you pressed a button!\r\n");
    }
}
/* USER CODE END WHILE */

PDF preview unavailable. Download the PDF instead.

STM32 Microsoft PowerPoint for Microsoft 365

Related Documents

Preview STM32 32-bit MCUs: STMicroelectronics Product Portfolio and Ecosystem
Explore the comprehensive STM32 32-bit microcontroller portfolio from STMicroelectronics, covering high-performance, mainstream, and ultra-low-power MCUs. Discover the STM32 ecosystem, hardware tools, software solutions, and community resources for embedded development.
Preview STM32CubeCLT: Command-line Toolset for STM32 MCUs | STMicroelectronics
STMicroelectronics STM32CubeCLT is an all-in-one command-line toolset for STM32 microcontrollers. It integrates GNU C/C++ toolchain, GDB debugger, and STM32CubeProgrammer, streamlining embedded development across Windows, Linux, and macOS.
Preview How to Build a LoRa® Application with STM32CubeWL
STMicroelectronics' application note AN5406 guides developers on building LoRa® applications using STM32CubeWL microcontrollers, covering architecture, middleware, and practical examples for LoRaWAN and SubGHz communication.
Preview STMicroelectronics STM32L Series: Ultra-Low-Power 32-bit MCUs
Explore the STMicroelectronics STM32L series of ultra-low-power 32-bit microcontrollers (MCUs), featuring the Arm Cortex-M0+, M3, M4, and M33 cores. Discover their features, applications, development tools, and ecosystem for energy-efficient embedded systems.
Preview STM32 Microcontroller Monthly Update - January 2018
STMicroelectronics' January 2018 monthly update for STM32 microcontrollers, featuring new IoT solutions with Amazon FreeRTOS, development board announcements, technical articles, and resource listings.
Preview AN5557: STM32H7 Dual-Core Architecture and Application Examples
This application note details the dual-core architecture of STM32H745/755 and STM32H747/757 microcontrollers, featuring Arm Cortex-M7 and Cortex-M4 cores. It covers system overview, memory resources, peripheral allocation, dual-core communication, boot modes, STM32CubeMX examples, debugging capabilities, and application partitioning strategies.
Preview STM32 Open Development Environment: Accelerating IoT Prototyping
Explore the STM32 Open Development Environment (STM32 ODE) from STMicroelectronics, a comprehensive platform for fast and affordable development and prototyping of embedded systems and IoT applications.
Preview STMicroelectronics STM32 ARM Development with Eclipse/GCC/ST-LINK IDE
A guide to using Eclipse, GCC, and ST-LINK IDEs for STMicroelectronics 32-bit ARM microcontrollers, covering software tools, development boards, and practical examples.