Interrupts are implemented using the interrupt keyword and terminal numbers 0-4:
Return value Function name interrupt n
n corresponds to the number of the interrupt source. The interrupt number tells the interrupter the entry address of the interrupt program, which corresponds to the enable bit in the IE register, that is, bit 0 in the IE register corresponds to external interrupt 0. The
interrupt sources and terminal numbers of the 8051 microcontroller are as follows:
In the 51 series of single-chip microcomputers, some single-chip microcomputers have up to 32 interrupt sources, so the terminal numbers are 0-31.
When a specific task is being executed, there may be more urgent things that need to be handled by the CPU, which involves interrupt priority. High-priority interrupts can interrupt low-priority interrupt programs that are being processed, so it is best to assign different register groups to each priority program. In C51, you can use using to specify the register group. The variable after using is a constant integer from 0 to 3, which represents the 4 register groups in the 51 single-chip microcomputer. The complete syntax of the interrupt function is as follows:
return value function name ([parameter]) [mode] [reentry] interrupt n [usingn]
unsigned int interruptcnt;
unsigned char second;
void timer0 (void) interrupt 1 using 2
if (++interruptcnt==4000) // count to 4000
second++; // another counter
interruptcnt=0; // counter clear
Reference address:51 MCU interrupt function
Return value Function name
n corresponds to the number of the interrupt source. The interrupt number tells the interrupter the entry address of the interrupt program, which corresponds to the enable bit in the IE register, that is, bit 0 in the IE register corresponds to external interrupt 0. The
interrupt sources and terminal numbers of the 8051 microcontroller are as follows:
Interrupt number | Interrupt Sources | Entry address |
0 | External interrupt 0 | 0003H |
1 | Timer/Counter 0 Overflow | 000BH |
2 | External interrupt 1 | 0013H |
3 | Timer/Counter 1 Overflow | 001BH |
4 | Serial port interrupt | 0023H |
In the 51 series of single-chip microcomputers, some single-chip microcomputers have up to 32 interrupt sources, so the terminal numbers are 0-31.
When a specific task is being executed, there may be more urgent things that need to be handled by the CPU, which involves interrupt priority. High-priority interrupts can interrupt low-priority interrupt programs that are being processed, so it is best to assign different register groups to each priority program. In C51, you can use using to specify the register group. The variable after using is a constant integer from 0 to 3, which represents the 4 register groups in the 51 single-chip microcomputer. The complete syntax of the interrupt function is as follows:
unsigned int interruptcnt;
unsigned char second;
void timer0 (void) interrupt 1 using 2
if (++interruptcnt==4000)
second++;
interruptcnt=0;
Previous article:C language program based on 51 single chip infrared encoding and decoding
Next article:Design and simulation of electronic clock
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
- 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)
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- 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
MoreDaily News
- 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
- How Lucid is overtaking Tesla with smaller motors
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Wi-Fi 8 specification is on the way: 2.4/5/6GHz triple-band operation
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
- Vietnam's chip packaging and testing business is growing, and supply-side fragmentation is splitting the market
Guess you like
- "Core" ecosystem, "Assist" security, "Connect" the future. Registration for the 2021 STM32 China Summit and Fan Carnival is now open!
- Critical issues with naked code
- Please tell me the role of these two resistors in the circuit
- Is the naked-eye 3D large screen also made of light-emitting diodes (LED)? What is the principle?
- Comparison of TI's tms320 series DSP
- Playing with Zynq Serial 45——[ex64] Image Laplace Sharpening Processing of MT9V034 Camera
- New employee: I am the most idle person in the company, so my boss assigned me to write the bootloader
- I feel like I can't stay in this stupid company any longer.
- TI High Power Density Solution Analysis!
- Can the CH246 & CH241 wireless charging kit be used like this?