当前位置:网站首页>Little knowledge about TXE and TC flag bits
Little knowledge about TXE and TC flag bits
2022-07-08 02:03:00 【51CTO】
TXE Sign a
( in the light of Send data register )
TXE by 1:TDR All the data in is moved to the shift register , And no new data into TDR.
TXE by 0:TDR There are data in it. , Not empty , be TXE by 0.
TXE And "FlagStatus USART_GetFlagStatus(USART_TypeDef* USARTx, uint16_t USART_FLAG)" Use it together to judge TDR Whether there is data in
TC Sign a
( in the light of Send data register )
TC by 1: from TDR All the data coming over are transferred to TX Pin , And TDR There is no new data in .
TC by 0: from TDR All the data in has not been moved , Or before TDR The data in has been removed , but TDR New data is coming in .
The reason lies in

resolvent :
- Sending "K" Read first USART_SR;
- Software clearance “0”, You need to use the following function
Multiple groups for transmission , You need to view the corresponding multiple TXE Flag bit and a TC Sign a (TC To ensure that the last character is sent from the shift register to TX)
rewrite USART_SendByte() Make it possible to write multiple characters repeatedly
Function to send string
Serial communication mode : Polling 、 Interruption method . Generally, receive and use interrupts .
ITStatus The value is 1, Indicates that the value can be read
ITStatus The value is 0, Indicates that the value cannot be read
Can pass while and if To judge
USART_GetITStatus() | USART_GetFlagStatus() | |
The same thing | All access serial ports SR Status register | |
Difference | It will not only judge whether the flag bit is set 1, It also determines whether the corresponding interrupt is enabled , So interrupt the function in the serial port , This function is usually used | Only the flag bit is judged , When the corresponding interrupt is not enabled , This function is usually used to determine whether the flag bit is set 1. |
Understand a library function , It needs to be combined with specific examples .
printf function
stay C Language is used to print information to the console .printf It is a sharp tool for debugging in the development of MCU !
Yes printf The underlying function redirects , Use fputc and fgetc
printf() Function uses semi host mode , Will cause the program to fail to run , Therefore, this mode should be prohibited
- Use Micro Library : When using the micro Library , Half host mode is turned off by default
- Using microlibraries
- introduce stdio.h The header file
- rewrite fputc and fgetc function

There may be "FIFLE" is underfined, add
- Do not use micro Libraries , But the following words need to be added
- The two methods are the same :
- 1 All use “stdio.h" The header file
- All need to be rewritten printf The underlying function ,fputs and fgets.
- The differences between the two methods :
- Check... Or not “Use MicroLIB”
Semi host mode : The half host mode is ARM A debugging mechanism of single chip microcomputer , It needs an emulator to connect the computer and ARM Single chip microcomputer , And call the corresponding instructions to realize the MCU to print information to the computer display .
The micro library is designed for small memory embedded devices , It can reduce the space occupied by code .
Minimize the use of micro libraries
- be relative to C For the standard library , Fewer functions are supported , Mainly reflected in the support of the operating system .
- Standard things are relatively more reliable .
Related contents of the two functions
difference | int fputc(int ch,FILE *fp) function | int fgetc(FILE *fp) function | ||
function | Write a character to a file | Read a character from the file | ||
Parameters | ch Characters to write ,fp Point to FILE Pointer to structure | fp Point to FILE Pointer to structure | ||
Return value | success , Returns the character ; When encountering end of file or reading error , return EOF(-1) | success , Returns the character ; When encountering end of file or reading error , return EOF(-1) | ||
How to learn SCM better
- First of all, find a proper byte tutorial
- Hands-on practice !!
Thanks for the video teaching of Haichuang Electronics
Haichuang Electronics : https://space.bilibili.com/93630735/?spm_id_from=333.999.0.0
51 Single chip microcomputer : https://www.bilibili.com/video/BV1vJ411X7iZ?spm_id_from=333.999.0.0&vd_source=cf352bf665894b2751d802dc81299dd8
STM32 Single chip microcomputer : https://www.bilibili.com/video/BV1N7411x7Yk?spm_id_from=333.999.0.0&vd_source=cf352bf665894b2751d802dc81299dd8
边栏推荐
- Introduction à l'outil nmap et aux commandes communes
- How to fix the slip ring
- leetcode 873. Length of Longest Fibonacci Subsequence | 873. 最长的斐波那契子序列的长度
- C语言-Cmake-CMakeLists.txt教程
- Keras深度学习实战——基于Inception v3实现性别分类
- VIM string substitution
- Voice of users | understanding of gbase 8A database learning
- 很多小夥伴不太了解ORM框架的底層原理,這不,冰河帶你10分鐘手擼一個極簡版ORM框架(趕快收藏吧)
- Codeforces Round #643 (Div. 2)——B. Young Explorers
- QT -- create QT program
猜你喜欢

COMSOL --- construction of micro resistance beam model --- final temperature distribution and deformation --- addition of materials
![[recommendation system paper reading] recommendation simulation user feedback based on Reinforcement Learning](/img/48/3366df75c397269574e9666fcd02ec.jpg)
[recommendation system paper reading] recommendation simulation user feedback based on Reinforcement Learning

Alo who likes TestMan

Optimization of ecological | Lake Warehouse Integration: gbase 8A MPP + xeos

Kwai applet guaranteed payment PHP source code packaging

List of top ten domestic industrial 3D visual guidance enterprises in 2022

保姆级教程:Azkaban执行jar包(带测试样例及结果)

leetcode 866. Prime Palindrome | 866. 回文素数

See how names are added to namespace STD from cmath file

C language - modularization -clion (static library, dynamic library) use
随机推荐
How mysql/mariadb generates core files
Apache multiple component vulnerability disclosure (cve-2022-32533/cve-2022-33980/cve-2021-37839)
Applet running under the framework of fluent 3.0
adb工具介绍
Reading notes of Clickhouse principle analysis and Application Practice (7)
Why did MySQL query not go to the index? This article will give you a comprehensive analysis
Nmap tool introduction and common commands
常见的磁盘格式以及它们之间的区别
Ml self realization / logistic regression / binary classification
Many friends don't know the underlying principle of ORM framework very well. No, glacier will take you 10 minutes to hand roll a minimalist ORM framework (collect it quickly)
Introduction to ADB tools
Redismission source code analysis
Codeforces Round #633 (Div. 2) B. Sorted Adjacent Differences
【目标跟踪】|DiMP: Learning Discriminative Model Prediction for Tracking
Remote Sensing投稿經驗分享
Le chemin du poisson et des crevettes
[error] error loading H5 weight attributeerror: 'STR' object has no attribute 'decode‘
SQLite3 data storage location created by Android
The way fish and shrimp go
Introduction to Microsoft ad super Foundation