The MCS51 microcontroller series is an 8-bit microcontroller. It is a product launched by Intel in 1980 following the successful design of the MCS48 series. Because the MCS51 series has strong on-chip functions and command systems, it has made a leap forward in the application of microcontrollers. This series of products has quickly become the second generation of standard controllers in the world. The 51 series microcontroller has 5 interrupt sources, 2 of which are external input interrupt sources INT0 and INT1. The interrupt triggering mode of external input interrupt 1 and interrupt 0 can be controlled by IT1 (TCON.2) and IT0 (TCON.1) of the interrupt control register TCON respectively. If it is 0, the external input interrupt control is level triggered; if it is 1, the control is edge triggered. Here is the falling edge triggered interrupt.
1 Introduction to the question
Almost all domestic microcontroller data have unclear or wrong definitions of the response time of the microcontroller's edge-triggered interrupt. For example, the description of the edge trigger interrupt response moment in the literature [1] is: "For the pulse trigger mode (ie, edge trigger mode), the level must be detected twice. If the previous one is high level and the latter one is low level, it means A valid interrupt request signal with a negative transition was detected", but this is not the case.
We know that the interrupt trigger level of the external input of the microcontroller is the TTL level. For TTL levels, the allowable range of TTL logic gate output high level is 2.4~5 V, and its nominal value is 3.6 V; the allowable range of output low level is 0~0.7 V, and its nominal value is 0.3 V[ 2], the intermediate level between 0.7 V and 2.4 V is neither high nor low.
In this way, in practical applications, assuming that the external interrupt pin INT0 of the microcontroller inputs a falling edge signal from +5 V to 0 V, the microcontroller samples the INT0 pin in a certain clock cycle and obtains a high level of 2.4 V; and in the next clock When the cycle comes for sampling, it often takes a certain amount of time for the actual external input interrupt trigger signal to change from high level to low level. Therefore, what is detected may not be a real low level (less than 0.7 V), but a low level. A certain intermediate level between low level and high level, that is, a certain level between 0.7~2.4 V. In this case, will the microcontroller still set the interrupt trigger flag to trigger an interrupt? Regarding this point, most domestic textbooks and device information provided by microcontroller manufacturers do not give accurate definitions, but in practical applications, this situation will indeed be encountered.
Take the operational amplifier chip AD708 produced by Analog Company in the United States as an example. Its slew rate is 0.3 V/μs. In the comparator circuit composed of the AD708 chip, the falling edge of its output square wave drops from 2.4 V to 0.7 V, the required time is approximately: (2.4 V-0.7 V)/0.3V·μs-1=4.67 μs. That is to say, it takes a transition time of about 4.67 μs before the falling edge actually drops from high level to low level. In practical application circuits, this falling time can often reach more than 10 μs. For a precision measurement system, such a long uncertainty time is unacceptable. Therefore, it is necessary to accurately measure the edge interrupt triggering moment of the microcontroller.
2 Design and analysis of test waveforms
In order to determine the actual moment of the falling edge trigger of the MCS51 microcontroller, an 80 MHz function/arbitrary waveform generator (function/arbitrary waveform generator) model 33250A produced by Agilent Company is used to generate a period of 20 ms as shown in Figure 1. waveform.
Figure 1 Periodic waveform with a period of 20 ms |
Figure 2 Established rectangular coordinate setting |
The L1 equation is obtained as:
When using a microcontroller to measure the interrupt moment, two counters are used, both set to mode 1 (16-bit counting mode). Among them, the first counter is used to record the time elapsed from the start of program execution to the arrival of the first falling edge, and the second counter is used to record the time elapsed from the start of program execution to the arrival of the second falling edge. The two The time interval between two falling edges can be obtained by subtracting the counter value. From the previous analysis, it can be seen that this time interval may have two situations: one is T1 time, that is, the time interval between t1′ and t2′; the other is T2 time, that is, the time between t2′ and t3′ interval. Among them, T1+T2=T, T1 time is smaller than T2 time. By measuring the T1 or T2 time, the actual level at the moment when the falling edge triggers the interrupt can be obtained using equation (4).
3 Test process and corresponding microcontroller program
The interrupt service program flow of the microcontroller is shown in Figure 3.
Figure 3 Interrupt service routine flow |
INCR1
MOVA,R1
CJNEA,#01H,SEC
CLRTR0
MOV20H,TL0
MOV21H,TH0
CLRIE0
RETI
SEC:CLRTR1
MOV22H,TL1
MOV23H,TH1
CLREX1
CLREX0
RETI
Since there is a certain delay in program execution, the output values of the two counters need to be corrected after the interrupt returns. This experiment uses the H51/L simulator produced by Weifu Company as the single-chip microcomputer measurement system. The measured T1 value is 6.514 ms. From equation (4), we can get: y′=0.729 V, that is, when y′ is about 0.73 V, The falling edge of the microcontroller triggers an interrupt.
4 Conclusion
By designing a simple waveform, this article accurately measures the edge-triggered interrupt response time of the microcontroller, thereby correcting the unclear definition of the edge-triggered interrupt time in domestic microcontroller learning materials, and the final results have been verified experimentally.
Previous article:Using AT89C series microcontroller to realize remote control of 5-inch TFT-LCD
Next article:Measurement of 51 microcontroller edge triggered interrupt response time
Recommended ReadingLatest update time:2024-11-17 00:17
- Popular Resources
- Popular amplifiers
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
- Photoelectric detection technology
- Animation identifies the meaning of each measurement item of the oscilloscope
- A wired mouse that can play sound via Bluetooth
- The analog input of AD7476 front end is fixed at around 1V
- About continue in for loop
- Radar Principles and Engineering Implementation Cases
- Dynamic understanding of I2C transmission
- zx_Vivado Concise Tutorial
- How to select the reactor parameters when using the reactor instead of the motor as the inverter load
- Study on burr problem in fpga design.pdf