Reset Problems in MCS-51 Interrupt System

Publisher:暗里著迷Latest update time:2011-10-12 Keywords:MCS-51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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.

Keywords:MCS-51 Reference address:Reset Problems in MCS-51 Interrupt System

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

Features of the internal data memory of MCS-51 microcontroller and how to set it up
How is the internal data memory of the MCS-51 microcontroller set up? Answer: The MCS-51 microcontroller has 128 bytes of data storage inside, and the internal RAM address is 00H~7FH. MCS-51 has a rich set of operating instructions for its internal RAM memory, which facilitates program design. What are the chara
[Microcontroller]
MCS-51 arithmetic instructions
There are 24 arithmetic operation instructions, and arithmetic operations mainly perform addition, subtraction, multiplication, and division. In addition, a considerable part of the MCS-51 instruction system is for addition and subtraction of 1, and the operation and adjustment of BCD codes, which are all classified as
[Microcontroller]
Timer/Counter 0 (Counter)
/* Effect description: Counter interrupt: program execution through external count Press the interrupt button once, the upper four bits will light up when the interrupt occurs, and the program will return to the main program after the interrupt occurs. */ #include reg51.h #in
[Microcontroller]
Timer/Counter 0 (Counter)
MCS-51 single-chip timer/counter, serial port, multi-machine communication
The MCS-51 microcontroller contains two timers/counters with four working modes. It has two working modes (counter mode and timer mode). The MCS-51 microcontroller contains one full-duplex serial port with four working modes. TMOD - Timer/Counter Mode Control Register TCON - Timer/Counter Control Register SMOD - Seria
[Microcontroller]
Commonly used single chip microcomputers and their performance
    Typical chips of MCS-51 microcontrollers are 8031, 8051, and 8751. The 8051 has a 4KB ROM, the 8751 has a 4KB EPROM, and the 8031 ​​has no ROM. Apart from this, the internal structures and pins of the three are exactly the same. Therefore, taking the 8051 as an example, the internal structure and signal pins of thi
[Microcontroller]
Commonly used single chip microcomputers and their performance
MCS-51 MCU external pins and bus interface
The 51 series microcontrollers generally use a 40-pin dual in-line package (DIP) package structure. In addition to the DIP package, the 51 microcontroller also uses a 44-pin square flat (QFP - Quad Flat Package) package (4 pins are useless). Three categories Port pins (32 in total) Power supply and crystal pins (
[Microcontroller]
MCS-51 MCU external pins and bus interface
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号