this works
while(TI==0);
TI=0;
……
……
This does not work. I cannot detect TI=1 using the following method. Why?
for(i=0;(i<10)&&(TI==0);i++);
TI=0;
if(i<10)
// Correct processing
else
// Error processing
There is no need to use the second method
It takes a certain amount of time for the serial port to send data. Assuming the baud rate is 9600bps, it takes more than 100 us per bit. If the data bit is 8 bits and the check bit is one, it takes more than one ms to send one byte of data. The error of the second method is that it is believed that sending does not take time or the time is very short. The author's original intention may be to make 10 judgments on TI. If TI is found to be 0 in all 10 judgments, that is, the sending is not completed, then it is considered that an error has occurred; otherwise, if TI is found to be 1 within 10 judgments, that is, the sending is completed, then it is considered that the sending is correct. The actual situation is that the time to execute 10 loops is much less than the time required for sending. Therefore, the loop has exited before the sending is completed, and a judgment of sending error is made. The correct handling is to add a delay program before the loop, and the delay time should be greater than the minimum time required for sending. I personally think that there is no need to use the second method. For the 51 single-chip microcomputer serial port, there are only the cases of sending completion and non-completion, and there is no concept of right and wrong. If the sending error is said, that is, after executing the sending instruction, the internal hardware circuit of 51 cannot correctly send the data or cannot set TI to 1, it means that the CPU is broken or the crystal oscillator has a problem. The so-called right and wrong should refer to whether the data received by the receiver is correct or wrong.
Previous article:A cheap single-chip AC power line interface solution
Next article:Powerful clock interrupt
Recommended ReadingLatest update time:2024-11-16 15:26
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- MM32F103 BUG reminder to avoid pitfalls
- Will MakeCode support Python?
- What are the specific differences between triodes and MOS tubes?
- How to set the GND pin of a separate component as a flower pad in PADS?
- EEWORLD University Hall----Keithley 4200A-SCS parameter analyzer accelerates semiconductor equipment, materials and process development
- EEWORLD University Hall ---- Advanced C Language Programming for Embedded Systems (Ling Ming, Southeast University)
- Two-phase brushless DC motor speed control system based on DSP and CPLD
- The main structure of the DM642 image processing program
- Multi-way switch, battery inspection instrument
- EEWORLD University ---- Wildfire FPGA Video Tutorial