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

📄 1.lst

📁 使用C51做的电子钟
💻 LST
字号:
C51 COMPILER V6.12  1                                                                      03/24/2009 18:40:42 PAGE 1   


C51 COMPILER V6.12, COMPILATION OF MODULE 1
OBJECT MODULE PLACED IN .\1.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE .\1.c DEBUG OBJECTEXTEND

stmt level    source

   1          //采用8位LED软件译码动态显示,P0为字段码,P2为位选码,数码管共阳;
   2          //key0为位选键;key1为加“1键;key2为减“1”键。
   3          
   4          #include "reg51.h"
   5          #define char unsigned char 
   6          char code 
   7          dis_7[12]={0xc0,0xf9,0xa4,0xb0,	// 0, 1, 2, 3
   8          				0x99,0x92,0x82,0xf8,0x80,0x90,0xff,0xbf};//4,5,6,7,8,9,"灭”和“-”
   9          char code scan_con[8]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};//位的选择
  10          char _data_dis[8]={0x00,0x00,0x0b,0x00,0x00,0x0b,0x00,0x00};//显示缓冲区,时,分和秒初始为0,0x0b为“-”的
             -编码
  11          char data timedata[3]={0x00,0x00,0x00};
  12          char data ms50=0x00,con=0x00,con1=0x00,con2=0x00;
  13          sbit key0=P1^4;
  14          sbit key1=P1^5;
  15          sbit key2=P1^6;
  16          //1ms延时
  17          delay1ms(int t)
  18          { int i,j;
  19   1        for(i=0;i<t;i++)
  20   1          for(j=0;j<120;j++);
  21   1       }
  22          void deep()  //当有效按键被按下时,蜂鸣器响;
  23          {  int i;
  24   1         for(i=.0;i<10;i++)
  25   1         {P3^7 = 0;
*** ERROR C141 IN LINE 25 OF .\1.C: syntax error near '='
  26   2         delay1ms(1);
  27   2         P3^7 = 1;
*** ERROR C141 IN LINE 27 OF .\1.C: syntax error near '='
  28   2         }
  29   1      }
  30           //按键处理
  31          keycan()
  32           {  EA=0;
  33   1          if(key0==0)
  34   1      	   { delay1ms(10);deep();
  35   2      	     while(key0==0);
  36   2      		  con++;TR0=0;ET0=0;
  37   2      		  if(con>=3)
  38   2      		    { con=0;TR0=1;ET0=1;}
  39   2      		}
  40   1      		 if(con!=0)
  41   1      		   { if(key1==0)
  42   2      		      { delay1ms(10);deep();
  43   3      			     while(key1==0);
  44   3      				 timedata[con]++;
*** ERROR C187 IN LINE 44 OF .\1.C: not an lvalue
  45   3      				 if(con==2) con1=24;else con1=60;
  46   3      				   if(timedata[con]>=con1)
  47   3      				     { timedata[con]=0;}
*** ERROR C213 IN LINE 47 OF .\1.C: left side of asn-op not an lvalue
  48   3      			   }
  49   2      		 }
  50   1      		  if(con!=0)
C51 COMPILER V6.12  1                                                                      03/24/2009 18:40:42 PAGE 2   

  51   1      		    { if(key2==0)
  52   2      			    {delay1ms(10);deep();
  53   3      				  while(key2==0);
  54   3      				    timedata[con]--;
*** ERROR C187 IN LINE 54 OF .\1.C: not an lvalue
  55   3      					if(con==2) con2=23;else con2=59;
  56   3      					  if(timedata[con]<=0)
  57   3      					    { timedata[con]=con2;}
*** ERROR C213 IN LINE 57 OF .\1.C: left side of asn-op not an lvalue
  58   3      						}
  59   2      					   }
  60   1      					    EA=1;
  61   1      					 }
  62          //数码管显示
  63           scan()
  64           { char k;
  65   1          _data_dis[0]=timedata[0]%10; _data_dis[1]=timedata[0]/10;
*** ERROR C193 IN LINE 65 OF .\1.C: '%': bad operand type
*** ERROR C193 IN LINE 65 OF .\1.C: '/': bad operand type
  66   1          _data_dis[3]=timedata[1]%10; _data_dis[4]=timedata[1]/10;
*** ERROR C193 IN LINE 66 OF .\1.C: '%': bad operand type
*** ERROR C193 IN LINE 66 OF .\1.C: '/': bad operand type
  67   1          _data_dis[6]=timedata[2]%10; _data_dis[7]=timedata[2]/10;
*** ERROR C193 IN LINE 67 OF .\1.C: '%': bad operand type
*** ERROR C193 IN LINE 67 OF .\1.C: '/': bad operand type
  68   1         for(k=0;k<8;k++)
  69   1          { P0=dis_7[ _data_dis[k]];P2=scan_con[k];delay1ms(1);P2=0xff;}
  70   1      
  71   1      }
  72          //主函数
  73          main()
  74           { TH0=0x3c;TL0=0xb0;
  75   1         TMOD=0x01;ET0=1;TR0=1;EA=1;
  76   1          while(1)
  77   1      	  { scan();
  78   2      	   keycan();
  79   2      	  }
  80   1      }
  81          //定时器/记数器T0中断服务
  82           void time_intt0(void)interrupt 1
  83           { ET0=0;TR0=0;TH0=0x3c;TL0=0xb0;TR0=1;
  84   1         ms50++;
  85   1         if(ms50==20)
  86   1         { ms50=0x00;timedata[0]++;
*** ERROR C187 IN LINE 86 OF .\1.C: not an lvalue
  87   2           if(timedata[0]==60)
  88   2      	   { timedata[0]=0;timedata[1]++;
*** ERROR C213 IN LINE 88 OF .\1.C: left side of asn-op not an lvalue
*** ERROR C187 IN LINE 88 OF .\1.C: not an lvalue
  89   3      	     if(timedata[2]==24)
  90   3      		   {timedata[2]=0;
*** ERROR C213 IN LINE 90 OF .\1.C: left side of asn-op not an lvalue
  91   4      		   }
  92   3      	   }
  93   2      	} ET0=1;
  94   1        }

C51 COMPILATION COMPLETE.  0 WARNING(S),  16 ERROR(S)

⌨️ 快捷键说明

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