
AT32 Printf Debug Demo
2019.08.05
10
Rev 1.0.2
2.2.4 Software
2.2.4.1 Header files
Add the
“
stdio.h
” to the code project files.
2.2.4.2 Redirection settings
Initialize the serial ports and redirect the Printf function to the actual serial ports. The redirection
function is as follows:
PUTCHAR_PROTOTYPE
{
USART_SendData(AT32_PRINT_UART, ch);
while ( USART_GetFlagStatus(AT32_PRINT_UART, USART_FLAG_TRAC) == RESET );
return ch;
}
2.2.5 Debug and download
Compile the code and download it to the MCU, and run it at full speed, then you can see that the
“Hello World” is displayed in the terminal interaction window (Figure 3)
Figure 3. Serial port debugging assistant window