51 microcontroller (AT89C52) external interrupt program

Publisher:素雅之韵Latest update time:2018-06-21 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

#include  

#define uchar unsigned char  

#define uint unsigned int  

#define DELAY 1000  

void delay(uint z) //1ms  

{  

    uint x,y;  

    for(x=z;x>0;x--)  

        for(y=111;y>0;y--);  

}  

void main()  

{  

    uchar i,dt;  

    EA=1; //Enable total interrupt  

    EX1=1; //Enable external interrupt 1  

//IT1=0; //Set external interrupt 1 as low level trigger  

    IT1=1; //Set external interrupt 1 as falling edge trigger  

    while(1)  

    {  

        dt=0x01;  

        for(i=0;i<8;i++)  

        {  

            P2=dt;  

            delay(DELAY);  

            dt<<=1;  

        }  

    }     

}  

void exter1() interrupt 2  

{  

    P2=0xff;  

}  

If no interruption occurs, a single lamp will light up in a cycle; if an interruption occurs, all lights will light up.


Reference address:51 microcontroller (AT89C52) external interrupt program

Previous article:51 single chip microcomputer (AT89C52) controls buzzer
Next article:51 single chip microcomputer (AT89C52) controls dual relays

Recommended ReadingLatest update time:2024-11-15 15:43

AT89C52 MCU Proteus Simulation Music Player Operation Steps
Many beginners don't know how to use the Proteus simulator to make a music player. Although the function is simple, it is difficult for beginners to get started. I will post the simple process and source files here for beginners to learn. Operation steps: 1. Create a new project 2. Add components according to the
[Microcontroller]
AT89C52 MCU Proteus Simulation Music Player Operation Steps
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号