EasyManua.ls Logo

STMicroelectronics STM32 User Manual

STMicroelectronics STM32
118 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #71 background imageLoading...
Page #71 background image
AN4989 Rev 3 71/118
AN4989 Printf debugging
117
HAL_UART_Transmit(&UartHandle, (uint8_t *)&ch, 1, 0xFFFF);
return ch;
}
Without syscall.c integrated, a customized _write function has to be defined:
int _write(int file, char *ptr, int len)
{
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++){ __io_putchar( *ptr++ );}
return len;
}
Refer to STM32Cube provided example UART_Printf() available for almost all STM32
Series. An example is available in STM32Cube_FW_F3_V1.7.0\Projects\
STM32F303ZE-Nucleo\Examples\UART\UART_Printf.
Caution: USART word length includes parity which is not the case for most of UART terminal. Word
length 8 with parity require 7 bits + parity on terminal side to match.
VCP does not support Word length of 7 bits and below (whatever the parity). Table 5 gives
examples of compatible configurations:
7.3 Printf via SWO/SWV
Serial Wire Output (SWO) is single pin, asynchronous serial communication channel
available on Cortex-M3/M4/M7 and supported by the main debugger probes.
It is using the ITM (instrumentation trace macrocell) module of the Cortex Core-Sight.
The asynchronous mode (SWO) requires 1 extra pin and is available on all packages for
STM32 based on Cortex-M3, -M4, and -M7.
It is only available if a Serial Wire mode is used. It is not available in JTAG mode.
By default, this pin is NOT assigned. It can be assigned by setting the TRACE_IOEN and
TRACE_MODE bits in the Debug MCU configuration register (DBGMCU_CR). This
configuration has to be done by the debugger host.
Refer to the related chapter of STMicroelectronics reference manual.
In debug context it can be a good alternative to UART in system where pinout constraints
are strong (alternate function preempting UART GPIOs).
Table 5. STM32 USART vs. PC terminal WordLength example
STM32 UART PC Terminal
Word Length: 8, Parity: Odd Data: 7, Parity: Odd
Word Length: 8, Parity: None Data: 8, Parity: None
Word Length: 9, Parity: Odd Data 8, Parity: Odd
Word Length: 7, Parity: Odd/None Not Working with VCP

Table of Contents

Questions and Answers:

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

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 I2C

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.

Related product manuals