当前位置:网站首页>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
边栏推荐
- leetcode 873. Length of Longest Fibonacci Subsequence | 873. 最长的斐波那契子序列的长度
- body有8px的神秘边距
- See how names are added to namespace STD from cmath file
- How to make the conductive slip ring signal better
- Installing and using mpi4py
- The body has a mysterious margin of 8px
- 系统测试的类型有哪些,我给你介绍
- If time is a river
- 需要思考的地方
- 【目标跟踪】|atom
猜你喜欢

metasploit

Matlab r2021b installing libsvm

leetcode 869. Reordered Power of 2 | 869. 重新排序得到 2 的幂(状态压缩)

burpsuite

SQLite3 data storage location created by Android

How to make the conductive slip ring signal better

Nacos microservice gateway component +swagger2 interface generation

Exit of processes and threads

Neural network and deep learning-5-perceptron-pytorch

Beaucoup d'enfants ne savent pas grand - chose sur le principe sous - jacent du cadre orm, non, ice River vous emmène 10 minutes à la main "un cadre orm minimaliste" (collectionnez - le maintenant)
随机推荐
[SolidWorks] modify the drawing format
力扣4_412. Fizz Buzz
微软 AD 超基础入门
分布式定时任务之XXL-JOB
Get familiar with XML parsing quickly
保姆级教程:Azkaban执行jar包(带测试样例及结果)
How to fix the slip ring
很多小伙伴不太了解ORM框架的底层原理,这不,冰河带你10分钟手撸一个极简版ORM框架(赶快收藏吧)
Ml backward propagation
Remote sensing contribution experience sharing
A comprehensive and detailed explanation of static routing configuration, a quick start guide to static routing
系统测试的类型有哪些,我给你介绍
Ml self realization / logistic regression / binary classification
The body has a mysterious margin of 8px
Matlab r2021b installing libsvm
Wechat applet uniapp page cannot jump: "navigateto:fail can not navigateto a tabbar page“
If time is a river
鱼和虾走的路
Is it necessary for project managers to take NPDP? I'll tell you the answer
阿南的判断