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
}
Previous article:LCD with character display I LOVE YOU
Next article:Digital tube buttons plus or minus one
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
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
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- How to use AD to draw the power layer of a four-layer board
- Prize-winning live broadcast: Application of NXP LPC553x in dual motor control is now open for registration!
- Has anyone used XN297?
- [RVB2601 Creative Application Development] Chapter 6: Building a TCP Client
- TI Signal Chain and Power Q&A Series Live Broadcast - Sensor Special Live Broadcast with Prizes in Progress!
- Save battery power in HEV/EV with automatic host reverse wake-up function
- How to join the LXI Consortium?
- Can the official routine freertos_blink of lpc824 be used?
- NUCLEO_G431RB review——by viphotman
- [MPS Mall Big Discount Experience Season] Unboxing