当前位置:网站首页>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
边栏推荐
- 《ClickHouse原理解析与应用实践》读书笔记(7)
- 给刚入门或者准备转行网络工程师的朋友一些建议
- 日志特征选择汇总(基于天池比赛)
- Graphic network: uncover the principle behind TCP's four waves, combined with the example of boyfriend and girlfriend breaking up, which is easy to understand
- 2022国内十大工业级三维视觉引导企业一览
- Why did MySQL query not go to the index? This article will give you a comprehensive analysis
- 力扣6_1342. 将数字变成 0 的操作次数
- WPF custom realistic wind radar chart control
- Cross modal semantic association alignment retrieval - image text matching
- The method of using thread in PowerBuilder
猜你喜欢

Usage of hydraulic rotary joint

COMSOL --- construction of micro resistance beam model --- final temperature distribution and deformation --- addition of materials

Introduction à l'outil nmap et aux commandes communes

How to fix the slip ring

喜欢测特曼的阿洛

JVM memory and garbage collection -4-string

Get familiar with XML parsing quickly

MySQL查询为什么没走索引?这篇文章带你全面解析

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

PB9.0 insert OLE control error repair tool
随机推荐
Redisson distributed lock unlocking exception
魚和蝦走的路
JVM memory and garbage collection-3-runtime data area / heap area
进程和线程的退出
#797div3 A---C
阿锅鱼的大度
力扣5_876. 链表的中间结点
MySQL查询为什么没走索引?这篇文章带你全面解析
Remote sensing contribution experience sharing
body有8px的神秘边距
Get familiar with XML parsing quickly
C语言-模块化-Clion(静态库,动态库)使用
Ml self realization / linear regression / multivariable
[target tracking] |dimp: learning discriminative model prediction for tracking
leetcode 869. Reordered Power of 2 | 869. 重新排序得到 2 的幂(状态压缩)
神经网络与深度学习-5- 感知机-PyTorch
I don't know. The real interest rate of Huabai installment is so high
Give some suggestions to friends who are just getting started or preparing to change careers as network engineers
The numerical value of the number of figures thought of by the real-time update of the ranking list
SQLite3 data storage location created by Android