#include
#define GPIO_LED P2
//External interrupt IO
sbit K3=P3^2;
sbit K4=P3^3;
void IntConfiguration();
void Delay(unsigned int n);
unsigned char KeyValue=0;
void main(void)
{
GPIO_LED=0X01;
IntConfiguration();
while(1)
{
if(KeyValue)
GPIO_LED=_crol_(GPIO_LED,1);
else
GPIO_LED=_cror_(GPIO_LED,1);
Delay(2000);
}
}
void IntConfiguration()
{
//Set INT0
IT0=1; // Jump edge start mode (falling edge)
EX0=1; //Turn on the interrupt enable of INT0.
//Set INT1
IT1=1;
EX1=1;
EA=1; //Open the general interrupt
}
void Delay(unsigned int n)
{
for(;n>0;n--)
{
}
}
//The two external interrupt hardware are connected to P3^3 and P3^2
. //For example, if the P3^2 key is pressed, external interrupt 0 is triggered, and interrupt handler 0 will assign KeyValue to 1.
//At this time, the main loop will execute GPIO_LED=_crol_(GPIO_LED,1
//); Similarly, when P3^3 is pressed, external interrupt 1 will be triggered
//, and interrupt handler 0 will assign KeyValue to 0; at this time, the main loop will execute GPIO_LED=_cror_(GPIO_LED,1).
Previous article:Design and experiment of MCU music program
Next article:Interrupted learning
- 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
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
- Let’s talk about the “Three Musketeers” of radar in autonomous driving
- Why software-defined vehicles transform cars from tools into living spaces
- Practical operation of gate valve in high and low temperature test chamber
- Answer the questions to win prizes | Infineon takes you into the world of silicon carbide (SiC)
- [Domestic RISC-V Linux Banfang·Starlight VisionFive Trial Report] Use USB camera to establish MJPEG streaming service
- Play with AT32F437 (2) --- Simple identification of QR code
- 【GD32F307E-START】+ button test
- The problem of brushless DC motor without Hall no-carry waveform
- TL16C754C application consultation
- EEWORLD University ----TI Body Motor Solution
- Chinese semiconductor companies have raised $38 billion this year, double last year
- How to generate 10.4V and 9.3V from 16V