External interrupt 0/1

Publisher:平静宁静Latest update time:2024-08-15 Source: cnblogs Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

External interrupt 0 or 1 is essentially the same, only EX and IT are changed to 0 or 1.

Q: So the question is: Why do we have two very similar external interrupts 0 or 1?

A: When there are two external interrupts, if there is only one external interrupt,

Then when one interrupt handles two external interrupts, its CPU processing is not accurate enough.

Therefore, we need to open another channel to handle external interrupts.

Q: What if there are three external interrupts?

A: This is the limitation of the microcontroller. Haha~~ But the flight control has many interrupts


#include

/*

* External interrupt 0

*/

sbit LED = P2^0; //bit declaration

//Register initialization function

void kinson()

{

EX0 = 1; // External interrupt 0 switch

EA = 1; //Interrupt the main switch

IT0 = 1; //External interrupt 0 trigger mode: 0 is level, 1 is falling edge //The timer is to be started

}

//Main function

void main(void)

{

kinson(); //Calling the register initialization function

while(1); //Let the program loop infinitely here

}


//Interrupt

void xjx() interrupt 0 //The interrupt number of external interrupt 0 is 0, and the interrupt number of external interrupt 1 is 2

{

LED = ~LED; //The LED turns on and off because of each interrupt

}


#include

/*

* External interrupt 1

*/

sbit LED = P2^0; //bit declaration

//Register initialization function

void kinson()

{

EX1 = 1; // External interrupt 0 switch

EA = 1; //Interrupt the main switch

IT1 = 1; //External interrupt 0 trigger mode: 0 is level, 1 is falling edge //The timer is to be started

}

//Main function

void main(void)

{

kinson(); //Calling the register initialization function

while(1); //Let the program loop infinitely here

}


//Interrupt

void xjx() interrupt 2 //The interrupt number of external interrupt 0 is 0, and the interrupt number of external interrupt 1 is 2

{

LED = ~LED; //The LED turns on and off because of each interrupt

}


Reference address:External interrupt 0/1

Previous article:LCD with character display I LOVE YOU
Next article:Digital tube buttons plus or minus one

Recommended ReadingLatest update time:2024-11-25 04:41

Program Upgrade Method of MSP430 MCU Serial Port
With the continuous improvement of performance and the reduction of costs, single-chip microcomputers have been widely used in various fields. Especially in the control and processing of signals, single-chip microcomputers have become the first choice of designers with their ultra-low power consumption and simple opera
[Microcontroller]
Program Upgrade Method of MSP430 MCU Serial Port
51 MCU ~ DS18B20 temperature sensor
1. Introduction: (ii) Wiring: 1. Internal structure: The first five digits of positive temperature are 0. The first five digits of negative temperature are 1. A four-digit hexadecimal number consisting of LS and MS, and a 16-digit binary number. (MS first, then LS) Combine the above and below graphs to get
[Microcontroller]
51 MCU ~ DS18B20 temperature sensor
Several Problems in PIC Microcontroller Development
1 How to further reduce power consumption Power consumption is an important consideration in battery-powered instruments. The PIC16C×× series microcontrollers have low power consumption (the operating current is less than 2mA at 5V, 4MHz oscillation frequency). To further reduce power consumption, the operating freque
[Microcontroller]
Advice for MCU beginners
    Basically, you need some knowledge of digital circuits, and some knowledge of analog circuits.     The key is to understand the knowledge of interfaces and interrupts. The basic knowledge in undergraduate courses such as "Computer Hardware Basics" is also very important.     You can buy a cheaper circuit board o
[Microcontroller]
It is also possible to use C language to design the game of greedy snake in single chip microcomputer
In the MCU, I used to see that the seniors used assembly or FPGA language to write Snake. Then I was thinking, C language is the simplest language. Why not write it in C language? First of all, we must know. When designing MCU games. We must know the concept of game design. For most MCU + LCD game designs, the basic fr
[Microcontroller]
It is also possible to use C language to design the game of greedy snake in single chip microcomputer
Application of single chip microcomputer in USB design
With the rapid development of USB technology and the widespread application of USB peripherals in more and more occasions, more and more chips support USB interface technology. For the design of USB interface, if it is not for expansion, the selection of USB controller with MCU is of course the first choice of d
[Microcontroller]
Application of single chip microcomputer in USB design
How to improve programming efficiency and optimize programs using microcontrollers
When designing the 8051 microcontroller application system, programming often requires directly operating the various memory address spaces. The object code generated after the C51 program is compiled has a floating address, and its absolute address can only be determined after BL51 connection positioning. In orde
[Microcontroller]
Overview of the Status of Single Chip Microcomputer in Modern Electronic Systems
Abstract : Modern electronic technology is developing at an increasingly rapid pace, and its basic core technology is embedded computer systems. As one of the embedded systems, single-chip microcomputers, with their obvious typicality, extensiveness, and popularity, occupy an important position in the development of m
[Analog Electronics]
Latest Microcontroller Articles
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号