51 MCU interrupt system

Publisher:HarmonySpiritLatest update time:2012-10-23 Source: 21ic Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

About the concept of single-chip microcomputer interrupt system: What is an interrupt? Let's introduce it from a routine 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 is also very helpful for us to learn the interruption of single-chip microcomputers.

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 go to handle different things (because after handling, we have to come back to continue reading): when the phone rings, we have to go to the place where the phone is placed, and when the doorbell rings, we have to go to the door. These are also different interrupts, and we have to handle them in different places, and this place is often 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 this 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 automatically completed by the computer and has nothing to do with the programmer. The interrupt handler 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 interruption point and continues to execute. How does the microcontroller find the location of the interrupt program and how does it return? We will talk about it later.

The structure of the MCS-51 microcontroller interrupt system:

The symbols, names and conditions for the occurrence of the five interrupt sources are as follows.

INT0: External interrupt 0, introduced by P3.2 port line, caused by low level or falling edge.

INT1: External interrupt 1, introduced by P3.3 port line, caused by low level or falling edge.

T0: Timer/Counter 0 interrupt, caused by T0 counting full and returning to zero.

T1: Timer/Counter 1 interrupt, caused by T1 counting full and returning to zero.

TI/RI: Serial I/O interrupt, caused by the serial port completing a frame of character transmission/reception.

The structural block diagram of the entire interrupt system is shown in Figure 1 below.

Click to browse the next page

Reference address:51 MCU interrupt system

Previous article:51 MCU interrupt system structure
Next article:MCU Counters and Timers

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号