MCU interrupt problem

Publisher:平凡幸福Latest update time:2021-04-01 Source: eefocusKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Introduction: Isn't the interrupt of 51 MCU just jumping to another place when something happens in the middle, and returning after execution? Why do we need to use interrupts specifically? Can't we just jump to the instruction directly?


First of all, to understand the interrupt, we must first talk about the pins of the microcontroller P3 port; P30 to P35 are the input pins of the interrupt. Including serial ports, timers (counters), external interrupts, etc. The characteristics of these interrupts are that when the interrupt conditions are met, the corresponding interrupt program will be executed. Note that there is an important difference between the execution of the interrupt program and the subroutine of the assembly language: (most textbooks do not mention this point) The subroutine must have a call statement such as ACALL to call it before it can be executed; but the interrupt is not! It is automatically executed after the interrupt condition is met. For example: the timer counts full; the external interrupt pin is triggered at a low level; the serial port receives data..., at this time the program automatically jumps to the interrupt entry: 03H, 0BH, .... 23H. After entering the interrupt entry, it is generally necessary to jump and then jump to the corresponding interrupt subroutine (unless your interrupt program is very short and will not enter other interrupts). Take C language as an example, in C51, the interrupt function does not need to be called by the main function main(), and is automatically executed (provided that the condition that triggers the interrupt occurs).


Isn't interruption just jumping to another place when something happens in the middle and returning after execution?


The "what happens in the middle" here refers to the interrupt that is triggered. According to the type of interrupt that is triggered, the program automatically jumps to the entry program (for example, if external interrupt 0 is triggered, it jumps to 03H, and if serial port interrupt is triggered, it jumps to 23H. These entry addresses are generally arranged with jump instructions)


Why do we need to use interrupts specifically? Can't we just jump to the instruction directly?


The microcontroller works in this way of interruption! For example, when the microcontroller is processing data, an external device sends a signal to start. This is an external interrupt signal. After receiving it, the microcontroller enters the corresponding interrupt program to start the device, or monitor the device, etc. Without interruption, the function of the microcontroller is greatly reduced. Does it mean that one is a known conditional jump and the other is unknown, so the interruption is used. This is the meaning, but it is not accurate. The interrupt is caused by an external signal, or the clock timing is reached, or the serial data is received. In short, the generation of the interrupt is not determined by the code in the program.


Keywords:MCU Reference address:MCU interrupt problem

Previous article:X25045 reading and writing program written by c51
Next article:About C51 memory types and physical areas of 51 microcontrollers

Recommended ReadingLatest update time:2024-11-16 16:20

MCU Learning Journey (IV) Buzzer Singing
After learning about the microcontroller buzzer today, I found that the frequency of the buzzer can be controlled to achieve the function of singing, so I found relevant tutorials on the Internet and share them with you below. The code has been tested and can be copied and used directly. The code contains statemen
[Microcontroller]
The unknown mystery of 51 MCU's IO port
1. When the quasi-bidirectional port outputs data: Quasi-bidirectional port output types can be used as output and input functions without reconfiguring the port line output state. This is because when the port line output is 1, the drive capability is very weak, allowing an external device to pull it low. When the pi
[Microcontroller]
The unknown mystery of 51 MCU's IO port
Atmel AVR Flash Microcontrollers for Motors
Atmel has expanded the support range of AVR microcontrollers to AC and brushless DC (BLDC) motor control applications, bringing highly flexible and cost-effective solutions to these applications. The excellent performance and comprehensive features of AVR Flash microcontrollers provide designers with the best solution
[Microcontroller]
Using 51 single chip microcomputer to realize key control of LED light on and off
#include reg51.h //header file sbit LED=P2^0; //bit definition LED light sbit k1=P3^1; //bit definition button void delay()//delay function {     unsigned char a,b; for(a=0;a 200;a++) for(b=0;b 200;b++); } void key()//key processing function { if(k1==0)//Judge whether the button is pressed (k=0 when the button i
[Microcontroller]
32-bit microcontroller CS32G020K8U7QH丨Xinhai Technology confirms application for 2024 Golden Edition Award
Application technology丨32-bit microcontroller CS32G020K8U7QH Application field: Automotive grade chips Unique advantages: 1.Integrated 2 PD modules, can support 2-way full-function PD 2.Integrated hardware CRC-32 calculation unit 3.
[Automotive Electronics]
32-bit microcontroller CS32G020K8U7QH丨Xinhai Technology confirms application for 2024 Golden Edition Award
Production of MCU USB-ISP download cable
Nowadays, laptops and desktops are gradually abandoning parallel and serial ports; many netizens also told me that desktops no longer have parallel ports and download cables cannot be used, and asked me to help them think of a solution. It seems that making a USB-ISP download cable is inevitable. After search
[Microcontroller]
Production of MCU USB-ISP download cable
AVR MCU Port Operation
Note: This section focuses on the operation of true bidirectional ports and the differences between true bidirectional port operation and pseudo bidirectional port operation. Marquee example. It is recommended to read the marquee first and then go back to read the previous introduction. AVR port is a true bidirectiona
[Microcontroller]
Application of Smart IC Card Gas Meter Based on SPMC65P2404A Single Chip Microcomputer
With the development of computer technology and information technology in the world, the global information age has arrived. All countries are formulating their own development paths in the field of high technology. The Chinese government is committed to the construction of national economic informatization. The i
[Microcontroller]
Application of Smart IC Card Gas Meter Based on SPMC65P2404A Single Chip Microcomputer
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号