What is interruption? Let's introduce it from an example in life. You are reading a book at home, and suddenly the phone rings. You put down the book, answer the phone, talk to the caller, then put down the phone and come back to continue reading your book. This is the phenomenon of "interruption" in life, that is, the normal working process is interrupted by external events.
A careful study of interruptions in life will also be helpful for us to learn about microcontroller interrupts.
First, what can cause an interrupt? Many events in life can cause interrupts: someone presses the doorbell, the phone rings, your alarm goes off, the water you boiled... and so on. We call the events that can cause interrupts interrupt sources. There are also some events in the microcontroller that can cause interrupts. There are a total of 5 in 8031: two external interrupts, two counter/timer interrupts, and one serial port interrupt.
Second, the nesting and priority processing of interrupts: Imagine that we are reading a book, the phone rings, and someone presses the doorbell at the same time. What should you do first? If you are waiting for an important call, you generally won't pay attention to the doorbell. On the contrary, if you are waiting for an important guest, you may not pay attention to the phone. If it is neither of these two (i.e. not waiting for a call, nor waiting for someone to come to the door), you may handle it according to your usual habits. In short, there is a priority problem here, and the same is true in the microcontroller, there is also a priority problem. The priority problem not only occurs when two interrupts are generated at the same time, but also occurs when one interrupt has been generated and another interrupt is generated, such as when you are answering the phone and someone presses the doorbell, or when you are opening the door to talk to someone and the phone rings. Consider what we would do.
Third, the interrupt response process: When an event occurs, before entering the interrupt, we must first remember which page of the book we are reading, or take a bookmark and put it at the current page, and then deal with different things (because after dealing with them, we have to come back to continue reading): when the phone rings, we have to go to where the phone is, and when the doorbell rings, we have to go to the door. These are different interrupts, and we have to deal with them in different places, and this place is usually fixed. This method is also used in computers. There are five interrupt sources. After each interrupt is generated, go to a fixed place to find the program to handle the interrupt. Of course, before going, you must first save the address of the instruction to be executed next, so that after handling the interrupt, return to the original place and continue to execute the program. Specifically, the interrupt response can be divided into the following steps:
1. Protect the breakpoint, that is, save the address of the next instruction to be executed, that is, send this address to the stack.
2. Find the interrupt entry. According to the interrupts generated by 5 different interrupt sources, find 5 different entry addresses. The above work is done automatically by the computer and has nothing to do with the programmer. The interrupt handling program is stored at these 5 entry addresses (this is where the program is written. If the interrupt program is not placed there, it is wrong and the interrupt program cannot be executed).
3. Execute the interrupt handler.
4. Interrupt return: After executing the interrupt instruction, it returns to the main program from the interrupt point and continues execution.
Previous article:The structure of the MCS-51 interrupt system
Next article:What are interrupts and interrupt handlers
Recommended ReadingLatest update time:2024-11-16 18:06
- 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
- A legendary figure in the world of microwave and radio frequency
- Last day, make an appointment and get a gift: Design and test solution for vehicle-mounted radar
- Has anyone designed this power supply?
- Network Control of ROS Melodic
- Can someone please help me derive this formula?
- DE1-SOC development board sets the network port IP to static (fixed) IP
- ST releases the world's first LoRa SoC microcontroller STM32WL
- Today at 10:00 AM, live broadcast with prizes: TI's new generation of integrated PA Zigbee 3.0 and multi-protocol solutions
- PIR sensor module manufacturers
- Inverter and Motor Control