The External Interrupt of single-chip microcomputer has also been enhanced by other single-chip microcomputer, which is not triggered by a simple descent edge. Currently, high and low level triggering is triggered, and the rising edge and falling edge are triggered, more level changes are triggered. At present, the development is basically complete, and the external interrupt function is very great. It can be that the standby microcontroller is activated and runs normally, and the application design can be used as a button, for example, the infrared remote control program is completed by combining the timer with the External Interrupt. The test frequency is also achieved by the external interrupt, and the pulse width is calculated. The introduction of the concept of interruption makes it difficult for many beginners to understand external interruptions. Why is there an interruption! This problem has been ruined on the Internet. The interrupt mechanism is to respond to external events to achieve intelligent control or handling. The number of interruptions of a single-chip microcomputer is directly related to the performance of the single-chip microcomputer. The richer the interruptions, the better the single-chip microcomputer settings and the more powerful the functions are. Interruption comprehension is simply a function module outside the CPU!
# Include <reg52.h>/**-51 configuration of the MCU's External Interrupt-**/void ex_init (void) {ex0 = 1; // enable it0 for local external interruptions 0 = 1; // The Descent edge triggers ex1 = 1; it1 = 1; px1 = 1; // The interrupt priority settings, in general, it is the highest interrupt level of the natural priority 0 to 4. 0} void main (void) {ex_init (); EA = 1; // enable global interruption for (;) {pcon = 0x01; // in idle mode, the CPU stops working .}} Void ex0_int (void) interrupt 0 // interrupt the service program, tell the storage address of the interrupt service program {p1 = 0x01;} take the program to the following and update it occasionally! Void ex1_int (void) interrupt 2 // inform the interrupted service program of the storage address {p1 = 0x02 ;} // try to see the effect on your development board or simulation software protues. It is recommended that you write it first to see the effect and then think about it.