The MCS-51 series of microcontrollers provide multiple interrupt sources (8051 provides 5, 8052 provides 6 interrupt sources). Each interrupt source can be programmed with two levels of interrupts, high-level interrupt requests and low-level interrupt requests, so two-level interrupt service nesting can be achieved. Even for interrupt sources of the same level, when requesting interrupts at the same time, the CPU response has a different order. Therefore, MCS-51 is widely used in real-time systems and instrumentation. The design of the interrupt system is a key point in software design. If it is not handled properly, the software will often fail to achieve the designed effect.
The following is a problem I encountered during the application process.
The power meter we designed contains a keyboard and a second clock. The keyboard interrupt uses INT0, and the second clock uses T0. INT0 is set as a high priority interrupt, and T0 is a low priority. The second interrupt service takes about 750ms. The CPU is required to have a high response speed to the keyboard, and once a valid keyboard command is received, the program will re-enter the measurement state from the waiting position and will not return to the place where it was interrupted by the keyboard. The software flow is shown in Figure 1.
The original keyboard service program ends as follows:
During the debugging process, after responding to the keyboard interrupt, it is often unable to enter the second interrupt normally, and only waits in the WAIT loop. At this time, EA=1, TR0=1, TF0=1. It can be seen that EA=1, TR0=1, TF0=1 are not sufficient and necessary conditions for interrupt T0 response.
After consulting relevant information from multiple sources, it was discovered that the interrupt system of the MCS-51 series microcontrollers has two non-addressable priority status triggers. Their set states, one indicates that the CPU is executing a high-priority interrupt service program, and the other indicates that a low-priority interrupt service is being executed. The set states of these two triggers respectively shield all interrupt requests and other interrupt requests of the same priority level.
The second interrupt service takes 750ms. When the keyboard is pressed, there is a 75% chance that the second interrupt service program is being executed, indicating that the trigger for executing the low-priority interrupt service has been set. After responding to the keyboard interrupt, the trigger for executing the high-priority interrupt service is set. However, only one RETI instruction is executed during the entire process, indicating that the trigger for the CPU executing the T0 interrupt is not reset. Even if TR0=1, TF=1, and EA=1, the CPU still believes that the program has executed the second interrupt service, and therefore cannot enter the second interrupt service again. For this reason, the author changed the original program to
After the assembly is loaded into the system, everything is normal.
Previous article:Keil mode settings and programming matters
Next article:Using the redundant I/O ports of a single-chip microcomputer to implement a temperature detection circuit
Recommended ReadingLatest update time:2024-11-16 17:50
- Popular Resources
- Popular amplifiers
- 【ON Semiconductor】LC87F7932B8-bit single-chip microcontroller
- USB Complete The Developer\'s Guide 5ed (USB Development Complete 5th Edition)
- Introducing the application of multiplication and division instructions with interrupt functions of C16x series microcontrollers
- ARMask.The ARM has six operating modes:• User (unprivileged mode under which most tasks run)
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
- How to suppress the output ripple of switching power supply?
- What is the file with the suffix jed? What is its function?
- EEWORLD University ---- ESP32 MicroPython Video Tutorial
- Relationship between PN conduction voltage drop and current and temperature
- [GD32L233C-START Review] 15. RT-Thread message queue, multi-threaded use
- High-speed rail Spring Festival travel benefits?
- NXP Rapid IoT Review Summary and Highlights (Updated January 25)
- Essence ESP-S3-12K (Part 1) ---- Unboxing
- Medical device EMC and safety testing
- Can you share your experience in learning layout design?