//==Declaration area= ... #include#define uint unsigned int #define uchar unsigned char void delay(uint a); bit c,b; //==Main program area= ... void main() { EA=1; //Open the general interrupt EX0=1; //Open external interrupt 0 IT0=0; //Set interrupt 0 to level trigger IT1=0; //Set interrupt 0 to level trigger EX1=1; //Open external interrupt 1 while(1) { P1=0xfe; //Turn off the LED in INT0 P0=0xff; //Turn off the digital tube in INT1 P0=0x00; P2=0xf8; P1=0xfe; while(1); } } //=Subroutine area============================================================================================================================== void delay(uint a) { uint b,c; for(b=a;b>0;b--) for(c=110;c>0;c--); } void Int0() interrupt 0 // The service subroutine of external interrupt 0 does not need to be declared in the declaration area { uint a; a=10; while(a--) //You cannot use while(1) here. If not, when the external interrupt has become a high level, it is impossible to jump out of the interrupt service subroutine. { P0=0x00; P2=0xf8; P1=0xff; delay(1000); P1=0x00; delay(1000); } } void Int1() interrupt 2 //The service subroutine of external interrupt 1 does not need to be declared in the declaration area. { delay(1); c=P3^3; if(c==0) { delay(1); if(c==0) { uint a; a=10; while((a--)) //You cannot use while(1) here. If not, when the external interrupt has become a high level, it is impossible to jump out of the interrupt service subroutine. { P1=0xff; P2=0xf8; P0=0x3f; delay(1000); P2=0xf9; P0=0x00; delay(1000); P2=0xf8; P0=0x06; delay(1000); P2=0xf8; P0=0x5b; delay(1000); P2=0xf8; P0=0x4f; delay(1000); P2=0xf8; P0=0x66; delay(1000); P2=0xf8; P0=0x6d; delay(1000); } } } }
/*The program function is to light up the first LED. If the P3^2 port is at a low level, it will enter the interrupt program. The interrupt function is to flash all eight LEDs. If the P3^3 port is at a low level, it will enter external interrupt 1. The program implementation of external interrupt 1 is that the first digital tube displays 0, 1, 2, 3, 4, 5. But I haven't figured out why there is a time interval between 0 and 1 and everyone's delay They are the same, but the display is different. The program implements that after the interrupt ends, the 8 LEDs of INT0 are still lit, and the last digital tube of INT1 is still lit, because the LED and digital tube are not turned off in the main program. Note that my development board's P0 port is connected to a digital tube (common cathode), P2 port is 74HC138, and P1 port is LED*/
Previous article:Design and implementation of a low-noise portable ECG monitor
Next article:Timing conflicts among serial port, I2C bus, EEPROM and LCD driver
Recommended ReadingLatest update time:2024-11-16 21:51
- Popular Resources
- Popular amplifiers
- Wireless Sensor Network Technology and Applications (Edited by Mou Si, Yin Hong, and Su Xing)
- Modern Electronic Technology Training Course (Edited by Yao Youfeng)
- Modern arc welding power supply and its control
- Small AC Servo Motor Control Circuit Design (by Masaru Ishijima; translated by Xue Liang and Zhu Jianjun, by Masaru Ishijima, Xue Liang, and Zhu Jianjun)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- 【LAUNCHXL-CC2650】LAUNCHXL-CC2650 unboxing test
- What kind of programming language is Python?
- GD32E231 DIY Contest (5) - Complete the driver and settings of DS1302 and the recognition of long and short keys
- [Operational amplifier parameter analysis and LTspice application simulation] Come to LTspice|Calculate the RMS value of the amplifier circuit noise...
- 【GD32E503 Review】GD32E503VET6 Performance Test
- Share the troubleshooting of using bq34z100 chip
- The salary and development path of hardware engineers
- MSP430 series MCU-Timer_A realizes PWM
- Here are some questions about the differential signal amplifier circuit
- [Gizwits Gokit 3 Review] Part 2: Product Creation