Printf debugging
AN4989
70/118
AN4989 Rev 3
Figure 49. USART2 setting with STM32CubeMX
Retargeting printf to UART depends on the toolchain.
For IAR™ EWARM and Keil
®
MDK-Arm µVISION this is done by overriding the stdio fputc
function
#include "stdio.h"
int fputc(int ch, FILE *f)
{
HAL_UART_Transmit(&UartHandle, (uint8_t *)&ch, 1, 0xFFFF);
return ch;
}
For GCC based toolset like STM32CubeIDE, two cases can be met.
With syscall.c integrated to the project:
#include "stdio.h"
int __io_putchar(int ch)
{