当前位置:网站首页>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 :
边栏推荐
- Remember the experience of automatically jumping to spinach station when the home page was tampered with
- [dynamic programming] Ji Suan Ke: Suan tou Jun breaks through the barrier (variant of the longest increasing subsequence)
- Cesium terrain clipping draw polygon clipping
- Farmersworld farmers world, no faith, how to talk about success?
- IPhone development swift foundation 08 encryption and security
- 十大券商开户注册安全靠谱吗?有没有风险的?
- On my first day at work, this API timeout optimization put me down!
- Blue Bridge Cup Guoxin Changtian single chip microcomputer -- software environment (II)
- Development trend and market demand analysis report of China's energy storage battery industry Ⓩ 2022 ~ 2028
- Decompile and modify the non source exe or DLL with dnspy
猜你喜欢

Some 5000+ likes, the development notes of a director of cosmic factory, leaked

What is the difference between res.send() and res.end() in the node express framework
![[dynamic planning] counting garlic customers: the log of garlic King (the longest increasing public subsequence)](/img/29/543dce2f24130d22c1824385fbfa8f.jpg)
[dynamic planning] counting garlic customers: the log of garlic King (the longest increasing public subsequence)

Exclusive interview with the person in charge of openkruise: to what extent has cloud native application automation developed now?

Cesium terrain clipping draw polygon clipping

Redis concludes that the second pipeline publishes / subscribes to bloom filter redis as a database and caches RDB AOF redis configuration files

Teach you how to install aidlux (1 installation)

Décompiler et modifier un exe ou une DLL non source en utilisant dnspy

On my first day at work, this API timeout optimization put me down!

Tidb's initial experience of ticdc6.0
随机推荐
Pengcheng cup Web_ WP
The White House held an open source security summit, attended by many technology giants
Investment planning analysis and prospect prediction report of China's satellite application industry during the 14th five year plan Ⓑ 2022 ~ 2028
Décompiler et modifier un exe ou une DLL non source en utilisant dnspy
Is the account opening of Guotai Junan Securities safe and reliable? How to open Guotai Junan Securities Account
Compréhension de la technologie gslb (Global Server load balance)
Farmersworld farmers world, no faith, how to talk about success?
Conditional statements of shell programming
DOM light switch case
treevalue——Master Nested Data Like Tensor
What indicators should be paid attention to in current limit monitoring?
How does sentinel, a traffic management artifact, make it easy for business parties to access?
IPhone development swift foundation 08 encryption and security
QGIS grid processing DEM data reclassification
Functions and differences between static and Const
Imitation Netease cloud music applet
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
Station B, dark horse programmer, employee management system, access conflict related (there is an unhandled exception at 0x00007ff633a4c54d (in employee management system.Exe): 0xc0000005: read locat
Luogu deep foundation part 1 Introduction to language Chapter 7 functions and structures
MySQL - idea connects to MySQL