80C51 MCU Program (4)

Publisher:码农闲散人Latest update time:2016-03-18 Source: eefocusKeywords:80C51 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
//80C51 MCU program - use of interrupts

#include    //Include reg52.h header file
#define uint unsigned int    //Macro definition of uint data type is unsigned int type
#define uchar unsigned char    //Macro definition of uchar data type is unsigned char type 
sbit D1=P2^6;
sbit W1=P2^7;
sbit D2=P1^0;
uchar num;
uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};    //Common cathode digital tube 0-9
void delay(uint z);   //Declare delay subfunction
void main()
{
     EA=1;//Open total interrupt
    EX0=1;//Open external interrupt 0
    TCON=0x01;   //Open jump
    W1=1;    //Send high potential to the latch to open the latch

     P0=0xea;
    W1=0;     //Send low voltage to the latch and close the latch
    while(1)
   {
        for(num=0;num<10;num++)    //Loop 10 times, display numbers 0-9
        {
              D1=1;    //Turn off the digital tube display   
              P0=table[num];
             D1=0;    //Open the bit port
             delay(1000);     //Delay program 
         }
    }
}

void delay(uint z)    //delay sub-function with parameters
{
    uint x,y;
   for(x=z;x>0;x--)
       for(y=110;y>0;y--);    //enter a nested loop 
}

void exter0() interrupt 0    //External interrupt 0 program
{
   D2=0; 
}

Keywords:80C51 Reference address:80C51 MCU Program (4)

Previous article:A classic design of embedded gateway based on CAN bus and Ethernet
Next article:80C51 MCU Program (3)

Recommended ReadingLatest update time:2024-11-16 22:51

Realization of Broadband DC Amplifier Based on 80C51
This system uses 80C51 single-chip microcomputer as the control chip of broadband DC amplifier circuit, and uses VCA810 composed of amplifier circuit to intelligently amplify the input small signal. The amplification gain can be adjusted macroscopically through potentiometer, and the amplification gain can be accurate
[Analog Electronics]
Realization of Broadband DC Amplifier Based on 80C51
Taking 80C51 microcontroller as an example to describe how the microcontroller operates
Preface To understand how a microcontroller runs a program, you first need to understand the composition of a microcontroller. This article takes the 80C51 microcontroller as an example to tell you how the program runs in the microcontroller. The composition of the microcontroller The internal hardware structure of
[Microcontroller]
Taking 80C51 microcontroller as an example to describe how the microcontroller operates
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号