Case analysis:
The method of combining interrupt and query is to sort multiple external interrupt sources in the system according to their importance, connect the highest-level interrupt source to an external interrupt source input terminal of MCS-51 (for example, to a pin), and connect the remaining interrupt sources to another external interrupt input terminal ( ) by wire "OR" method, and connect to an I/O port at the same time, such as P1 port as shown in Figure 3. The interrupt request is generated by the hardware circuit, and the identification of the interrupt source is processed by program query. The query order is determined by the priority of the interrupt source. Figure 3 shows the connection circuit of five external interrupt sources, in which devices 1~4 are connected through OC gates and connected to P1.0~P1.3, all using level triggering. Device 0 is the highest-level interrupt source and is used as the input signal of external interrupt 0 alone. This method is relatively simple to expand, but when the number of external interrupt expansions is large, the query time is relatively long, resulting in low program execution efficiency.
Program code:
ORG 1000H
LJMP INTR
INTR: PUSH PSW ; protect context
PUSH A
JNB P1.0, IR1 ; P1.0 pin is 0, jump to device 1 interrupt service routine
JNB P1.1, IR2 ; P1.1 pin is 0, jump to device 2 interrupt service routine
JNB P1.2, IR3 ; P1.2 pin is 0, jump to device 3 interrupt service routine
JNB P1.3, IR4 ; P1.3 pin is 0, jump to device 4 interrupt service routine
INTR1: POP A ; restore context
POP PSW
RETI ; interrupt return
IR1: …… ; device 1 interrupt service routine entry
AJMP INTR1 ; jump to the instruction indicated by INTR1
IR2: …… ; device 2 interrupt service routine entry
AJMP INTR1 ; jump to INTR1
IR3: …… ; device 3 interrupt service routine entry
AJMP INTR1 ; Jump to INTR1
IR4: ... ; Device 4 interrupt service routine entry
AJMP INTR1 ; Jump to INTR1
Previous article:Summary of small problems in microcontroller programming
Next article:Extension of Parallel I/O Interface of Single Chip Microcomputer
Recommended ReadingLatest update time:2024-11-16 01:25
- 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.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- 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
- Infineon Position2Go Development Kit Review - skypinglee
- Schematic diagram of a quadrature oscillator
- Please tell me about the PB pin of GD32E230C
- Qorvo UWB Solution Receives Apple U1 Interoperability Certification
- Can't even see the taillights? LED makes car tail lighting safer
- EEWORLD University - How and why to replace discrete MOSFETs with load switches
- 【ESP32-C3-DevKitM-1】+ESP32 series universal Windows environment construction
- Digi-Key KOL video is here~ Senior algorithm engineer talks about the secrets of image processing
- 【RPi PICO】Run Fuzix system
- 【EVAL-M3-TS6-665PN】2. PFC working principle