?? clock-1620.lst
字號(hào):
C51 COMPILER V6.12 CLOCK_1620 11/25/2008 15:53:04 PAGE 1
C51 COMPILER V6.12, COMPILATION OF MODULE CLOCK_1620
OBJECT MODULE PLACED IN .\clock-1620.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE .\clock-1620.c DEBUG OBJECTEXTEND
stmt level source
1 #include"reg51.h"
2 #define uchar unsigned char
3 #define uint unsigned int
4
5
6 sbit rs=P3^0;
7 sbit rw=P3^1;
8 sbit e=P3^2;
9 sbit ds=P1;
10 sbit button=P2^0;
11 sbit bf=P1^7;
12
13 uint ms=0;
14 uint second=0;
15 uint min=0;
16 uint hr=0;
17
18
19
20 uchar code tab[]={"***FM1602A--3***"};
21 uchar code tab1[]={0x0f,0x09,0x0f,0x09,0x0f,0x09,0x0b,0x11,
22 0x1F,0x11,0x11,0x11,0x1F,0x11,0x11,0x1F}; // 月日
23 uchar code number[]={"0123456789"};
24
25 uchar code inti0[]={"11 25 00:00:00"};
26
27
28
29 void nop(){}
30
31 void delay(uint q) //延時(shí)
32 {uchar n;
33 1 while(q--)
34 1 {for(n=0;n<24;n++){;;}}
35 1 }
36
37
38
39 void check() // 判忙
40 {rs=0;
41 1 rw=1;
42 1 e=0;
43 1 P1=0xff;
44 1 e=1;
45 1 nop();
46 1 nop();
47 1 while(P&0x80){};
48 1 delay(10);
49 1 }
50
51 void sendc(uchar com) // 發(fā)命令字
52 {check();
53 1
54 1
55 1 rs=0;
C51 COMPILER V6.12 CLOCK_1620 11/25/2008 15:53:04 PAGE 2
56 1 rw=0;
57 1 e=1;
58 1 P1=com;
59 1
60 1 nop();
61 1 e=0;
62 1 nop();
63 1 }
64
65 void sendd(uchar word) // 發(fā)顯示字
66 {check();
67 1
68 1
69 1 rs=1;
70 1 rw=0;
71 1 e=1;
72 1 P1=word;
73 1 nop();
74 1 e=0;
75 1 nop();
76 1 }
77
78 void inti() // 初始化
79 {uchar d;
80 1 sendc(0x01);
81 1 sendc(0x38);
82 1 sendc(0x0c);
83 1 sendc(0x06);
84 1 delay(10);
85 1
86 1 sendc(0x80);
87 1 for(d=0;d<16;d++)
88 1 {sendd(*(inti0+d));};
89 1 sendc(0x82);
90 1 sendd(0x00);
91 1 sendc(0x85);
92 1 sendd(0x01);
93 1 sendc(0xc0);
94 1 for(d=0;d<16;d++)
95 1 {sendd(*(tab+d));};
96 1 }
97
98 void cpuinti()
99 {
100 1 TMOD=0x01;
101 1 TH0=0x3c;
102 1 TL0=0xb0;
103 1 TR0=1;
104 1 EA=1;
105 1 ET0=1;
106 1 }
107
108
109
110 void keyboard()
111 {}
112
113
114 void displayhr() //////顯示小時(shí)
115 {uchar ho,ht;
116 1 if(hr>9)
117 1 {
C51 COMPILER V6.12 CLOCK_1620 11/25/2008 15:53:04 PAGE 3
118 2 ht=hr/10;
119 2 ho=hr%10;}
120 1 else{ht=0;ho=hr;};
121 1
122 1 sendc(0x88);
123 1 sendd(*(number+ht));
124 1 sendc(0x89);
125 1 sendd(*(number+ho));
126 1 while(hr==24)
127 1 {hr=0;
128 2 //day++;
129 2 //displayhr();
130 2 };
131 1 }
132
133
134
135 void displaymin() ///////////顯示 分
136 {uchar mo,mt;
137 1 if(min>9)
138 1 {
139 2 mt=min/10;
140 2 mo=min%10;}
141 1 else{mt=0;mo=min;};
142 1
143 1 sendc(0x8b);
144 1 sendd(*(number+mt));
145 1 sendc(0x8c);
146 1 sendd(*(number+mo));
147 1 while(min==60)
148 1 {min=0;
149 2 hr++;
150 2 displayhr();};
151 1 }
152
153
154
155 void displaysec() /////////////顯示 秒
156 {uchar o,t;
157 1 if(second>9)
158 1 {
159 2 t=second/10;
160 2 o=second%10;}
161 1 else{t=0;o=second;};
162 1
163 1 sendc(0x8e);
164 1 sendd(*(number+t));
165 1 sendc(0x8f);
166 1 sendd(*(number+o));
167 1 while(second==60)
168 1 {second=0;
169 2 min++;
170 2 displaymin();};
171 1 }
172
173
174
175
176 void timer() interrupt 1 ///////////中斷入口
177 {
178 1 ms++;
179 1
C51 COMPILER V6.12 CLOCK_1620 11/25/2008 15:53:04 PAGE 4
180 1 displaysec();
181 1 while(ms==14){TH0=0x3c;TL0=0xb0;
182 2 ms=0;
183 2 second++;}
184 1 }
185
186
187 void setcgram()
188 {uchar x;
189 1 sendc(0x40);
190 1 for(x=0;x<16;x++)
191 1 {sendd(*(tab1+x));}
192 1 }
193
194
195
196
197
198
199 void main()
200 {setcgram();
201 1 inti();
202 1 cpuinti();
203 1
204 1 while(1){};
205 1
206 1 }
207
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 584 ----
CONSTANT SIZE = 61 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 8 5
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -