interrupt m modifier
The C51 interrupt function must be modified by this modifier. In C51 programming, when the interrupt m modifier is used in the function definition, the system converts the corresponding function into an interrupt function during compilation, automatically adds the program header and trailer, and automatically arranges it in the corresponding position in the program memory according to the 51 system interrupt processing method.
In this modifier, the value of m is 0~31, and the corresponding interrupt conditions are as follows:
0——External interrupt 0
1——Timer/Counter T0
2——External interruption 1
3——Timer/Counter T1
4——Serial port interrupt
5——Timer/Counter T2
Other values are reserved.
The C51 compiler generates an interrupt vector from the absolute address 8m+3, where m is the interrupt number, which is the number after interrupt. The vector contains an absolute jump to the entry address of the interrupt function.
[Example] Write an interrupt service program to count the number of interrupts of external interrupt 0
1 int x=0;2 void int0() interrupt 0 using 13 {4 x++;5 }
using n modifier
The modifier using n is used to specify the working register group used within this function, where n is a value between 0 and 3, indicating the register group number. This modifier can be omitted, and the system automatically selects the register group number after it is omitted.
Note the following about the interrupt function:
(1) Interrupt functions cannot pass parameters. If an interrupt function contains any parameter declaration, a compilation error will occur.
(2) The interrupt function has no return value. If you attempt to define a return value, you will not get the correct result. It is recommended to define the interrupt function as a void type to clearly indicate that there is no return value.
Previous article:Program to test timer 0
Next article:51 MCU SRF register
Recommended ReadingLatest update time:2024-11-16 15:48
- 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
- Analysis of the working principles of seven triode collector DC circuits 2
- Circuit
- TMS320F28035 call jump instruction problem
- Sliding resistor for LM358 comparator
- TE pressure sensor: underwater robots from 0 to 1000, how to avoid mass production pitfalls
- OHM Graphical Introduction to Electronics
- Detailed explanation of the design of RFID-based smart hotel system
- 【Qinheng Trial】Streamlined mobile phone system design #1
- A newbie asks a question about the STC15 interrupt function
- MSP432P401R LaunchPad download program prompts not supported