Measurement of 51 microcontroller edge triggered interrupt response time

Publisher:wmghyuLatest update time:2006-10-31 Source: 单片机及嵌入式系统应用Keywords:command Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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
By inputting this waveform through the external interrupt 0 of the microcontroller, the actual moment when the falling edge interrupt is triggered can be measured. The following is a detailed analysis of the waveform. Establish the rectangular coordinates as shown in Figure 2.

Figure 2 Established rectangular coordinate setting
The period of the waveform shown in Figure 2 is T. The microcontroller triggers an interrupt when the voltage drops to y=y′. t1′, t2′, and t3′ are the interrupt triggering moments of the preceding and following periods respectively, then:

The L1 equation is obtained as:
The L2 equation is obtained as:
From the circuit shown in Figure 2 and equations (1), (2), and (3), it can be obtained:
Input the above waveform from the external interrupt 0 of the microcontroller, select the edge trigger mode, and measure the value of T1 or T2 through the interrupt service program, so that the level value y' at the time when the interrupt occurs can be found, that is, the actual time when the edge triggers the interrupt.

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
The corresponding interrupt service routine is:

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.

Keywords:command Reference address:Measurement of 51 microcontroller edge triggered interrupt response time

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

Significant progress made: Huawei's intelligent driving computing platform obtains ASPICE Level 2 certification
TÜV Rheinland, a world-renowned testing, inspection and certification company, has issued an ASPICE Level 2 certification certificate to Huawei's MDC Intelligent Driving Computing Platform (hereinafter referred to as "Huawei MDC"). As the "brain" of intelligent driving cars, Huawei MDC not only includes platform ha
[Automotive Electronics]
Significant progress made: Huawei's intelligent driving computing platform obtains ASPICE Level 2 certification
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号