About 51 MCU external interrupt response

Publisher:脑洞狂想Latest update time:2016-08-25 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
It is best to set the external interrupt mode to the falling edge mode, especially when the interrupt pin is connected to a button.

External falling edge interrupt: SETB IT0. The hardware automatically samples the pin in each machine cycle. If the level changes from high to low in two consecutive cycles, it is considered that there is an interrupt request, and IE0 = 1. IE0 will remain until the interrupt request is responded to by the CPU. It will not be automatically cleared before the response. Only after the response will the hardware automatically clear IE0 to IE0 = 0.

 External low-level interrupt: CLR IT0. When the interrupt pin is at a low level and maintains a machine cycle, the hardware automatically sets IE0=1. If the interrupt pin is sampled at a high level in the next cycle, the hardware automatically clears IE0 to 0. Conditions for automatically clearing the interrupt flag: The falling edge interrupt will only be cleared to 0 when the CPU responds to the interrupt, otherwise it will remain. Low-level interrupt: At any time when the external interrupt pin is at a low level, IE0=1; when it is at a high level, IE0=0, so there is no need to respond to the interrupt to clear it to 0, which is related to the pin status. Note: When EA=0, the interrupt pin is at a low level and IE0 will not be automatically set to 1. It will only be automatically set to 1 when EA=1.

When there are two CPUs in the single-chip design, the main CPU should pay attention to the following when controlling the interrupt of the sub-CPU: when the main CPU sends an interrupt signal, the sub-CPU can receive it in time, that is, the sub-CPU working state is not allowed to run in the program with CLR EA disabled. As long as the sub-CPU is not working in the program with interrupt disabled, the sub-CPU can respond to the interrupt signal sent by the main CPU in time. In addition, if the falling edge method is used, the interval between the high and low levels sent by the main CPU only needs one NOP instruction. Therefore, this time difference problem should be considered as much as possible. Sometimes, the main CPU sends an interrupt signal before the sub-CPU has finished running the program that masks the interrupt, causing the sub-CPU to be unable to interrupt or to work intermittently.

Keyboard interrupts can finally come to an end today.

 

Now I know that having a program structure does not mean that the program is easy to complete. More time is spent on debugging, simulation, debugging again, and so on. So when you encounter problems, you must be patient, confident, and careful. If you do these three things, you will succeed! ! ! !

Reference address:About 51 MCU external interrupt response

Previous article:Design of Small Temperature Detection System Based on Matlab
Next article:51 single chip microcomputer read and write max186 c51 program

Recommended ReadingLatest update time:2024-11-16 13:28

51 MCU assembly instruction quick reference table
Instruction format Function Description Bytes Cycles 1. Data transfer instructions MOV A, Rn Register to accumulator 1 1 MOV Rn, A Accumulator to register 1 1 MOV A, @Ri Internal RAM unit sends accumulator 1 1 MOV @Ri, A Accumulator sends internal RAM unit 1 1 MOV A, #data immediately sends the data to acc
[Microcontroller]
Application of Timer/Counter T0 of AT89S51 Microcontroller
1. Experimental tasks Use the timer/counter T0 of the AT89S51 microcontroller to generate a one-second timing time as the second counting time. When one second is generated, the second counting increases by 1. When the second counting reaches 60, it automatically starts from 0. The hardware circuit is shown in the fig
[Microcontroller]
Application of Timer/Counter T0 of AT89S51 Microcontroller
51 MCU EEPROM 24c02 reads and stores multiple bytes
First store the data, then read it out and display it on the digital tube. In addition to the connections defined in the code, p0 must also be connected to pin 8 of the 8-bit digital tube. 1 /*-- 2 Name: IIC protocol EEPROM24c02 3 Content: This program is used to test the performance of EEPROM. The test method
[Microcontroller]
89C51 MCU timer/counter, P1 port programming example
There is a light-emitting diode connected to the P1.0 port of the 89C51 microcontroller. When P1.0 outputs a low level, the light-emitting diode lights up, and when it outputs a high level, it goes out. There is a switch connected to P1.7. When the switch is closed, P1.7 is at a low level, and when it is disconnected,
[Microcontroller]
Based on 51 single chip microcomputer, a program that lights up every 3 seconds
#include reg52.h sbit led=P2^0; void delay3s(void) //error 0us { unsigned char a,b,c; for(c=189;c 0;c--) for(b=230;b 0;b--) for(a=33;a 0;a--); } void main() { while(1) { led = ~led;
[Microcontroller]
51 MCU Notes
For microcontroller programs written in C language, the declaration of registers is contained in the header file "reg52.h" Special statement: sfr——Special function register data declaration, declares an 8-bit register. sfr16——Data declaration of 16-bit special function register. sbit - special function bit dec
[Microcontroller]
Design of RS 232 serial data interception based on AT89C51 single chip microcomputer
    introduction     At present, there is still a certain gap between my country's equipment technology level and that of developed countries. For advanced equipment introduced from abroad, how to break through its technical bottleneck without any technical information and achieve leapfrog development of equipment tec
[Microcontroller]
Design of RS 232 serial data interception based on AT89C51 single chip microcomputer
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号