zoukankan      html  css  js  c++  java
  • 外部中断0,1

     #include <reg52.h>
     #define uint unsigned int
     #define uchar unsigned char
     uchar duan[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
     uchar liushui[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f};
     uchar num=0;
     void delay(uint i)
     {
        while(i--);
     }
    /* ********************************************************************************************* */
    void init(void)//初始化子函数
    {
       IT0=1;//设置外部中断0为边沿触发
       EX0=1;//打开外部中断0
       IT1=1;//设置外部中断1为边沿触发
       EX1=1;//打开外部中断1
       EA=1;//打开中断的总开关
       
       }    
       /* ********************************************************************************************* */
     main()              //主函数
       {
          init();
          while(1)
          {
         num++;
         if(num==10)
         num=0;
         P1=duan[num];
         delay(50000);
          }
       } 
          
     /* ********************************************************************************************* */
    void int0(void) interrupt 0//外部中断0处理程序
    {
       P1=0;
       delay(20000);
       P1=0x00;
       delay(20000);
        P1=0x00;
       delay(20000);
      
      }   
      /* ********************************************************************************************* */
       void int1(void) interrupt 2//外部中断1处理程序
    {
       
       uchar i,j;
       for(i=0;i<3;i++)
       {
          
          for(j=0;j<8;j++)
          {
         P2=liushui[j];
         delay(5000);
         }
          
          }
       
          P2=0xff;
      }     
    
       
    归去来兮
  • 相关阅读:
    jmeter录制rabbitmq消息-性能测试
    plsqll连接Oracle的两种方式
    Badboy录制脚本时,提示脚本错误的解决方法
    Decorator
    PyObject and PyTypeObject
    Python LEGB (Local, Enclosing, Global, Build in) 规则
    Python Namespace
    Method Resolve Order (MRO)
    Source Code Structure
    Bound Method and Unbound Method
  • 原文地址:https://www.cnblogs.com/zoute/p/7881013.html
Copyright © 2011-2022 走看看