📄 1602.lst
字号:
C51 COMPILER V7.06 1602 03/09/2009 10:43:07 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE 1602
OBJECT MODULE PLACED IN 1602.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE 1602.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include<reg52.h>
2 #define uchar unsigned char
3 #define uint unsigned int
4
5 sbit lcdrs=P1^2;
6 sbit lcdrw=P1^3;
7 sbit lcden=P1^4;
8 sbit shezhi=P3^5;
9 sbit add=P3^6;
10 sbit dec=P3^7;
11
12 uchar count,shezhinum;
13 char miao,shi,fen;
14 uchar code table[]=" wang shu mao ";
15 uchar code table1[]=" 12-00-00 ";
16 void delay(uchar z)
17 {
18 1 uchar x,y;
19 1 for(x=0;x<z;x++)
20 1 for(y=0;y<110;y++);
21 1 }
22
23 void write_com(uchar com)
24 {
25 1 lcdrs=0;
26 1 lcden=0;
27 1 P0=com;
28 1 delay(5);
29 1 lcden=1;
30 1 delay(5);
31 1 lcden=0;
32 1 }
33
34 void write_dat(uchar dat)
35 {
36 1 lcdrs=1;
37 1 lcden=0;
38 1 P0=dat;
39 1 delay(5);
40 1 lcden=1;
41 1 delay(5);
42 1 lcden=0;
43 1 }
44
45 void init()
46 {
47 1 uchar i;
48 1 lcden=0;
49 1 lcdrw=0;
50 1 write_com(0x38);
51 1 write_com(0x0c);
52 1 write_com(0x06);
53 1 write_com(0x01);
54 1 write_com(0x80);
55 1 for(i=0;i<15;i++)
C51 COMPILER V7.06 1602 03/09/2009 10:43:07 PAGE 2
56 1 {
57 2 write_dat(table[i]);
58 2 delay(5);
59 2 }
60 1 write_com(0x80+0x40);
61 1 for(i=0;i<12;i++)
62 1 {
63 2 write_dat(table1[i]);
64 2 delay(5);
65 2 }
66 1 TMOD=0x01;
67 1 TH0=0xdc;
68 1 TL0=0x00;
69 1 EA=1;
70 1 ET0=1;
71 1 TR0=1;
72 1 }
73
74 void write_sfm(uchar add,uchar dat)
75 {
76 1 uchar shi,ge;
77 1 shi=dat/10;
78 1 ge=dat%10;
79 1 write_com(0x80+0x40+add);
80 1 write_dat(0x30+shi);
81 1 write_dat(0x30+ge);
82 1 }
83
84 void keyscan()
85 {
86 1 if(shezhi==0)
87 1 {
88 2 delay(5);
89 2 if(shezhi==0)
90 2 {
91 3 shezhinum++;
92 3 while(!shezhi);
93 3 if(shezhinum==1)
94 3 {
95 4 TR0=0;
96 4 write_com(0x80+0x40+10);
97 4 write_com(0x0f);
98 4 }
99 3 }
100 2 if(shezhinum==2)
101 2 {
102 3 write_com(0x80+0x40+7);
103 3 }
104 2 if(shezhinum==3)
105 2 {
106 3 write_com(0x80+0x40+4);
107 3 }
108 2 if(shezhinum==4)
109 2 {
110 3 shezhinum=0;
111 3 write_com(0x0c);
112 3 TR0=1;
113 3 }
114 2
115 2
116 2 }
117 1 if(shezhinum!=0)
C51 COMPILER V7.06 1602 03/09/2009 10:43:07 PAGE 3
118 1 {
119 2 if(add==0)
120 2 {
121 3 delay(5);
122 3 if(add==0)
123 3 {
124 4 while(!add);
125 4 if(shezhinum==1)
126 4 {
127 5 miao++;
128 5 if(miao==60)
129 5 miao=0;
130 5 write_sfm(10,miao);
131 5 write_com(0x80+0x40+10);
132 5
133 5
134 5 }
135 4 if(shezhinum==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(shezhinum==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);
150 5 }
151 4 }
152 3 }
153 2 if(dec==0)
154 2 {
155 3 delay(5);
156 3 if(dec==0)
157 3 {
158 4 while(!dec);
159 4 if(shezhinum==1)
160 4 {
161 5 miao--;
162 5 if(miao==-1)
163 5 miao=59;
164 5 write_sfm(10,miao);
165 5 write_com(0x80+0x40+10);
166 5 }
167 4 if(shezhinum==2)
168 4 {
169 5 fen--;
170 5 if(fen==-1)
171 5 fen=59;
172 5 write_sfm(7,fen);
173 5 write_com(0x80+0x40+7);
174 5 }
175 4 if(shezhinum==3)
176 4 {
177 5 shi--;
178 5 if(shi==-1)
179 5 shi=23;
C51 COMPILER V7.06 1602 03/09/2009 10:43:07 PAGE 4
180 5 write_sfm(4,shi);
181 5 write_com(0x80+0x40+4);
182 5 }
183 4 }
184 3 }
185 2 }
186 1 }
187 void main()
188 {
189 1 init();
190 1 SCON=0XFF;
191 1 while(1)
192 1 {
193 2 keyscan();
194 2 }
195 1 }
196
197 void timer0() interrupt 1
198 {
199 1 TH0=0xdc;
200 1 count++;
201 1 if(count==100)
202 1 {
203 2 count=0;
204 2 miao++;
205 2 write_sfm(10,miao);
206 2 if(miao==60)
207 2 {
208 3 miao=0;
209 3 fen++;
210 3 write_sfm(7,fen);
211 3 if(fen==60)
212 3 {
213 4 fen=0;
214 4 shi++;
215 4 write_sfm(4,shi);
216 4 if(shi==24)
217 4 {
218 5 shi=0;
219 5 }
220 4 }
221 3 }
222 2
223 2 }
224 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 528 ----
CONSTANT SIZE = 34 ----
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 + -