📄 jcsa92-01.lst
字号:
C51 COMPILER V7.09 JCSA92_01 07/27/2007 16:54:47 PAGE 1
C51 COMPILER V7.09, COMPILATION OF MODULE JCSA92_01
OBJECT MODULE PLACED IN JCSa92-01.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE JCSa92-01.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include <reg52.h>
2 #include <INTRINS.H>
3 sbit SDA=P3^0;
4 sbit SCL=P3^1;
5 sbit GO=P3^3;
6
7 void DelayXms(unsigned int i);
8 void I2CStart();
9 void I2CStop();
10 void I2CSent(unsigned char Data);
11 void Display(unsigned char d);
12 void Wait();
13
14 void DelayXms(unsigned int i)
15 {
16 1 unsigned char a;
17 1 unsigned int b;
18 1 for(b=0;b<i;b++)
19 1 for(a=0;a<255;a++);
20 1 }
21
22 void I2CStart( void )
23 {
24 1 SDA=1;
25 1 _nop_();
26 1 _nop_();
27 1 _nop_();
28 1 SCL=1;
29 1 _nop_();
30 1 _nop_();
31 1 _nop_();
32 1 SDA=0;
33 1 _nop_();
34 1 _nop_();
35 1 _nop_();
36 1 SCL=0;
37 1 }
38
39 void I2CStop( void )
40 {
41 1 SDA=0;
42 1 _nop_();
43 1 _nop_();
44 1 _nop_();
45 1 SCL=1;
46 1 _nop_();
47 1 _nop_();
48 1 _nop_();
49 1 SDA=1;
50 1 _nop_();
51 1 _nop_();
52 1 _nop_();
53 1 SCL=0;
54 1 }
55
C51 COMPILER V7.09 JCSA92_01 07/27/2007 16:54:47 PAGE 2
56 void I2CSent(unsigned char Data)
57 {
58 1 unsigned char i,d;
59 1 bit ack;
60 1 SDA=1;
61 1 Resent:
62 1 d=Data;
63 1 for(i=0;i<8;i++)
64 1 {
65 2 if(d&0x80)
66 2 SDA=1;
67 2 else
68 2 SDA=0;
69 2 d<<=1;
70 2 _nop_();
71 2 _nop_();
72 2 _nop_();
73 2 SCL=1;
74 2 _nop_();
75 2 _nop_();
76 2 _nop_();
77 2 SCL=0;
78 2 _nop_();
79 2 _nop_();
80 2 _nop_();
81 2 }
82 1 _nop_();
83 1 _nop_();
84 1 _nop_();
85 1 SDA=1;
86 1 _nop_();
87 1 _nop_();
88 1 _nop_();
89 1 SCL=1;
90 1 _nop_();
91 1 _nop_();
92 1 _nop_();
93 1 ack=SDA;
94 1 SCL=0;
95 1 _nop_();
96 1 _nop_();
97 1 _nop_();
98 1 if(ack==1)goto Resent;
99 1 }
100
101
102
103 void Wait()
104 {
105 1 while(1)
106 1 {
107 2 if(GO==0)
108 2 {
109 3 DelayXms(250);
110 3 return;
111 3 }
112 2 }
113 1 }
114
115 void Display(unsigned char d)
116 {
117 1 unsigned char i;
C51 COMPILER V7.09 JCSA92_01 07/27/2007 16:54:47 PAGE 3
118 1 I2CStart();
119 1 I2CSent(0x70);
120 1 I2CSent(0xe0); //Device select A0=A1=A2=0
121 1 I2CSent(0xc8); //Mode set
122 1 I2CSent(0x00);
123 1 for(i=0;i<16;i++)
124 1 {
125 2 I2CSent(d);
126 2 }
127 1 I2CStop();
128 1 }
129 void Display1()
130 {
131 1 unsigned char i=0;
132 1 for(i=0;i<32;i++)
133 1 {
134 2 Display(0x00);
135 2 I2CStart();
136 2 I2CSent(0x70);
137 2 I2CSent(0xe0); //Device select A0=A1=A2=0
138 2 I2CSent(0xc8); //Mode set
139 2 I2CSent(i);
140 2 I2CSent(0xf0);
141 2 I2CStop();
142 2 Wait();
143 2 }
144 1 }
145
146
147
148 void main(void)
149 {
150 1 while(1)
151 1 {
152 2 Display(0xff);
153 2 Wait();
154 2 Display(0x00);
155 2 Wait();
156 2 Display1();
157 2 Display(0x55);
158 2 Wait();
159 2 Display(0xaa);
160 2 Wait();
161 2 Display(0x99);
162 2 Wait();
163 2 Display(0x5a);
164 2 Wait();
165 2 Display(0xa5);
166 2 Wait();
167 2 }
168 1 }
169
170
171
172
173
174
175
176
177
178
179
C51 COMPILER V7.09 JCSA92_01 07/27/2007 16:54:47 PAGE 4
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
C51 COMPILER V7.09 JCSA92_01 07/27/2007 16:54:47 PAGE 5
242
243
244
245
246
247
248
249
250
251
252
253
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 280 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- 1
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -