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

📄 dzz_thesamea.lst

📁 基于单片机的数字时钟
💻 LST
📖 第 1 页 / 共 2 页
字号:
C51 COMPILER V6.12  DZZ_THESAMEA                                                           05/06/2008 17:16:29 PAGE 1   


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

stmt level    source

   1          #include <reg52.h>
   2          #define uchar unsigned char
   3          #define uint unsigned int 
   4          #define ulong unsigned long
   5          sbit choose_du=P2^6;
   6          sbit choose_we=P2^7;
   7          sbit s2=P3^4;
   8          sbit s3=P3^5;
   9          sbit s4=P3^6;
  10          sbit s5=P3^7;
  11          sbit beep=P2^3;
  12          
  13          bit beep_f;
  14          bit allow;
  15          bit yes;
  16          bit flag;
  17          bit temp;
  18          bit flag_voice;
  19          bit key_flag;
  20          
  21          uchar num_voice;
  22          uchar num;
  23          uchar num_sec,num_secflag;
  24          uchar num_hours,num_hourg,num_minis,num_minig;
  25          uchar num_hoursclock,num_hourgclock,num_minisclock,num_minigclock;
  26          uchar i,j;
  27          uchar times;
  28          uchar num_hourf;
  29          uchar num_key;
  30          uchar pres;
  31          
  32          uint upmost1=500;
  33          uint upmost2=50000;
  34          /*uchar code table_du[]={			//0-9的共阴极代码 	
  35          	0x3f,0x06,0x5b,0x4f,0x66,
  36          	0x6d,0x7d,0x07,0x7f,0x6f,0x40	
  37          			};
  38          uchar data_dis[5]={0x00,0x00,0x00,0x00,0x00};
  39          uchar scan_con[]={0xfe,0xfd,0xfb,0xf7,0xef};	//数码管位选码 */
  40          
  41          uchar code table_du[]={			//0-9的共阴极代码 	
  42          	0xc0,0xf9,0xa4,0xb0,0x99,
  43          	0x92,0x82,0xf8,0x80,0x90,0xbf	
  44          			};
  45          uchar data_dis[5]={0x00,0x00,0x00,0x00,0x00};
  46          uchar scan_con[]={0x01,0x02,0x04,0x08,0x10};
  47          //uchar scan_con[]={0xfe,0xfd,0xfb,0xf7,0xef};	//数码管位选码共阴极 
  48          
  49          void delay(uchar x)//正常显示用延时子函数和消除抖动用延时函数  
  50          {	
  51   1      	uchar i,j;
  52   1      	for(i=x;i>0;i--)
  53   1      		for(j=200;j>0;j--);
  54   1      }
  55          
C51 COMPILER V6.12  DZZ_THESAMEA                                                           05/06/2008 17:16:29 PAGE 2   

  56          void display_wait1()//等待时显示P 
  57          {
  58   1      	//P0=0xff;
  59   1      	P0=0x00;
  60   1      	choose_we=1;
  61   1      	choose_we=0;
  62   1      	//P0=0x73;	//display of P
  63   1      	P0=0x8c;
  64   1      	choose_du=1;
  65   1      	choose_du=0;
  66   1      	//P0=0xe4;	//1110 0100 最低位是最左边的数码管 
  67   1      	P0=0x1b;	
  68   1      	choose_we=1;
  69   1      	choose_we=0;
  70   1      	delay(3);
  71   1      	
  72   1      	//P0=0xff;
  73   1      	P0=0x00;
  74   1      	choose_we=1;
  75   1      	choose_we=0;
  76   1      	//P0=0x40;
  77   1      	P0=0xbf;
  78   1      	choose_du=1;
  79   1      	choose_du=0;
  80   1      	//P0=0xfb;	//1111 1011
  81   1      	P0=0x04;
  82   1      	choose_we=1;
  83   1      	choose_we=0;
  84   1      	delay(3);	
  85   1      }
  86          
  87          void display_wait2()//等待时不显示 
  88          {
  89   1      	//P0=0xff;
  90   1      	P0=0x00;
  91   1      	choose_we=1;
  92   1      	choose_we=0;
  93   1      	delay(3);		
  94   1      }
  95          
  96          void display_scan()//扫描的显示方式一定程度上减少了程序的长度  
  97          {							//显示函数 	
  98   1      	uchar k;
  99   1      	data_dis[0]=num_hours;
 100   1      	data_dis[1]=num_hourg;
 101   1      	data_dis[2]=10;
 102   1      	data_dis[3]=num_minis;
 103   1      	data_dis[4]=num_minig;
 104   1      	for(k=0;k<5;k++)
 105   1      	{		
 106   2      		//P0=0xff;
 107   2      		P0=0x00;
 108   2      		choose_we=1;
 109   2      		choose_we=0;
 110   2      		P0=table_du[data_dis[k]];
 111   2      		choose_du=1;
 112   2      		choose_du=0;
 113   2      		P0=scan_con[k];
 114   2      		choose_we=1;
 115   2      		choose_we=0;
 116   2      		delay(3);	
 117   2      	}
C51 COMPILER V6.12  DZZ_THESAMEA                                                           05/06/2008 17:16:29 PAGE 3   

 118   1      }
 119          void display_ss(uchar x)
 120          {
 121   1      	data_dis[0]=num_hours;
 122   1      	data_dis[1]=num_hourg;
 123   1      	data_dis[3]=num_minis;
 124   1      	data_dis[4]=num_minig;
 125   1      	
 126   1      	//P0=0xff;
 127   1      	P0=0x00;
 128   1      	choose_we=1;
 129   1      	choose_we=0;
 130   1      	P0=table_du[data_dis[x]];
 131   1      	choose_du=1;
 132   1      	choose_du=0;
 133   1      	P0=scan_con[x];
 134   1      	choose_we=1;
 135   1      	choose_we=0;
 136   1      	delay(3);	
 137   1      }
 138          
 139          void displayclock(uchar hours,uchar hourg,uchar minis,uchar minig)
 140          {										//设置时钟时的动态显示函数 	
 141   1      		
 142   1      	//P0=0xff;
 143   1      	P0=0x00;
 144   1      	choose_we=1;
 145   1      	choose_we=0;
 146   1      	P0=table_du[hours];
 147   1      	choose_du=1;
 148   1      	choose_du=0;
 149   1      	//P0=0xfe;
 150   1      	P0=0x01;
 151   1      	choose_we=1;
 152   1      	choose_we=0;
 153   1      	delay(3);
 154   1      
 155   1      	//P0=0xff;
 156   1      	P0=0x00;
 157   1      	choose_we=1;
 158   1      	choose_we=0;
 159   1      	P0=table_du[hourg];
 160   1      	choose_du=1;
 161   1      	choose_du=0;
 162   1      	//P0=0xfd;
 163   1      	P0=0x02;
 164   1      	choose_we=1;
 165   1      	choose_we=0;
 166   1      	delay(3);
 167   1      	
 168   1      	//P0=0xff;
 169   1      	P0=0x00;
 170   1      	choose_we=1;
 171   1      	choose_we=0;
 172   1      	//P0=0x40;
 173   1      	P0=0xbf;
 174   1      	choose_du=1;
 175   1      	choose_du=0;
 176   1      	//P0=0xfb;
 177   1      	P0=0x04;
 178   1      	choose_we=1;
 179   1      	choose_we=0;
C51 COMPILER V6.12  DZZ_THESAMEA                                                           05/06/2008 17:16:29 PAGE 4   

 180   1      	delay(3);
 181   1      	
 182   1      	//P0=0xff;
 183   1      	P0=0x00;
 184   1      	choose_we=1;
 185   1      	choose_we=0;
 186   1      	P0=table_du[minis];
 187   1      	choose_du=1;
 188   1      	choose_du=0;
 189   1      	//P0=0xf7;
 190   1      	P0=0x08;
 191   1      	choose_we=1;
 192   1      	choose_we=0;
 193   1      	delay(3);
 194   1      	
 195   1      	//P0=0xff;
 196   1      	P0=0x00;
 197   1      	choose_we=1;
 198   1      	choose_we=0;
 199   1      	P0=table_du[minig];
 200   1      	choose_du=1;
 201   1      	choose_du=0;
 202   1      	//P0=0xef;
 203   1      	P0=0x10;
 204   1      	choose_we=1;
 205   1      	choose_we=0;
 206   1      	delay(3);					
 207   1      }
 208          
 209          void statedisplay(uchar du,uchar we)	//设置时钟时的静态显示函数 
 210          {
 211   1      	P0=table_du[du];
 212   1      	choose_du=1;
 213   1      	choose_du=0;
 214   1      	P0=we;
 215   1      	choose_we=1;
 216   1      	choose_we=0;			
 217   1      }
 218          
 219          void settime_minig()                //可不可以用一个循环的方式呢? 
 220          {							//分个位调整函数 
 221   1      	uchar umost=16;
 222   1      	while(1)
 223   1      	{
 224   2      		umost--;
 225   2      		for(i=0;i<185;i++)
 226   2      		{
 227   3      			display_ss(4);
 228   3      		}
 229   2      		for(i=0;i<185;i++)
 230   2      		{	
 231   3      			display_wait2();
 232   3      		}
 233   2      		if(s3==0)
 234   2      		{
 235   3      			delay(10);
 236   3      			if(s3==0)
 237   3      			{
 238   4      				num_minig++;
 239   4      				if(num_minig==10)
 240   4      					num_minig=0;
 241   4      			}
C51 COMPILER V6.12  DZZ_THESAMEA                                                           05/06/2008 17:16:29 PAGE 5   

 242   3      			while(!s3);
 243   3      			umost=16;
 244   3      		}	
 245   2      		if(s2==0)
 246   2      		{
 247   3      			delay(10);
 248   3      			if(s2==0)
 249   3      				yes=1;	
 250   3      		}	
 251   2      		while(!s2);
 252   2      		if((umost==0)|yes)
 253   2      		{
 254   3      			yes=0;
 255   3      			break;
 256   3      		}			
 257   2      	}
 258   1      }
 259          
 260          void settime_minis()	//分十位时间调整函数  
 261          {
 262   1      	uchar umost=16;
 263   1      	while(1)
 264   1      	{
 265   2      		umost--;
 266   2      		for(i=0;i<185;i++)
 267   2      		{	
 268   3      			display_ss(3);
 269   3      		}
 270   2      		for(i=0;i<185;i++)
 271   2      		{
 272   3      			display_wait2();
 273   3      		}
 274   2      		if(s3==0)
 275   2      		{
 276   3      			delay(10);
 277   3      			if(s3==0)
 278   3      			{
 279   4      				num_minis++;
 280   4      				if(num_minis==6)
 281   4      					num_minis=0;
 282   4      			}
 283   3      			while(!s3);
 284   3      			umost=16;
 285   3      		}	
 286   2      		if(s2==0)
 287   2      		{
 288   3      			delay(10);
 289   3      			if(s2==0)
 290   3      				yes=1;	
 291   3      		}	
 292   2      		while(!s2);
 293   2      		if((umost==0)|yes)
 294   2      		{
 295   3      			yes=0;
 296   3      			break;
 297   3      		}			
 298   2      	}
 299   1      }
 300          
 301          void settime_hourg()		//小时个位时间调整函数  
 302          {
 303   1      	uchar umost=16;
C51 COMPILER V6.12  DZZ_THESAMEA                                                           05/06/2008 17:16:29 PAGE 6   

 304   1      	while(1)
 305   1      	{
 306   2      		umost--;
 307   2      		for(i=0;i<185;i++)
 308   2      		{
 309   3      			display_ss(1);
 310   3      		}
 311   2      		for(i=0;i<185;i++)
 312   2      		{
 313   3      			display_wait2();
 314   3      		}
 315   2      		if(s3==0)
 316   2      		{
 317   3      			delay(10);
 318   3      			if(s3==0)
 319   3      			{
 320   4      				num_hourg++;
 321   4      				if(num_hourg==10)
 322   4      					num_hourg=0;
 323   4      			}
 324   3      			while(!s3);
 325   3      			umost=16;
 326   3      		}	
 327   2      		if(s2==0)
 328   2      		{
 329   3      			delay(10);
 330   3      			if(s2==0)
 331   3      				yes=1;	
 332   3      		}	
 333   2      		while(!s2);
 334   2      		if((umost==0)|yes)
 335   2      		{
 336   3      			yes=0;
 337   3      			break;
 338   3      		}			
 339   2      	}
 340   1      }
 341          
 342          void settime_hours()		//小时十位时间调整函数  
 343          {
 344   1      	uchar umost=16;
 345   1      	while(1)
 346   1      	{
 347   2      		umost--;
 348   2      		for(i=0;i<185;i++)
 349   2      		{
 350   3      			display_ss(0);
 351   3      		}
 352   2      		for(i=0;i<185;i++)
 353   2      		{
 354   3      			display_wait2();
 355   3      		}
 356   2      		if(s3==0)
 357   2      		{
 358   3      			delay(10);
 359   3      			if(s3==0)
 360   3      			{

⌨️ 快捷键说明

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