📄 24c02bak.lst
字号:
C51 COMPILER V6.23a 24C02BAK 11/06/2005 16:32:12 PAGE 1
C51 COMPILER V6.23a, COMPILATION OF MODULE 24C02BAK
OBJECT MODULE PLACED IN 24C02bak.OBJ
COMPILER INVOKED BY: D:\Program Files\KeilC51Full\C51\BIN\C51.EXE 24C02bak.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1
2
3 #include<At89X51.h>
4 #include <intrins.h>
5 #include <stdio.h>
6
7 sbit SDA = 0xB0^5; //P3_5 connect the SDA footprint
8 sbit SCL = 0xB0^4; //P3_4 connect the CLK footprint
9
10
11 unsigned short i = 0;
12 char nReceive[32];
13 char nStore[] = "HateMath is an excellent boy.\0";
14 unsigned char nAdress = 0x10;
15
16
17 /**************************** OWNER-DEFINED FUNC*****************************************/
18
19 //delay some time
20 void Delay()
21 {
22 1 _nop_();
23 1 _nop_();
24 1
25 1 }
26
27 // get ACK signal from 24c02
28 bit GetACK()
29 {
30 1 bit bACK = 1;
31 1
32 1 SDA = 1;
33 1 Delay();
34 1 SCL = 1;
35 1 Delay();
36 1 bACK = SDA;
37 1 SCL = 0;
38 1
39 1 return bACK;
40 1 }
41
42 //tell 24c02 to stop
43 void Stop()
44 {
45 1 SDA = 0;
46 1 Delay();
47 1 SCL = 1;
48 1 Delay();
49 1 SDA = 1;
50 1 Delay();
51 1
52 1 }
53 //tell 24c02 to start
54 void Start()
55 {
C51 COMPILER V6.23a 24C02BAK 11/06/2005 16:32:12 PAGE 2
56 1 SDA = 1;
57 1 SCL = 1;
58 1 Delay();
59 1 SDA = 0;
60 1 Delay();
61 1 SCL = 0; //钳住I2C总线准备发送或接受数据
62 1 // Delay();
63 1 }
64
65
66
67 //write one byte from 24c02
68 void WriteByte(char nData)
69 {
70 1 //1.the size of data is 8 by default
71 1
72 1 //2.test each bit of nData,then write into EEPROM
73 1 bit bEach;
74 1 unsigned char nTestBit = 0x80;//shit,why dosn't it work when 0x01?
75 1 unsigned char i = 0;
76 1 for(i = 0; i < 8; i++)
77 1 {
78 2 bEach = nData & nTestBit;
79 2 SDA = bEach;
80 2 Delay();
81 2 SCL = 1;
82 2 Delay();
83 2 SCL = 0;
84 2 SDA = !SDA;
85 2 nTestBit >>= 1;
86 2 }
87 1 }
88
89 //read one byte from 24c02
90 char ReadByte(unsigned char nAddress)
91 {
92 1 char i = 0;
93 1 unsigned char nBuff = 0;
94 1 Start();
95 1
96 1 WriteByte(0xA0); // write signal
97 1 while(GetACK());
98 1
99 1 WriteByte(nAddress); //adress of memory in 24c02
100 1 while(GetACK());
101 1
102 1 Start();
103 1 WriteByte(0xA1); // read signal
104 1 while(GetACK());
105 1
106 1 for(i = 7; i >= 0; i--)
107 1 {
108 2 SCL = 1;
109 2 Delay();
110 2 nBuff |= (unsigned char)SDA << i;
111 2 SCL = 0;
112 2 Delay();
113 2 }
114 1
115 1 return nBuff;
116 1 }
117
C51 COMPILER V6.23a 24C02BAK 11/06/2005 16:32:12 PAGE 3
118 /*clear all data in 24c02
119 void ClearAll(void)
120 {
121
122 }
123 */
124
125
126 void INT1_func() interrupt 2 using 2
127 {
128 1 //read the data in 24c02----------------------------------------
129 1 for(i = 0; i <= 7; i++)
130 1 {
131 2 nReceive[i] = ReadByte(nAdress + i);
132 2 }
133 1
134 1 Stop();
135 1 P1 = nReceive[0];
136 1
137 1 }
138 /**************************** MAIN FUNC*****************************************/
139
140 void Main()
141 {
142 1 /*
143 1 IT1 = 1;
144 1 EX1 = 1;
145 1 EA = 1;
146 1
147 1
148 1 //write the data into 24c02-----------------------------------
149 1 Start();
150 1
151 1 WriteByte(0xA0); //control command
152 1 while(GetACK());
153 1
154 1 WriteByte(nAdress); //adress to write
155 1 while(GetACK());
156 1
157 1 i = 0;
158 1 while(i <= 7)
159 1 {
160 1 WriteByte(nStore[i]);
161 1 while(GetACK());
162 1
163 1 i++;
164 1 }
165 1
166 1
167 1 Stop(); //if this take effect,the following doesn't work
168 1
169 1 P1_0 = 0;
170 1 */
171 1
172 1
173 1 //read the data in 24c02----------------------------------------
174 1 for(i = 0; i <= 7; i++)
175 1 {
176 2 nReceive[i] = ReadByte(nAdress + i);
177 2 }
178 1
179 1 Stop();
C51 COMPILER V6.23a 24C02BAK 11/06/2005 16:32:12 PAGE 4
180 1 P1 = nReceive[7];
181 1
182 1
183 1 while(1);
184 1 }
185
186
187 /* WriteByte('H');
188 while(GetACK());
189 WriteByte('a');
190 while(GetACK());
191 WriteByte('t');
192 while(GetACK());
193 WriteByte('e');
194 while(GetACK());
195 WriteByte('M');
196 while(GetACK());
197 WriteByte('a');
198 while(GetACK());
199 WriteByte('t');
200 while(GetACK());
201 WriteByte('h');
202 while(GetACK());
203
204 WriteByte(' ');
205 while(GetACK());
206
207 WriteByte('i');
208 while(GetACK());
209 WriteByte('s');
210 while(GetACK());
211
212 WriteByte(' ');
213 while(GetACK());
214
215 WriteByte('a');
216 while(GetACK());
217 WriteByte('n');
218 while(GetACK());
219
220 WriteByte(' ');
221 while(GetACK());
222
223 WriteByte('e');
224 while(GetACK());
225 WriteByte('x');
226 while(GetACK());
227 WriteByte('c');
228 while(GetACK());
229 WriteByte('e');
230 while(GetACK());
231 WriteByte('l');
232 while(GetACK());
233 WriteByte('l');
234 while(GetACK());
235 WriteByte('e');
236 while(GetACK());
237 WriteByte('n');
238 while(GetACK());
239 WriteByte('t');
240 while(GetACK());
241
C51 COMPILER V6.23a 24C02BAK 11/06/2005 16:32:12 PAGE 5
242 WriteByte(' ');
243 while(GetACK());
244
245 WriteByte('b');
246 while(GetACK());
247 WriteByte('o');
248 while(GetACK());
249 WriteByte('y');
250 while(GetACK());
251
252 WriteByte(' ');
253 while(GetACK());
254
255 WriteByte('^');
256 while(GetACK());
257 WriteByte('_');
258 while(GetACK());
259 WriteByte('^');
260 while(GetACK());
261
262
263 */
264
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 261 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 66 ----
IDATA SIZE = ---- ----
BIT SIZE = ---- 2
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -