External interrupt system block diagram:
The interrupt request flags of these interrupt request sources are latched by the response bits of the special function registers TCON and SCON.
1. TCON register
The lower four bits are related to the interrupt.
1) IT0 and IT1 - external interrupt request trigger flag:
0——Low level trigger;
1——Falling edge trigger
Can be set and cleared by software
2) IE0 and IE1 - external interrupt request flags
1——Indicates that there is an interrupt request. The CPU will respond to the interrupt request and jump to the interrupt service routine. The interrupt program is processed according to the priority. When jumping into the interrupt service routine, it is cleared to 0 by hardware;
0——Indicates no interrupt request.
The reset value TCON is always 0.
SCON is the serial port control register, see Serial Port for details.
2. Interrupt enable register IE, bit addressable, reset to 0:
When each bit is 1, the corresponding bit interrupt is enabled, and when it is 0, the corresponding bit interrupt is disabled. EA is the general interrupt switch.
Note: After the microcontroller responds to an external interrupt, it will automatically clear the external interrupt flag to 0. However, due to the characteristics of the external interrupt request triggering method, the problem of repeated requests should be avoided when using external interrupts.
External interrupt 0 programming steps;
1. Set the external interrupt request enable bit and set the EA EX0 bit in the IE register;
2. Select the appropriate external interrupt request mode, that is, set IT0 (or IT1) in TCON;
3. Write the interrupt service function.
Examples:
main()
{
IT0 = 1; //Set external interrupt 0 to falling edge trigger
EX0 = 1; //Open external interrupt 0
EA = 1; //Open general interrupt
while (1)
;
}
void ext_interrupt(void) interrupt 0
{
delay(5);
if (button0 == 0) {
led = !led;
}
}
Previous article:51 MCU interrupt and timing counter attempt
Next article:51 MCU code storage problem
Recommended ReadingLatest update time:2024-11-16 13:31
- Popular Resources
- Popular amplifiers
- MCU C language programming and Proteus simulation technology (Xu Aijun)
- 100 Examples of Microcontroller C Language Applications (with CD-ROM, 3rd Edition) (Wang Huiliang, Wang Dongfeng, Dong Guanqiang)
- Fundamentals and Applications of Single Chip Microcomputers (Edited by Zhang Liguang and Chen Zhongxiao)
- Single chip microcomputer control technology (Li Shuping, Wang Yan, Zhu Yu, Zhang Xiaoyun)
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
- Beetle ESP32-C3 test (Part 1) Unboxing and filling holes
- How to connect the power cord and ground wire when charging a lithium battery using a USB-TYPE-C interface?
- Qorvo Launches Complete V2X Front-End Solution
- [Raspberry Pi 4B Review] Raspberry Pi 4 running test on different operating systems
- Are the transistors MMBT2222A and 8050D completely interchangeable? In what applications can they not be replaced?
- Showing goods + embedded primary development board
- Domestic FPGA AGM
- What is the physical meaning of Stokes' formula in advanced mathematics?
- TI|Pain Point Unlocker: We understand your power supply design pain points! Unlock and comment to win gifts!
- Please help me see what went wrong