📄 24c256.lst
字号:
C51 COMPILER V6.12 24C256 06/02/2006 14:59:22 PAGE 1
C51 COMPILER V6.12, COMPILATION OF MODULE 24C256
OBJECT MODULE PLACED IN .\24c256.OBJ
COMPILER INVOKED BY: d:\toolfiles\Keil\C51\BIN\C51.EXE .\24c256.c DEBUG OBJECTEXTEND
stmt level source
1
2 # include<pic.h>
*** ERROR 318 IN LINE 2 OF .\24c256.c: can't open file 'pic.h'
3 # define uch unsigned char
4 # define unint unsigned int
5 # define SDA RC4
6 # define SCL RC3
7 uch ACK;
8
9 void delay(void) //延时
10 {
11 1 unint m;
12 1 for(m=0;m<0xffff;m++)
13 1 continue;
14 1 }
15
16 void start (void) // IIC开始
17 {
18 1 TRISC3=0; //置输出
*** ERROR C202 IN LINE 18 OF .\24C256.C: 'TRISC3': undefined identifier
19 1 TRISC4=0;
*** ERROR C202 IN LINE 19 OF .\24C256.C: 'TRISC4': undefined identifier
20 1 SDA=1;
*** ERROR C202 IN LINE 20 OF .\24C256.C: 'RC4': undefined identifier
21 1 asm("nop");
*** WARNING C206 IN LINE 21 OF .\24C256.C: 'asm': missing function-prototype
*** ERROR C267 IN LINE 21 OF .\24C256.C: 'asm': requires ANSI-style prototype
22 1 SCL=1; //在至少4u秒期间SDA从高电平到低电平
*** ERROR C202 IN LINE 22 OF .\24C256.C: 'RC3': undefined identifier
23 1 asm("nop");
24 1 asm("nop");
25 1 asm("nop");
26 1 SDA=0;
*** ERROR C202 IN LINE 26 OF .\24C256.C: 'RC4': undefined identifier
27 1 asm("nop");
28 1 asm("nop");
29 1 asm("nop");
30 1 SCL=0;
*** ERROR C202 IN LINE 30 OF .\24C256.C: 'RC3': undefined identifier
31 1 asm("nop");
32 1 asm("nop");
33 1 }
34
35 void stop(void) // IIC结束
36 { TRISC3=0;
*** ERROR C202 IN LINE 36 OF .\24C256.C: 'TRISC3': undefined identifier
37 1 TRISC4=0; //置输出
*** ERROR C202 IN LINE 37 OF .\24C256.C: 'TRISC4': undefined identifier
38 1 SDA=0;
*** ERROR C202 IN LINE 38 OF .\24C256.C: 'RC4': undefined identifier
39 1 asm("nop");
40 1 SCL=1; //在至少4u秒期间SDA从低电平到高电平
*** ERROR C202 IN LINE 40 OF .\24C256.C: 'RC3': undefined identifier
41 1 asm("nop");
42 1 asm("nop");
C51 COMPILER V6.12 24C256 06/02/2006 14:59:22 PAGE 2
43 1 asm("nop");
44 1 SDA=1;
*** ERROR C202 IN LINE 44 OF .\24C256.C: 'RC4': undefined identifier
45 1 asm("nop");
46 1 asm("nop");
47 1 asm("nop");
48 1 SCL=0;
*** ERROR C202 IN LINE 48 OF .\24C256.C: 'RC3': undefined identifier
49 1 asm("nop");
50 1 asm("nop");
51 1 }
52
53 uch check(void) // 检查应答信号
54 {
55 1 TRISC4=1;
*** ERROR C202 IN LINE 55 OF .\24C256.C: 'TRISC4': undefined identifier
56 1 SCL=0;
*** ERROR C202 IN LINE 56 OF .\24C256.C: 'RC3': undefined identifier
57 1 SCL=1;
*** ERROR C202 IN LINE 57 OF .\24C256.C: 'RC3': undefined identifier
58 1
59 1 if (SDA == 1)
*** ERROR C202 IN LINE 59 OF .\24C256.C: 'RC4': undefined identifier
60 1 {
61 2 ACK = 1;
62 2 }
63 1 else
64 1 {
65 2 ACK = 0;
66 2 }
67 1 SCL=0;
*** ERROR C202 IN LINE 67 OF .\24C256.C: 'RC3': undefined identifier
68 1 return(ACK);
69 1 }
70
71
72 void send(uch data) // 发送一个字节
*** ERROR C141 IN LINE 72 OF .\24C256.C: syntax error near ')'
73 {
74 1 uch bitcount=8; //发送8位
75 1 do
76 1 {
77 2 TRISC3=0; //置输出
*** ERROR C202 IN LINE 77 OF .\24C256.C: 'TRISC3': undefined identifier
78 2 TRISC4=0;
*** ERROR C202 IN LINE 78 OF .\24C256.C: 'TRISC4': undefined identifier
79 2 if((data&0x80)==0x80)
*** ERROR C141 IN LINE 79 OF .\24C256.C: syntax error near 'data'
*** ERROR C141 IN LINE 79 OF .\24C256.C: syntax error near '=='
*** ERROR C141 IN LINE 79 OF .\24C256.C: syntax error near ')'
80 2 {
81 3 SDA=1; //发送 1
*** ERROR C202 IN LINE 81 OF .\24C256.C: 'RC4': undefined identifier
82 3 }
83 2 else
*** ERROR C141 IN LINE 83 OF .\24C256.C: syntax error near 'else'
84 2 {
85 3 SDA=0; //发送 0
*** ERROR C202 IN LINE 85 OF .\24C256.C: 'RC4': undefined identifier
86 3 }
87 2
88 2 SCL=0; // 在时钟大于4u秒期间写数据
C51 COMPILER V6.12 24C256 06/02/2006 14:59:22 PAGE 3
*** ERROR C202 IN LINE 88 OF .\24C256.C: 'RC3': undefined identifier
89 2 SCL=1;
*** ERROR C202 IN LINE 89 OF .\24C256.C: 'RC3': undefined identifier
90 2 asm("nop");
91 2 asm("nop");
92 2 asm("nop");
93 2 asm("nop");
94 2 asm("nop");
95 2 SCL=0;
*** ERROR C202 IN LINE 95 OF .\24C256.C: 'RC3': undefined identifier
96 2 data=data<<1;
*** ERROR C141 IN LINE 96 OF .\24C256.C: syntax error near 'data'
97 2 bitcount--;
98 2 } while(bitcount);
99 1 TRISC4=1 ; //释放总线等待应答
*** ERROR C202 IN LINE 99 OF .\24C256.C: 'TRISC4': undefined identifier
100 1 asm("nop");
101 1 asm("nop");
102 1 asm("nop");
103 1 asm("nop");
104 1 asm("nop");
105 1 }
106
107 uch recive(void) //接受一个字节
108 {
109 1 uch temp1=0;
110 1 uch bitcount1=8;
111 1 TRISC4=1; //置输入
*** ERROR C202 IN LINE 111 OF .\24C256.C: 'TRISC4': undefined identifier
112 1 TRISC3=0;
*** ERROR C202 IN LINE 112 OF .\24C256.C: 'TRISC3': undefined identifier
113 1 do
114 1 { SCL=0; //在时钟大于4u秒期间读数据
*** ERROR C202 IN LINE 114 OF .\24C256.C: 'RC3': undefined identifier
115 2 SCL=1;
*** ERROR C202 IN LINE 115 OF .\24C256.C: 'RC3': undefined identifier
116 2 asm("nop");
117 2 asm("nop");
118 2 if(SDA) //读 1
*** ERROR C202 IN LINE 118 OF .\24C256.C: 'RC4': undefined identifier
119 2 {
120 3 temp1=temp1|0x01;
121 3 }
122 2 else //读 0
123 2 {
124 3 temp1=temp1&0xfe;
125 3 }
126 2 SCL=0;
*** ERROR C202 IN LINE 126 OF .\24C256.C: 'RC3': undefined identifier
127 2 if(bitcount1-1)
128 2 {
129 3 temp1=temp1<<1;
130 3 }
131 2 bitcount1--;
132 2 }while(bitcount1);
133 1 return(temp1);
134 1 }
135 void ack(void) //发送继续读信号
136 {
137 1 SDA=0;
*** ERROR C202 IN LINE 137 OF .\24C256.C: 'RC4': undefined identifier
138 1 SCL=0;
C51 COMPILER V6.12 24C256 06/02/2006 14:59:22 PAGE 4
*** ERROR C202 IN LINE 138 OF .\24C256.C: 'RC3': undefined identifier
139 1 SCL=1;
*** ERROR C202 IN LINE 139 OF .\24C256.C: 'RC3': undefined identifier
140 1 asm("nop");
141 1 asm("nop");
142 1 asm("nop");
143 1 asm("nop");
144 1 asm("nop");
145 1 SCL=0;
*** ERROR C202 IN LINE 145 OF .\24C256.C: 'RC3': undefined identifier
146 1 }
147
148 void nack(void) //停止继续读
149 {
150 1 SDA=1;
*** ERROR C202 IN LINE 150 OF .\24C256.C: 'RC4': undefined identifier
151 1 SCL=0;
*** ERROR C202 IN LINE 151 OF .\24C256.C: 'RC3': undefined identifier
152 1 SCL=1;
*** ERROR C202 IN LINE 152 OF .\24C256.C: 'RC3': undefined identifier
153 1 asm("nop");
154 1 asm("nop");
155 1 asm("nop");
156 1 asm("nop");
157 1 asm("nop");
158 1 SCL=0;
*** ERROR C202 IN LINE 158 OF .\24C256.C: 'RC3': undefined identifier
159 1 }
160
161
162 void wrtoROM(uch *data,unint address,uch num) //给24LC256写数据
*** ERROR C141 IN LINE 162 OF .\24C256.C: syntax error near ','
163 { unint i;
164 1 unint adrl=address%256; //低8位地址
165 1 unint adrh=address/256; //高8位地址
166 1 start(); //起始信号
167 1 send(0xa2); //写主控器识别地址,本人是a2
168 1
169 1 do{;
170 2 }while(check()); //等待应答
171 1
172 1 send(adrh); //送数据高8位地址
173 1
174 1 do{;
175 2 }while(check()); //等待应答
176 1 send(adrl); //送数据低8位地址
177 1 do
178 1 {
179 2 ;
180 2 }while(check()); //等待应答
181 1 for(i=0;i<num;i++,data++) //发送从地址adress开始的num个数据
*** ERROR C141 IN LINE 181 OF .\24C256.C: syntax error near 'data'
182 1 {
183 2 send(*data); //发送数据
*** ERROR C141 IN LINE 183 OF .\24C256.C: syntax error near 'data'
184 2 do{;
185 3 }while(check()); //等待应答
186 2 }
187 1 stop(); //停止
188 1 delay(); //延时,下次发数据
189 1
190 1 }
C51 COMPILER V6.12 24C256 06/02/2006 14:59:22 PAGE 5
191 void rdfromROM(uch *pdata,unint address,uch num2) //从24LC256中读数据
*** ERROR C141 IN LINE 191 OF .\24C256.C: syntax error near ','
192 { unint adrl;
193 1 unint adrh;
194 1 uch j;
195 1 for(j=0;j<num2;j++,pdata++)
*** ERROR C141 IN LINE 195 OF .\24C256.C: syntax error near 'pdata'
196 1 {
197 2 adrl=address%256; //地址低位
198 2 adrh=address/256; //地址高位
199 2 start(); //开始
200 2 send(0xa2); //写主控器识别地址(写),本人是a2
201 2 do{
202 3 ;
203 3 }while(check()); //等待应答
204 2 send(adrh); //送高位
205 2 do
206 2 {
207 3 ;
208 3 }while(check()); //等待应答
209 2 send(adrl); //送低位
210 2 do
211 2 {
212 3 ;
213 3 }while(check()); //等待应答
214 2 start(); //开始读数据
215 2 send(0xa3); //写主控器识别地址(读)
216 2 do
217 2 {
218 3 ;
219 3 }while(check()); //等待应答
220 2
221 2 *pdata=recive();
*** ERROR C141 IN LINE 221 OF .\24C256.C: syntax error near 'pdata'
222 2 nack();
223 2 stop();
224 2 address=address+1; //指向下一个地址
225 2
226 2
227 2 }
228 1 }
229
230 main()
231 { unint h,n;
232 1 uch m;
233 1
234 1
235 1 uch str[64]={0x5d,0x5d,0x32,0x18,0x6c,0x88,0xa0,0x1d,0x20,0x08};
236 1
237 1 SCL=1;
*** ERROR C202 IN LINE 237 OF .\24C256.C: 'RC3': undefined identifier
238 1 SDA=1;
*** ERROR C202 IN LINE 238 OF .\24C256.C: 'RC4': undefined identifier
239 1 PORTD=0XFF;
*** ERROR C202 IN LINE 239 OF .\24C256.C: 'PORTD': undefined identifier
240 1 TRISD=0;
*** ERROR C202 IN LINE 240 OF .\24C256.C: 'TRISD': undefined identifier
241 1 for(n=0;n<256;)
242 1 {
243 2 wrtoROM(str,n,64); //写一页的数据,根据24LC256一页是64个字节
*** ERROR C208 IN LINE 243 OF .\24C256.C: '_wrtoROM': too many actual parameters
244 2 n=n+64; //写下一页数据
C51 COMPILER V6.12 24C256 06/02/2006 14:59:22 PAGE 6
245 2 }
246 1
247 1 for(h=0;h<64;h++) //数组清0
248 1 {
249 2 str[h]=0x21;
*** ERROR C213 IN LINE 249 OF .\24C256.C: left side of asn-op not an lvalue
250 2 }
251 1 delay();
252 1 rdfromROM(str,0x02,64); //读从地址0开始的一页数据
*** ERROR C208 IN LINE 252 OF .\24C256.C: '_rdfromROM': too many actual parameters
253 1 while(1)
254 1 {
255 2 for(m=0;m<64;m++)
256 2 {
257 3 PORTD=str[m];
*** ERROR C202 IN LINE 257 OF .\24C256.C: 'PORTD': undefined identifier
258 3 delay();
259 3 PORTD=0XFF;
*** ERROR C202 IN LINE 259 OF .\24C256.C: 'PORTD': undefined identifier
260 3 delay();
261 3 }
262 2 }
263 1 }
264
C51 COMPILATION COMPLETE. 1 WARNING(S), 62 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -