We introduced the delay program earlier, but it is not perfect, because we only know that the sentence DJNZ R6, D2 will be executed 62500 times, but how long will it take to execute so many times? Does it meet our requirements? We don't know yet, so we will solve this problem below.
Let me first ask a question: What is the most important thing in our school? (Bell) The principal can go on business trips, and teachers can take a break, but if there is no bell in the school for a day, there will be chaos. The whole school works in unison and in a coordinated manner under the unified command of the bell. This bell rings according to a certain schedule, which we can call "time sequence - the order of time". A unit composed of people must have a certain time sequence, and computers must have a stricter time sequence. In fact, a computer is more like a big clock. There are strict rules for when the minute hand moves, when the second hand moves, and when the hour hand moves, and there can be no chaos at all. The things that computers have to accomplish are more complicated, so their time sequence is also more complicated.
We know that when a computer is working, it fetches instructions from the ROM one by one and then executes them step by step. We define the time it takes for a computer to access the memory as a machine cycle. This is a time reference, just like we humans use "seconds" as our time reference. Why not just use "seconds"? It's so good and very familiar. As we continue to learn, we will find that using "seconds" is not a habit.
A machine cycle consists of 12 clock cycles. Let's calculate how long a machine cycle is. Suppose a single-chip microcomputer works with a 12M crystal oscillator, and its clock cycle is 1/12 (microseconds). Its machine cycle is 12*(1/12), which is 1 microsecond. (Please calculate the machine cycle of a single-chip microcomputer working with a 6M crystal oscillator).
Among all the instructions of the MCS-51 microcontroller, some are completed relatively quickly and only require one machine cycle, some are completed relatively slowly and require two machine cycles, and two instructions require four machine cycles. This is not difficult to solve, is it? The execution time of the instruction I asked you to sweep the floor is always longer than the instruction of wiping the blackboard. In order to keep the length of the instruction execution time constant, a new concept is introduced: instruction cycle. The so-called instruction cycle refers to the time to execute an instruction. INTEL gives the instruction cycle number for each instruction. Most of these data do not need to be remembered by us, but some instructions need to be remembered, such as the DJNZ instruction, which is a two-cycle instruction.
Let's calculate the delay. First, we must know the frequency of the crystal oscillator. If we assume that the crystal oscillator is 12M, then one machine cycle is 1 microsecond. The DJNZ instruction is a two-cycle instruction, so it takes 2 microseconds to execute once. A total of 62,500 executions is exactly 125,000 microseconds, or 125 milliseconds.
Previous article:Improvement of single-chip multi-computer communication network and data communication fault-tolerant technology
Next article:Analysis of the Internal Structure of a Single Chip Microcomputer
Recommended ReadingLatest update time:2024-11-17 00:04
- 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
- EEWORLD University ---- Haiwell IoT Terminal MQTT Protocol Application Video Tutorial
- [TI recommended course] #TI LED driver# RGB LED circuit design reference
- PNIRP-06V-S Properties Introduction
- [Synopsys IP Resources] Why HDCP 2.3 is required for high-definition large-screen displays
- AM335x Evaluation Board Quick Test (1)
- [TI mmWave Radar Review] Introduction to Sensor Management Module
- The relationship between FPGA memories
- How to choose a wireless communication module with long distance and fast speed?
- Survival rules for electronic engineers in the workplace, every word is true!
- [Project source code] [Modelsim FAQ] No error but always shows Loading