📄 shuzizhong.lst
字号:
C51 COMPILER V7.06 SHUZIZHONG 11/11/2011 22:43:03 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE SHUZIZHONG
OBJECT MODULE PLACED IN shuzizhong.OBJ
COMPILER INVOKED BY: E:\KEIL\C51\BIN\C51.EXE shuzizhong.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include<reg52.h>
2 #define uchar unsigned char
3 #define uint unsigned int
4 uchar count,s1num;
5 char miao,shi,fen;
6 sbit s1=P3^1;
7 sbit s2=P3^2;
8 sbit s3=P3^3;
9 sbit rd=P3^7;
10 sbit lcden=P2^7;
11 sbit lcdrs=P2^6;
12 sbit lcdrw=P2^5;//液晶
13
14 uchar code table[]=" 2007-7-30 MON";
15 uchar code table1[]=" 00:00:00";
16 void delay(uint z)
17 {
18 1 uint x,y;
19 1 for(x=z;x>0;x--)
20 1 for(y=110;y>0;y--);
21 1 }
22
23 void write_com(uchar com)
24 {
25 1 lcdrs=0;//写指令
26 1 P0=com;
27 1 delay(5);
28 1 lcden=1;
29 1 delay(5);
30 1 lcden=0;//以上都是根据指令表写出
31 1 }
32 void write_data(uchar date)//写数据
33 {
34 1 lcdrs=1;//写数据
35 1 P0=date;
36 1 delay(5);
37 1 lcden=1;
38 1 delay(5);
39 1 lcden=0;//以上都是根据指令表写出
40 1 }
41
42 void init()
43 {
44 1 uchar num;
45 1 lcdrw=0;//写入为0
46 1 lcden=0;
47 1 write_com(0x38);//开显示
48 1 write_com(0x0c);//不显示光标
49 1 write_com(0x06);
50 1 write_com(0x01);//清屏
51 1
52 1
53 1 write_com(0x80);
54 1 for(num=0;num<15;num++)
55 1 {
C51 COMPILER V7.06 SHUZIZHONG 11/11/2011 22:43:03 PAGE 2
56 2 write_data(table[num]);
57 2 delay(5);
58 2 }
59 1
60 1 write_com(0x80+0x40);
61 1 for(num=0;num<12;num++)
62 1 {
63 2 write_data(table1[num]);
64 2 delay(5);
65 2 }
66 1
67 1 TMOD=0x01;//定时器0的方式1
68 1 TH0=(65536-50000)/256;
69 1 TL0=(65536-50000)%256;//初值
70 1 EA=1;
71 1 ET0=1;
72 1 TR0=1;//启动定时器
73 1
74 1 }
75
76 void write_sfm(uchar add,uchar date)
77 {
78 1 uchar shi,ge;
79 1 shi=date/10;
80 1 ge=date%10;//秒的
81 1 write_com(0x80+0x40+add);
82 1 write_data(0x30+shi);
83 1 write_data(0x30+ge);
84 1 }
85 void keyscan()//判定功能键是否按下
86
87 {
88 1 rd=0; //行列键盘当独立键盘使用
89 1 if(s1==0)//功能键按下
90 1 {
91 2 delay(5);
92 2 if(s1==0)//确认按下
93 2 {
94 3 s1num++;
95 3 while(!s1);
96 3 if(s1num==1)
97 3 {
98 4 TR0=0;//时间停止
99 4 write_com(0x80+0x40+10);
100 4 write_com(0x0f);//光标闪烁秒的位置
101 4 }
102 3 if(s1num==2)
103 3 {
104 4 write_com(0x80+0x40+7);//分钟的位置
105 4 }
106 3 if(s1num==3)
107 3 {
108 4 write_com(0x80+0x40+4);
109 4 }
110 3 if(s1num==4)
111 3 {
112 4 s1num=0;
113 4 write_com(0x0c);//光标不再闪烁
114 4 TR0=1;//开定时器开始走
115 4 }
116 3 }
117 2
C51 COMPILER V7.06 SHUZIZHONG 11/11/2011 22:43:03 PAGE 3
118 2 }
119 1 if(s1num!=0)//在s1按下后判断s2调节加时间
120 1 {
121 2 if(s2==0)
122 2 {
123 3 delay(5);//延时去抖动
124 3 if(s2==0)
125 3 {
126 4 while(!s2);//等待松手
127 4 if(s1num==1)//光标在秒处
128 4 {
129 5 miao++;
130 5 if(miao==60)
131 5 miao=0;
132 5 write_sfm(10,miao);
133 5 write_com(0x80+0x40+10); //数据指针到秒处
134 5 }
135 4 if(s1num==2)//光标在分处
136 4 {
137 5 fen++;
138 5 if(fen==60)
139 5 fen=0;
140 5 write_sfm(7,fen);
141 5 write_com(0x80+0x40+7); //数据指针到分处
142 5 }
143 4 if(s1num==3)//光标在时处
144 4 {
145 5 shi++;
146 5 if(shi==24)
147 5 shi=0;
148 5 write_sfm(4,shi);
149 5 write_com(0x80+0x40+4); //数据指针到shichu
150 5 }
151 4 }
152 3 }
153 2 if(s3==0)//按s3减
154 2 {
155 3 while(!s3);
156 3 if(s1num==1)
157 3 {
158 4 miao--;
159 4 if(miao==-1)
160 4 miao=59;
161 4 write_sfm(10,miao);
162 4 write_com(0x80+0x40+10);
163 4
164 4 }
165 3 if(s1num==2)
166 3 {
167 4 fen--;
168 4 if(fen==-1)
169 4 fen=59;
170 4 write_sfm(7,fen);
171 4 write_com(0x80+0x40+7);
172 4
173 4 }
174 3 if(s1num==3)
175 3 {
176 4 shi--;
177 4 if(shi==-1)
178 4 shi=23;
179 4 write_sfm(4,shi);
C51 COMPILER V7.06 SHUZIZHONG 11/11/2011 22:43:03 PAGE 4
180 4 write_com(0x80+0x40+4);
181 4
182 4 }
183 3 }
184 2 }
185 1 }
186 void main()
187 {
188 1 init();
189 1 while(1)
190 1 {
191 2 keyscan();
192 2 if(count==20)//20ms
193 2 {
194 3 count=0;//清零
195 3 miao++;
196 3 if(miao==60)
197 3 {
198 4 miao=0;
199 4 fen++;
200 4 if(fen==60)
201 4 {
202 5 fen=0;
203 5 shi++;
204 5 if(shi==24)
205 5 {
206 6 shi=0;
207 6
208 6 }
209 5 write_sfm(4,shi);
210 5 }
211 4 write_sfm(7,fen);
212 4 }
213 3 write_sfm(10,miao);
214 3 }
215 2 }
216 1
217 1 }
218
219 void tiner0() interrupt 1
220 {
221 1 TH0=(65536-50000)/256;
222 1 TL0=(65536-50000)%256;//初值
223 1 count++;
224 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 496 ----
CONSTANT SIZE = 29 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 5 ----
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -