- Interrupt source: The event that caused the interrupt
- Interrupt request: The interrupt source makes a request to the CPU for processing
- Breakpoint: The pause point of the program when an interrupt occurs
- Interrupt response: The process by which the CPU pauses the current program and responds to an interrupt request
- Interrupt handler: A program that handles an interrupt source
- Interrupt processing: CPU executes the relevant interrupt processing program
- Interrupt return: the process of returning to the breakpoint
The difference between interrupts and subroutines
Calling is somewhat similar, but the two are different concepts.
- The source is different. Interrupts are generated by external interrupt sources and are unpredictable and random, such as throwing exceptions. Subroutines are called by the main program.
- The responses are different. The interrupt system needs to protect the breakpoints and context, while the subroutine only needs to save the breakpoints.
- The functions are different. The interrupt program mainly handles CPU external asynchronous events, and the subroutine call serves the main program.
Interrupt Type
- External interrupt source: generated by external hardware resources. Up and down edge trigger and high and low level trigger.
- Timing interrupt source: timer/counter overflow trigger.
- Serial port interrupt source: triggered by sending or receiving completion information during serial communication.
TCON interrupt flag
- IE1: External interrupt 1 request flag.
- IT1: External interrupt 1 trigger mode selection bit. When IT1=0, it is low level trigger mode; when IT1=1, it is falling edge trigger mode.
- IE0: External interrupt 0 request flag.
- IT0: External interrupt 0 trigger mode selection bit. When IT0=0, it is low level trigger mode; when IT0=1, it is falling edge trigger mode.
SCON interrupt flag
- RI: After receiving the information on the serial interface, the hardware automatically sets RI=1 and the CPU responds to the interrupt. Note that it will not automatically clear RI=0 and needs to be set by software
- TI: After the serial interface completes sending information, the hardware automatically sets TI=1 and the CPU responds to the interrupt. Note that it will not automatically clear TI=0 and needs to be set by software
General steps for interrupt initialization
1. Determine the working mode (i.e. assign a value to TMOD);2. Preset the initial value of timing or counting (the initial value can be directly written into TH0, TL0 or TH1, TL1);
3. Enable the interrupt of the timer/counter as needed (directly assign a value to the IE bit);
4. Start the timer/counter (if it is specified to be started by software, TR0 or TR1 can be set to "1"; if it is specified to be started by the external interrupt pin level, a start level needs to be added to the external pin. When the start requirements are met, the timer starts counting or timing according to the specified working mode and initial value).
Interrupt enable flag
- EX1: External interrupt 1 enable bit;
- EX0: external interrupt 0 enable bit;
- ET1: Timer/Counter T1 interrupt enable bit;
- ET0: Timer/Counter T0 interrupt enable bit;
- ES: serial port interrupt enable bit;
- EA: CPU interrupt enable (always enable) bit.
Interrupt priority flags
- PS: Serial interface interrupt priority setting bit
- PT1: Timer/Counter Interrupt 1 Interrupt Priority Setting Bit
- PT0: Timer/Counter Interrupt 0 Interrupt Priority Setting Bit
- PX1: External interrupt 1 interrupt priority setting bit
- PX0: External interrupt 0 interrupt priority setting bit
51 MCU interrupt number
- External interrupt 0 (INT0), the corresponding interrupt number is 0, the interrupt entry address is 0003H
- Timer/Counter 0 (T1), corresponding to interrupt number 1, interrupt entry address 000BH
- External interrupt 1 (INT1), interrupt number 2 entry address 0013H
- Timer/Counter 1 (T1) Interrupt Number 3 Entry Address 001BH
- Serial port (RI/TI) interrupt number 4 Entry address 0023H
- These five are AT89S51, 52 also has the following
- Timer/Counter 2 (T2) interrupt number 5, entry address 002BH
- Function name()interrupt 0 {} //Corresponding to external interrupt 0;
- Function name ()interrupt 1 {} //Corresponding to timer/counter 0 interrupt;
- Function name()interrupt 2 {} //Corresponding to external interrupt 1;
- Function name ()interrupt 3 {} //Corresponding to timer/counter 1 interrupt;
- Function name ()interrupt 4 {} //Corresponding to serial port interrupt;
Previous article:Renesas MCU Learning Notes (1) Basic Configuration
Next article:51 MCU Study Notes (VI)_Serial Port Interrupt Communication + Timer 2 Serial Port Interrupt
- 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
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- 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
- FAQ Power Management, Battery Management
- Together wow: Smart soldering iron based on domestic chip, portable soldering iron system IronOS (FreeRTOS)
- How to add code to ardunio ide
- Blackboard with 24 touch keys, 9 customizable LEDs
- TI DLP Pico micro-projection technology makes smart speakers more powerful
- Is there any correlation between the firmware library (standard library) and these operating systems? Can't we write an operating system using library functions?
- 50 555 Circuits—Chinese Version
- I have a few questions about tinning in AD. Please help answer them.
- Design and implementation of temperature controller based on single chip microcomputer and fuzzy control
- Review summary: ART-Pi is here: high-performance H7 chip, DIY tool