当前位置:网站首页>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
边栏推荐
- 微软 AD 超基础入门
- 力扣6_1342. 将数字变成 0 的操作次数
- PHP calculates personal income tax
- Get familiar with XML parsing quickly
- Nanny level tutorial: Azkaban executes jar package (with test samples and results)
- From starfish OS' continued deflationary consumption of SFO, the value of SFO in the long run
- Neural network and deep learning-5-perceptron-pytorch
- JVM memory and garbage collection-3-direct memory
- 数据链路层及网络层协议要点
- Version 2.0 of tapdata, the open source live data platform, has been released
猜你喜欢
[SolidWorks] modify the drawing format
Neural network and deep learning-5-perceptron-pytorch
Kwai applet guaranteed payment PHP source code packaging
Nanny level tutorial: Azkaban executes jar package (with test samples and results)
MySQL查询为什么没走索引?这篇文章带你全面解析
Reading notes of Clickhouse principle analysis and Application Practice (7)
burpsuite
JVM memory and garbage collection-3-object instantiation and memory layout
Nacos microservice gateway component +swagger2 interface generation
Optimization of ecological | Lake Warehouse Integration: gbase 8A MPP + xeos
随机推荐
Analysis ideas after discovering that the on duty equipment is attacked
Direct addition is more appropriate
电路如图,R1=2kΩ,R2=2kΩ,R3=4kΩ,Rf=4kΩ。求输出与输入关系表达式。
快手小程序担保支付php源码封装
2022国内十大工业级三维视觉引导企业一览
adb工具介绍
力扣6_1342. 将数字变成 0 的操作次数
静态路由配置全面详解,静态路由快速入门指南
ArrayList源码深度剖析,从最基本的扩容原理,到魔幻的迭代器和fast-fail机制,你想要的这都有!!!
[reinforcement learning medical] deep reinforcement learning for clinical decision support: a brief overview
CV2 read video - and save image or video
Sum of submatrix
关于TXE和TC标志位的小知识
cv2-drawline
Apache多个组件漏洞公开(CVE-2022-32533/CVE-2022-33980/CVE-2021-37839)
Redisson distributed lock unlocking exception
body有8px的神秘边距
Sword finger offer II 041 Average value of sliding window
metasploit
【错误】加载h5权重出错AttributeError: ‘str‘ object has no attribute ‘decode‘