1. Experimental Content
INT0 is connected to a single pulse generator. Pressing a pulse generates an interrupt, and the CPU reverses the state of P1.0. P1.0 is connected to an LED light to check the signal reversal.
Write a program based on the experimental content, and debug and verify it on the experimental system.
2. Simulation diagram
3. Code
C language implementation:
sbit LED=P1^0;
void INT0_IN();
void main()
{
LED=0;
INT0_IN();
while(1) ;
}
void INT0_IN()
{
EA=1; //General interrupt is turned on
EX0=1; //External interrupt 0 is turned on
IT0=0; //Negative edge trigger
}
void exter0() interrupt 0
{
IE0=0;
LED=~LED;
}
Assembly implementation:
LED BIT P1.0
LEDBUF BIT 20H
ORG 0000H
LJMP START
ORG 0003H
LJMP INT00
ORG 0030H
START: MOV SP,#60H
CLR LEDBUF // clear to 0
CLR LED // clear to 0
MOV TCON, #01H ; External interrupt 0 falling edge trigger
MOV IE, #81H ; Enable external interrupt enable bit (EX0) and general interrupt enable bit (EA)
OK: LJMP OK
INT00: PUSH PSW; protect the scene
CPL LEDBUF ; Invert LED
MOV C, LEDBUF
MOV LED, C
POP PSW ; Recovery site
RARELY
END
Previous article:51 MCU: External I/O port expansion experiment
Next article:51 MCU: 74LS138 decoding experiment
- Popular Resources
- Popular amplifiers
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
- 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
- [RVB2601 Creative Application Development] VI. Sound Playback Test of RVB2601
- MicroPython adds instructions for pyboard.py
- SD/MMC SPI mode command set
- DS90UB954 debugging problem help
- Microsecond latency, wireless communication solution
- Use STM32 Universal Bootloader to make OTA easier
- MLCC Noise Howling and Countermeasures
- The concepts of short circuit protection, overload protection and zero voltage protection
- Design of brushless DC motor driver based on hardware FOC TMC4671
- [ART-Pi Review] VI: Review of ATT-Pi's onboard Flash file system and FTP functions in RTT Studio environment