Cainiao takes you to kill Single-Chip Microcomputer in seconds 51 Single-Chip Microcomputer-External interruption

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.