Instruction cycle: The time consumed by the instruction cycle to execute a certain instruction, which is equal to an integer multiple of the machine cycle. Most of the instruction cycles of the traditional 80C51 microcontroller are single-cycle instructions, that is, the instruction cycle = machine cycle, and a small number of them are double-cycle instructions. Now (as of 2012) new microcontrollers can achieve no frequency division, and try to use a single instruction cycle, that is, instruction cycle = machine cycle = clock cycle.
Looking at this 8051 microcontroller external data, the changing frequency of ALE and $PSEN$ here is less than one machine cycle. If you use C language to simulate this signal, there is no way to achieve a one-to-one correspondence, so you can only try to match the timing above. Same, the cycle is extended.
The instruction cycle is uncertain because it is related to the machine cycle included in the instruction. One instruction cycle = 1 (or 2 or 3 or 4) machine cycle. Multiplication or division contains 4 machine cycles, and a single instruction only contains 1 machine cycle.
For most 51 microcontrollers, 1 machine cycle = 12 clock cycles (or oscillation cycles)
There are also some microcontrollers whose clock cycle and oscillation cycle are not equal. For example, 1 clock cycle = 2 oscillation cycles.
This definition refers to the time required to execute an instruction. Usually an instruction cycle consists of several machine cycles. Different instructions require different number of machine cycles.
For some simple single-byte instructions, in the instruction fetch cycle, after the instruction is fetched into the instruction register, it is immediately decoded and executed, and no other machine cycles are needed. For some more complex instructions, such as transfer instructions and multiplication instructions, two or more machine cycles are required. Generally, instructions that contain one machine cycle are called single-cycle instructions, and instructions that contain two machine cycles are called two-cycle instructions.
PIC microcontroller instruction cycle calculation
Every four clock cycles of the PIC microcontroller is an internal instruction cycle
For example: for an 8MHz crystal oscillator, the internal command cycle is 1/(8/4) = 0.5 uS
Example 1: 35us, 8MHz crystal oscillator, 8-bit timer, frequency division ratio 1/2, initial value E4
Example 2: 156.25us, 32768Hz crystal oscillator, 8-bit timer, frequency division ratio 1/32, initial value FC
Calculation method one: 35 = = (256-initial value)*frequency division*4/crystal oscillator+14/frequency division=(256-initial value)+14/2
Calculation method two: 0.015625 = (256-initial value)*frequency division*4/crystal oscillator = (256-initial value)*32*4/32768
Special note: the frequency division ratio 1-8 needs to be added with a 14/division ratio
What is prescaler ratio and postscaler ratio?
Frequency dividers are generally used in conjunction with counting units.
The prescaler ratio takes effect before the value of the counting unit changes (if prescaler is not used, the counter increases by 1 at each rising edge, and now a prescaler with a division ratio of 1:2 is used, Then you must wait until two rising edges arrive before the counter will add 1)
The postscaler has the same function as the prescaler, except that it takes effect after the counter value changes. Like the TMR2 postscaler, if it is not used, once the counter overflows, the flag will be set to TMR2IF immediately. However, if there is a 1:2 postscaler, it must overflow twice before it is set.
Nowadays, the commonly used microcontroller programming software is keil. After writing the program, we can determine the time required for program execution through software debugging, and we can also see each instruction:
Previous article:What is 51 microcontroller? How to learn 51 microcontroller by yourself
Next article:What is AT89S51 microcontroller?
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
- ST sensor evaluation platform STEVAL_MKI109V3 development board
- Analog Circuit Design Handbook: Advanced Application Guide
- How do you spend the May Day holiday?
- [Chuanglong Technology Allwinner A40i Development Board] Qt performance test
- Antai Instruments Repair Sharing - Tektronix Oscilloscope Repair DPO5054B
- You can't change actors in a serialized TV series, otherwise it will become a different movie.
- The transformer in the power supply has no output after loading
- Compile imx6-ek200 with buildroot
- Using MSP430 to implement PWM signal
- Get the MPM54304 evaluation board for the first quad-output module with digital power management