This writing method is to nest assembly in C. The exact delay time = 2*t*T+5*T, T is one machine cycle. For 8051,
If t=1, then the execution of this function should be 7us. If it is STC12, then the delay of this delay function should be: if t=1, the precise delay = 2*1*1/12+5*1/12=(7/12)us.
I checked the STC12 manual yesterday. The manual describes the clock in a very general way. One sentence is: Compared with the execution time of 8051 instructions, there are 12 instructions in total, which can be executed in one clock, and the operation speed is increased by 8 to 12 times at the same frequency.
Should it be (7/8)us? Instead of (7/12)us?
This is a uint type function and the time is approximate
Then you can use delay time = 8*t*T
It should be 8*1*(1/12)=8/12
According to the program analysis, it is conjectured that the delay function should be 1us when t=1, which is the most reasonable.
Using an oscilloscope to test, it takes about 5.8ms to execute a delay (5000). 51 It takes about 40064us to execute a delay (5000). Well, using an oscilloscope to measure the frequency change of the IO port is 85.47HZ, so a delay (5000) is (1/85.47)/2*1000=5850us
Here, t is set to uint type, which has errors. In addition, the execution of LED=1;LED=0; will also consume time and result in errors.
Finally, it is concluded that this delay statement takes about 7us to execute once on 51 and 1us on 12. The oscilloscope test passed! It is consistent with my calculation.
Previous article:51 single chip microcomputer realizes infrared coding detection
Next article:The influence of crystal oscillator on baud rate in single chip microcomputer
Recommended ReadingLatest update time:2024-11-23 11:21
- Popular Resources
- Popular amplifiers
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- Principles and Applications of Single Chip Microcomputers 3rd Edition (Zhang Yigang)
- Principles and Applications of Single Chip Microcomputers and C51 Programming (3rd Edition) (Xie Weicheng, Yang Jiaguo)
- STC32G Series MCU Technical Reference Manual
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- Xunwei i.MX6ULL development board-Transplant OpenCv2.4.9-QT program compilation
- Please share: Tell me about the best or most beautifully designed circuit board you have ever seen
- Microwave Transmission Technology and Application of Television Signals
- Microcontroller selection
- Made a tool to use serial port IAP to realize batch online upgrade program
- Principle and maintenance of electronic mosquito killer lamp
- Great article! This explanation of ESD is so easy to understand!
- Things that electronic hardware engineers need to know
- MSP430 watchdog usage notes && how to use the watchdog monitoring program to run away in low power mode
- Geely Automobile successfully developed a tire blowout warning and braking system with better performance than TPMS and PAX