EasyManua.ls Logo

STMicroelectronics STM32 - User Manual

STMicroelectronics STM32
118 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
Loading...
January 2021 AN4989 Rev 3 1/118
1
AN4989
Application note
STM32 microcontroller debug toolbox
Introduction
STM32 end-users are sometimes confronted with non- or partially-functional systems during
product development. The best approach to use for the debug process is not always
obvious, particularly for inexperienced users.
To address the above concerns, this application note provides a toolbox describing the most
common debug techniques and their application to popular recommended IDEs for STM32
32-bit Arm
®
Cortex
®
MCUs. It contains detailed information for getting started as well as
hints and tips to make the best use of STM32 Software Development Tools in STM32
ecosystem.
This application note applies to the microcontrollers listed in Table 1.
Table 1. Applicable products
Type Sub class
Microcontrollers
STM32 High Performance MCUs
STM32 Mainstream MCUs
STM32 Ultra Low Power MCUs
www.st.com

Table of Contents

Questions and Answers

  • P
    Paul WilliamsAug 3, 2025
    Why is it impossible to evaluate a variable or set a breakpoint in STMicroelectronics Microcontrollers?
    • A
      April RitterAug 3, 2025
      If you find it impossible to evaluate a value or variable, or to set a breakpoint at a specific line of code when working with STMicroelectronics Microcontrollers, the compiler optimization is probably enabled. Try removing it.
  • M
    Michael RobinsonAug 8, 2025
    What to do if an unexpected power consumption is measured for a low-power application in STMicroelectronics STM32 Microcontrollers?
    • H
      hillandreAug 9, 2025
      If you measure unexpected power consumption in a low-power application using STMicroelectronics Microcontrollers, ensure that low-power debug in the DBGMCU register is OFF. Note that this register resets only with a power-on reset (POR).
  • J
    James TorresAug 14, 2025
    What to do if I fail to connect to a board with Normal/System Reset in STMicroelectronics Microcontrollers?
    • J
      Jennifer BrownAug 14, 2025
      If you fail to connect to a board with Normal/System Reset when using STMicroelectronics Microcontrollers, try ConnectUnderReset / Hardware Reset connection mode. This resets the SWD connection in case it has been disabled by the application.
  • S
    Sean GonzalezAug 18, 2025
    What to do if connection with target is lost during debug of low-power system in STMicroelectronics Microcontrollers?
    • T
      Timothy ArnoldAug 19, 2025
      If the connection with the target is lost during debug of a low-power system using STMicroelectronics Microcontrollers, ensure that debug in low-power in the DBGMCU register is enabled and that the SWD pin is not set in an analog state.
  • S
    Susan AdamsAug 23, 2025
    What to do if I fail to connect on board using ConnectUnderReset/Hardware using ST-LINK in STMicroelectronics STM32?
    • R
      Robert PerezAug 23, 2025
      If you fail to connect on board using ConnectUnderReset/Hardware using ST-LINK with STMicroelectronics Microcontrollers, ensure that NRST of ST-LINK is properly connected to MCU NRST (e.g. check SB12 for Nucleo).
  • G
    gregory44Aug 28, 2025
    What to do if I fail to see clock signal on MCO output in STMicroelectronics STM32 Microcontrollers?
    • A
      Alexander WilsonAug 28, 2025
      If you fail to see a clock signal on the MCO output of STMicroelectronics Microcontrollers, ensure that the clock configured to MCO is in the supported range of the GPIO and that the OSPEED setting is correct.

Summary

Foreword

General Information

Document applicability to STM32 Arm Cortex MCUs and branding notes.

Software Versions

Lists specific tool versions used for examples in the note.

Acronyms

Glossary of technical terms and abbreviations used in the document.

STM32 Ecosystem Outlines

Hardware Development Tools

Overview of ST-LINK probes and debugger interfaces.

Software Development Tools

Introduction to IDEs, compilers, and ST tools for STM32.

Embedded Software

Describes HAL, LL APIs, middleware, and code examples.

Information and Sharing

Guides to STM32 resources like documentation, wiki, GitHub, and community.

Compiling for Debug

Optimization

Discusses code optimization impact on debugging and suggests settings.

Debugging Information

Explains the role of debugging information and its options in IDEs.

Connecting to the Board

SWD;JTAG Pinout

Details SWD pin mapping and usage on STMicroelectronics hardware.

Reset and Connection Mode

Reviews reset and connection modes for ST-LINK debuggers.

Low-Power Case

Addresses debug connection loss in low-power modes and DBGMCU register use.

Breaking and Stepping into Code

Debug Support for Timers, RTC, Watchdog, BxCAN and I2 C

Explains how timers and peripherals behave during breakpoints.

Debug Performance

Advises on optimizing SWD frequency for better debugger reactivity.

Secure Platform Limitation

Covers RDP and PCROP protection features and their debug implications.

Exception Handling

Default Weak Handlers

Explains default handler behavior and debugging strategies for exceptions.

Custom Handlers

Shows how to generate custom exception handler templates using STM32CubeMX.

Trapping div;0 Exception

Provides methods to trap division-by-zero errors on Cortex-M.

Printf Debugging

STM32 Virtual COM Port Driver

Describes using STM32 Virtual COM port via ST-LINK for printf.

Printf via UART

Explains how to redirect printf output through UART.

Printf via SWO;SWV

Details using Serial Wire Output (SWO) for printf debugging.

Semihosting

Explains the semihosting mechanism for I/O via debugger.

Debug Through Hardware Exploration

Easy Pinout Probing with STMicroelectronics Hardware Kits

Discusses pin access on ST hardware kits.

Microcontroller Clock Output (MCO)

Guides on configuring MCO for clock signal output and measurement.

Dual-Core Microcontroller Debugging

From Debug to Release

Troubleshooting

Appendix A: Managing DBGMCU Registers

By Software

Explains setting DBGMCU registers using HAL and LL functions.

By Debugger

Covers accessing DBGMCU registers through debugger interfaces or scripts.

Appendix B: Use Nucleo “Cuttable” ST-LINK as Stand-Alone VCP

Appendix C: Managing Various Targets on the Same PC

Appendix D: Cortex-M Debug Capabilities Reminder

Application Notes Index

Lists related application notes for further reading.

STMicroelectronics STM32 Specifications

General IconGeneral
SeriesSTM32
Clock FrequencyUp to 480 MHz
ArchitectureARM
CoreARM Cortex-M0, ARM Cortex-M0+, ARM Cortex-M3, ARM Cortex-M4, ARM Cortex-M7, ARM Cortex-M33
Program Memory TypeFlash
Operating Voltage1.62V ~ 3.6V
Operating Temperature-40°C ~ 125°C
PeripheralsGPIO, Timers, ADC, DAC, UART, SPI, I2C, USB, Ethernet, CAN, DMA, RTC, CRC, RNG, Cryptography, LCD, SDIO, Quad-SPI, FMC

Related product manuals