⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 51

📁 计算机控制系统
💻
字号:
#include    <reg51.h>
#include    <absacc.h>
#define		Led_dat		XBYTE[0xcfe8]
#define		Led_ctl		XBYTE[0xcfe9]
struct  time
  {
   char minute;
   char second;
  };
 struct time  current_time;
void Display_byte(unsigned char loc,unsigned char dat)
  {
   unsigned char table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40};
   loc &=0xf;
   Led_ctl = loc|0x80;
   if(dat==0xaa) Led_dat = table[10];
   else Led_dat = table[dat/10];     /*显示10进制数的十位数*/
   loc++;
   Led_ctl = loc|0x80;
   if(dat==0xaa) Led_dat = table[10];
   else Led_dat = table[dat%10];          /*显示10进制数的个位数*/    
  }
void time1(void) interrupt 3
  {
   static buf=0;
   TR1 = 0;
   TL1 = 0xaf;
   TH1 = 0x3c;
   buf++;
   if(buf>9)
     {
      buf=0;
      current_time.second++;
      if(current_time.second>59)
        {
         current_time.second = 0;
         current_time.minute++;
         if(current_time.minute>59)
          current_time.minute=0;  
        }
     }
   Display_byte(4,current_time.second);
   Display_byte(0,current_time.minute);
   TR1 = 1;
  }
void main(void)
  {
   TMOD = 0x10;
   TL1 = 0xaf;
   TH1 = 0x3c;
   IE = 0x88;
   Led_ctl = 0xd1;
   while((Led_ctl&0x80)==0x80);
   Led_ctl = 0x31;
   current_time.minute = 0;
   current_time.second = 0;
   Display_byte(2,0xaa);
   TR1 = 1;
   while(1);
  }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -