当前位置:网站首页>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 :
边栏推荐
- The latest analysis of crane driver (limited to bridge crane) in 2022 and the test questions and analysis of crane driver (limited to bridge crane)
- Pooling idea: string constant pool, thread pool, database connection pool
- JS Demo calcule combien de jours il reste de l'année
- 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
- Tkinter Huarong Road 4x4 tutorial III
- Leetcode problem solving - 235 Nearest common ancestor of binary search tree
- Mysql database - Advanced SQL statement (I)
- Niuke winter vacation training camp 4 g (enumeration optimization, Euler power reduction)
- 2022 high altitude installation, maintenance and removal of examination question bank and high altitude installation, maintenance and removal of examination papers
- Global and Chinese market of gallic acid 2022-2028: Research Report on technology, participants, trends, market size and share
猜你喜欢

2022 G3 boiler water treatment registration examination and G3 boiler water treatment examination papers

常用sql集合

Compréhension de la technologie gslb (Global Server load balance)
![[actual combat record] record the whole process of the server being attacked (redis vulnerability)](/img/9c/34b916aca2f9270ec4cf4651f0de7e.jpg)
[actual combat record] record the whole process of the server being attacked (redis vulnerability)

Blue Bridge Cup Guoxin Changtian single chip microcomputer -- led lamp module (V)

1068. Consolidation of ring stones (ring, interval DP)

Farmersworld farmers world, no faith, how to talk about success?

6.0 kernel driver character driver
![Intimacy communication -- [repair relationship] - use communication to heal injuries](/img/c2/f10405e3caf570dc6bd124d65b2e93.jpg)
Intimacy communication -- [repair relationship] - use communication to heal injuries

Pooling idea: string constant pool, thread pool, database connection pool
随机推荐
[flax high frequency question] leetcode 426 Convert binary search tree to sorted double linked list
Niuke winter vacation training camp 4 g (enumeration optimization, Euler power reduction)
Preliminary analysis of smart microwave radar module
Supply and demand situation and market scale calculation report of China's portable energy storage power PES industry Ⓛ 2022 ~ 2028
Plug - in Oil Monkey
Is the account opening of Guotai Junan Securities safe and reliable? How to open Guotai Junan Securities Account
Leetcode problem solving - 235 Nearest common ancestor of binary search tree
How PHP drives mongodb
Mysql database - Advanced SQL statement (I)
Imitation Netease cloud music applet
1068. Consolidation of ring stones (ring, interval DP)
Global and Chinese market of wireless hard disk 2022-2028: Research Report on technology, participants, trends, market size and share
QGIS grid processing DEM data reclassification
WFC900M-Network_ Card/Qualcomm-Atheros-AR9582-2T-2R-MIMO-802.11-N-900M-high-power-Mini-PCIe-Wi-Fi-Mod
Farmersworld farmers world, no faith, how to talk about success?
The latest analysis of crane driver (limited to bridge crane) in 2022 and the test questions and analysis of crane driver (limited to bridge crane)
What indicators should be paid attention to in current limit monitoring?
Why use pycharm to run the use case successfully but cannot exit?
Collections SQL communes
treevalue——Master Nested Data Like Tensor