standardtimeext.lst
来自「含有大量的单片机代码」· LST 代码 · 共 189 行
LST
189 行
C51 COMPILER V7.06 STANDARDTIMEEXT 11/29/2006 20:43:55 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE STANDARDTIMEEXT
OBJECT MODULE PLACED IN StandardTimeExt.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE StandardTimeExt.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 //QQ群:33495724 单片机 ARM FPGA 团队全力打造技术联盟
2 //实验课题:标准时间
3 //编写人:lc
4 //时间:2006.11.25.
5
6 #include<reg51.h>
7 #define uchar unsigned char
8 #define uint unsigned int
9 sfr p0=0x80;//初始化
10 sfr p1=0x90;
11 sfr p2=0xA0;
12 unsigned char code tab[10]={0xfc/*0*/,0x60/*1*/,0xda/*2*/,0xf2/*3*/,0x66/*4*/,
13 0xb6/*5*/,0xbe/*6*/,0xe0/*7*/,0xfe/*8*/,0xf6/*9*/};//段码查表
14
15 uint addi=0; //标示相对50mS的20次中断是否到达,到达就是一秒;
16 uchar hour=23;//时间初始化,其为全局变量!
17 uchar minute=59;
18 uchar second=50;
19 uchar templow,temphigh;//取十位,取个位
20 uchar displaylow(uchar middlenum1);//函数声明
21 uchar displayhigh(uchar middlenum2);
22 void delay(uint num);
23 void fun_frabrication();
24 void keycheck();
25
26 void t0_show() interrupt 1 using 0//TO中断
27 {
28 1 TH0=(65536-50000)/256;//产生一次中断,重新配置定时器预置值
29 1 TL0=(65536-50000)%256;
30 1 addi++;
31 1 if(addi==20){second+=1;addi=0;}
32 1 }
33
34
35 void displaysecond(uchar p_second)//秒显
36 {
37 1 if(p_second<60||p_second==00)
38 1 {
39 2 p1=0x20;p0=displaylow(p_second);delay(1);p1=0x00;
40 2 p0=displayhigh(p_second);p1=0x10;delay(1);p1=0x00;
41 2 }
42 1 else
43 1 {
44 2 p_second=00;
45 2 second=00;
46 2 p1=0x20;p0=displaylow(p_second);delay(1);p1=0x00;
47 2 p0=displayhigh(p_second);p1=0x10;delay(1);p1=0x00;
48 2 minute+=1;
49 2 }
50 1 }
51
52
53 void displayminute(uchar p_minute)//分显
54 {
55 1 if(p_minute<60||p_minute==00)
C51 COMPILER V7.06 STANDARDTIMEEXT 11/29/2006 20:43:55 PAGE 2
56 1 {
57 2 p1=0x08;p0=displaylow(p_minute);delay(1);p1=0x00;
58 2 p0=displayhigh(p_minute);p1=0x04;delay(1);p1=0x00;
59 2 }
60 1 else
61 1 {
62 2 p_minute=00;
63 2 minute=00;
64 2 p1=0x08;p0=displaylow(p_minute);delay(1);p1=0x00;
65 2 p0=displayhigh(p_minute);p1=0x04;delay(1);p1=0x00;
66 2 hour+=1;
67 2 }
68 1 }
69
70
71 void displayhour(uchar p_hour)//时显
72 {
73 1 if(p_hour<24||p_hour==00)
74 1 {
75 2 p1=0x02;p0=displaylow(p_hour);delay(1);p1=0x00;
76 2 p0=displayhigh(p_hour);p1=0x01;delay(1);p1=0x00;
77 2 }
78 1 else
79 1 {
80 2 p_hour=00;
81 2 hour=00;
82 2 p1=0x02;p0=displaylow(p_hour);delay(1);p1=0x00;
83 2 p0=displayhigh(p_hour);p1=0x01;delay(1);p1=0x00;
84 2 }
85 1 }
86
87 uchar displaylow(uchar middlenum1)//显十位通用包
88 {
89 1 templow=tab[middlenum1%10];
90 1 return(templow);
91 1 }
92
93
94 uchar displayhigh(uchar middlenum2) //显示个位通用包
95 {
96 1 temphigh=tab[middlenum2/10];
97 1 return(temphigh);
98 1 }
99
100
101 void delay(uint num)//函数延迟程序包,可以通用;
102 {
103 1 uint i,j;
104 1 for(i=num;i>0;i--)
105 1 for(j=0;j<200;j++);
106 1 }
107
108
109 void fun_frabrication()//显示函数封装包,可以用在很多其他的时钟设计当中;
110 {
111 1 displaysecond(second);
112 1 displayminute(minute);
113 1 displayhour(hour);
114 1 }
115
116
117 void main()
C51 COMPILER V7.06 STANDARDTIMEEXT 11/29/2006 20:43:55 PAGE 3
118 {
119 1 uchar p2change;
120 1 TMOD=0X01;
121 1 TH0=(65536-50000)/256;
122 1 TL0=(65536-50000)%256;
123 1 IE=0X82;
124 1 TR0=1;
125 1 while(1)
126 1 {
127 2 fun_frabrication();//将该显示信号放里面就不会刷动了
128 2 p2change=p2;
129 2 if((p2change&0x04)==0)keycheck();
130 2 else continue;
131 2 }
132 1 }
133
134 void keycheck()
135 {
136 1 uchar p2_change;
137 1 p2_change=p2;
138 1 while((p2_change&0x04)==0)
139 1 {
140 2 fun_frabrication();
141 2 if((p2_change&0x01)==0)
142 2 {
143 3 delay(3);//延时去抖;
144 3 if((p2_change&0x01)==0)hour+=1;
145 3 while((p2_change&0x01)==0)
146 3 {
147 4 p2_change=p2;
148 4 fun_frabrication();
149 4 if((p2_change&0x01)==1)break;}
150 3 }
151 2 if((p2_change&0x02)==0)
152 2 { delay(3);//延时去抖
153 3 if((p2_change&0x02)==0)minute+=1;
154 3 while((p2_change&0x02)==0)
155 3 {p2_change=p2;
156 4 fun_frabrication();
157 4 if((p2_change&0x02)==0x02)break;}
158 3 }
159 2 p2_change=p2;
160 2 }
161 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 440 ----
CONSTANT SIZE = 10 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 7 4
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?