当前位置:网站首页>STM32 multi serial port implementation of printf -- Based on cubemx
STM32 multi serial port implementation of printf -- Based on cubemx
2022-07-03 22:10:00 【Four armed watermelon】
STM32 Multi serial port implementation printf—— be based on cubemx
Preface
This article mainly explains how to realize multiple serial ports by single chip microcomputer printf Print data .
The tools needed :
- Development board :STM32F103RCT6
- STM32CubeMX
- IDE: Keil-MDK
List of articles
cubemx End initialization
Enable the serial port , There are no other precautions .
keil End programming
stay usart.c Write the following code at the bottom
#include <stdarg.h>
#include <stdio.h>
uint8_t UartTxBuf[200];
void Usart2Printf(const char *format,...)
{
uint16_t len;
va_list args;
va_start(args,format);
len = vsnprintf((char*)UartTxBuf,sizeof(UartTxBuf)+1,(char*)format,args);
va_end(args);
HAL_UART_Transmit(&huart2, UartTxBuf, len,0xff);
}
stay usart.h Write his function declaration inside , Such other .c Source file call serial port 2 Of printf Just include usart.h that will do .
void Usart2Printf(const char *format,...);
The results verify that
stay main.c Inside printing
Usart2Printf("hello usart%d\n",2);
Physical connection
Serial assistant view
Postscript
This article is included in :
Tang Chengqian's video game station
This article is the tip of the iceberg in the series , Welcome to the station to check .
Supporting procedures :
边栏推荐
- English topic assignment (28)
- js demo 计算本年度还剩下多少天
- IPhone development swift foundation 09 assets
- pivot ROP Emporium
- 2022 G3 boiler water treatment registration examination and G3 boiler water treatment examination papers
- How to install sentinel console
- Solve the problem that openocd fails to burn STM32 and cannot connect through SWD
- Investment planning analysis and prospect prediction report of China's satellite application industry during the 14th five year plan Ⓑ 2022 ~ 2028
- An expression that regularly matches one of two strings
- Yyds dry inventory hcie security Day12: concept of supplementary package filtering and security policy
猜你喜欢
Electronic tube: Literature Research on basic characteristics of 6j1
The post-90s resigned and started a business, saying they would kill cloud database
Functions and differences between static and Const
IPhone development swift foundation 09 assets
Exness: the Central Bank of England will raise interest rates again in March, and inflation is coming
pivot ROP Emporium
treevalue——Master Nested Data Like Tensor
1068. Consolidation of ring stones (ring, interval DP)
MySQL - idea connects to MySQL
320. Energy Necklace (ring, interval DP)
随机推荐
JS Demo calcule combien de jours il reste de l'année
Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?
DR882-Qualcomm-Atheros-QCA9882-2T2R-MIMO-802.11ac-Mini-PCIe-Wi-Fi-Module-5G-high-power
Covariance
How does sentinel, a traffic management artifact, make it easy for business parties to access?
QGIS grid processing DEM data reclassification
[dynamic programming] Jisuan Ke: Jumping stake (variant of the longest increasing subsequence)
Preliminary analysis of smart microwave radar module
Go language slice interview real question 7 consecutive questions
Blue Bridge Cup Guoxin Changtian single chip microcomputer -- software environment (II)
Tidb's initial experience of ticdc6.0
How to obtain opensea data through opensea JS
[sg function] lightoj Partitioning Game
Yyds dry inventory hcie security Day12: concept of supplementary package filtering and security policy
2022 free examination questions for safety management personnel of hazardous chemical business units and reexamination examination for safety management personnel of hazardous chemical business units
js demo 计算本年度还剩下多少天
Electronic tube: Literature Research on basic characteristics of 6j1
pivot ROP Emporium
Control loop of program (while loop)
常用sql集合