📄 main.lst
字号:
C51 COMPILER V7.06 MAIN 03/11/2005 13:25:33 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: D:\PROGRAM FILES\KEIL\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include <REG52.h>
2 #include <intrins.h>
3 #include <math.h>
4 #include <absacc.h>
5 #define C_ADD XBYTE[0xD000] //指令口地址
6 #define D_ADD XBYTE[0xD001] //数据口地址
7 #define PARA1 0x0A0 //80个字节/行
8
9 sbit SCL= P1^3 ;
10 sbit SDA= P1^4 ;
11 unsigned char xdata ppp[10] ={10,0xaa,30,40,50,60,70,80,90,100} ;
12 unsigned char xdata ppp[10] _at_ 0x00;
13
14 void clear();
15 void ccw_pr(unsigned int x,unsigned int y,unsigned int g);
16 void cc24pr(unsigned int s,unsigned int d ,unsigned int h);
17 void cw_pr(unsigned int m,unsigned int n, unsigned int d);
18 void w_dot(unsigned int x ,unsigned int y );
19 void cl_dot(unsigned int x,unsigned int y);
20 void onebyte_pr(unsigned int x,unsigned int y,unsigned int dataa);
21 void clcw_pr(unsigned int x, unsigned int y);
22 void clonebyte_pr(unsigned int x,unsigned int y);
23 void WriteIns(unsigned char d);
24 void WriteData(unsigned int,unsigned int ,unsigned int,unsigned int );
25 void cw_prr(unsigned int m,unsigned int n, unsigned int d);
26 void clcw_prr(unsigned int m,unsigned int n);
27
28 extern data unsigned char GRAYB;
29 unsigned int G_INSNUM;
30
31
32 void writeins(unsigned char d){
33 1 switch(d)
34 1 {case 12: /*8*8 英文*/
35 2 G_INSNUM=1;
36 2 break;
37 2 case 15:
38 2 G_INSNUM=2; /* 写点 */
39 2 break;
40 2 case 1: /*16*16汉文*/
41 2 G_INSNUM=3;
42 2 break;
43 2 case 2: /*擦一个字节*/
44 2 G_INSNUM=4;
45 2 break;
46 2 case 3: /*擦点*/
47 2 G_INSNUM=5;
48 2 break;
49 2 case 4: /*擦8*8英文*/
50 2 G_INSNUM=6;
51 2 break;
52 2 case 5: /*写一个字节*/
53 2 G_INSNUM=7;
54 2 break;
55 2 case 6: /*擦8*8字符*/
C51 COMPILER V7.06 MAIN 03/11/2005 13:25:33 PAGE 2
56 2 G_INSNUM=8;
57 2 break;
58 2 case 7: /*24*24汉文*/
59 2 G_INSNUM=9;
60 2 break;
61 2 case 8: /*16*8英文*/
62 2 G_INSNUM=10;
63 2 break;
64 2 case 9: /*擦16*8字符*/
65 2 G_INSNUM=11;
66 2 break;
67 2 default: break;
68 2 }
69 1 }
70
71 void WriteData(unsigned int x,unsigned int y,unsigned int dataa,unsigned int disp_type)
72 {
73 1 switch(disp_type) /*disp_type最高位是正显反显,最低位是灰显还是亮显*/
74 1 {
75 2 case 0x00: /*反显灰显*/
76 2 {
77 3 GRAYB=0X80;
78 3 break;
79 3 }
80 2 case 0x01: /*反显亮显*/
81 2 {
82 3 GRAYB=0XC0;
83 3 break;
84 3 }
85 2 case 0x80: /*正显灰显*/
86 2 {
87 3 GRAYB=0X08;
88 3 break;
89 3 }
90 2 case 0x81: /*正显亮显*/
91 2 {
92 3 GRAYB=0X0C;
93 3 break;
94 3 }
95 2 default:
96 2 break;
97 2 }
98 1 switch(G_INSNUM){
99 2 case 1:
100 2 {
101 3 cw_pr(x,y,dataa);
102 3 break;
103 3 }
104 2 case 2:
105 2 {
106 3 w_dot(x,y);
107 3 break;
108 3 }
109 2 case 3:
110 2 {
111 3 ccw_pr(x,y,dataa);
112 3 break;
113 3 }
114 2 case 4:
115 2
116 2 {
117 3 clonebyte_pr(x,y);
C51 COMPILER V7.06 MAIN 03/11/2005 13:25:33 PAGE 3
118 3 break;
119 3 }
120 2 case 5:
121 2 {
122 3 cl_dot(x,y);
123 3 break;
124 3 }
125 2 case 6:
126 2 {
127 3 clcw_pr(x,y);
128 3 break;
129 3 }
130 2 case 7:
131 2 {
132 3 onebyte_pr(x,y,dataa);
133 3 break;
134 3 }
135 2 case 8:
136 2 {
137 3 clcw_pr(x,y);
138 3 break;
139 3 }
140 2 case 9:
141 2 {
142 3 cc24pr(x,y,dataa);
143 3 break;
144 3 }
145 2 case 10:
146 2 {
147 3 cw_prr(x,y,dataa);
148 3 break;
149 3 }
150 2 case 11:
151 2 {
152 3 clcw_prr(x,y);
153 3 break;
154 3 }
155 2 default:
156 2 break;
157 2 }
158 1 }
159 void clonebyte_pr(unsigned int x,unsigned int y)
160 { onebyte_pr(x,y,0);
161 1 }
162
163 void Start()
164 {
165 1 SDA=1;
166 1 SCL=1;
167 1 SDA=0;
168 1 SCL=0;
169 1 } /*开始的前导符*/
170 void Stop()
171 {
172 1
173 1
174 1 SDA=0;
175 1 SCL=1;
176 1 SDA=1;
177 1 SCL=0;
178 1 SDA=0;
179 1
C51 COMPILER V7.06 MAIN 03/11/2005 13:25:33 PAGE 4
180 1
181 1 }
182 void Send(unsigned char SendData)
183 {
184 1 unsigned char data temp;
185 1 unsigned char data i;
186 1 SCL=0;
187 1
188 1 for (i=0;i<8;i++)
189 1 {
190 2 temp=SendData ;
191 2 temp=temp&0x80;
192 2
193 2 if (temp==0x80) /*bit 7 is 1*/
194 2 {
195 3 SDA=1;
196 3 }
197 2 else
198 2 {
199 3 SDA=0;
200 3 }
201 2
202 2 SCL=1;
203 2 SCL=0;
204 2
205 2 SendData=SendData<<1;
206 2 } /* end for i*/
207 1
208 1 SDA=1;
209 1 SCL=1;
210 1 while(SDA) {} /*JUDGE WHETHER ACKNOWLEDGE IS OCCUR OR NOT*/
211 1 SCL=0;
212 1
213 1 } /*发送数据*/
214 void Start_2464(unsigned char rw, /*读或写的标志*/
215 unsigned char h_addr /*24c256的硬件的编址*/
216 )
217
218 {
219 1 unsigned char data byte;
220 1 rw&=0x01;
221 1 byte=0xa0;
222 1 byte|=rw;
223 1 h_addr&=0x07; /*get low three bit */
224 1 h_addr=h_addr<<1;
225 1 byte|=h_addr;
226 1 Start();
227 1
228 1 Send(byte);
229 1
230 1
231 1 }
232 void ByteWrite_2464( unsigned int addr, /*待发送的数的首址*/
233 unsigned char senddata) /* 待发送的数 */
234 {
235 1 unsigned char data temp;
236 1 Start_2464(0x00,0x00);
237 1 temp= addr>>8 ; /*high address */
238 1 Send(temp);
239 1 temp=addr&0x00ff; /*low address */
240 1 Send(temp);
241 1 Send(senddata);
C51 COMPILER V7.06 MAIN 03/11/2005 13:25:33 PAGE 5
242 1 Stop();
243 1 for (temp=0;temp<0xff ;temp++); /*对于I2C总线而言延时是最重要的,*/
244 1 for (temp=0;temp<0x80;temp++);
245 1 /*我们上一次就因为这个部分而吃亏*/
246 1
247 1
248 1
249 1 }
250 char Get_2464 () /*获取一个字节的数据*/
251 {
252 1 unsigned char data getdata;
253 1 unsigned char data cycle;
254 1 getdata=0x00;
255 1
256 1 for (cycle=0;cycle<8;cycle++) /*一共要接受8个字节的数据*/
257 1 {
258 2 getdata=getdata<<1;
259 2 SCL=1;
260 2 if (SDA) /*SDA=1*/
261 2 {
262 3 getdata|=0x01;
263 3 }
264 2 else /*SDA=0*/
265 2 {
266 3 getdata|=0x00;
267 3 }
268 2 SCL=0;
269 2
270 2 } /*end for cycle*/
271 1 return getdata;
272 1
273 1
274 1 }
275
276 void SequentialRead_2464( unsigned int addr , /*存放数据的首址,读取的数据全部存储到外部的数据存储
-器*/
277 unsigned int num) /*读取数据的字节数*/
278 {
279 1 unsigned int data cycle;
280 1 unsigned char data senddata;
281 1
282 1
283 1
284 1 Start_2464(0X01,0X00);
285 1 for (cycle=0;cycle<num;cycle++)
286 1 {
287 2 senddata=Get_2464();
288 2 XBYTE[addr]=senddata; /*送到外部的数据存储器*/
289 2 addr++;
290 2 if(cycle==num-1) /*the last byte data need not ACK*/
291 2 {
292 3 SDA=1;
293 3 SCL=1;
294 3 SCL=0; /*NOACK*/
295 3 Stop();
296 3 break;
297 3 }
298 2 SDA=0; /*ACK*/
299 2 SCL=1; /*ACK*/
300 2 SCL=0; /*ACK*/
301 2 SDA=1; /*ACK*/
302 2 } /*end for cycle*/
C51 COMPILER V7.06 MAIN 03/11/2005 13:25:33 PAGE 6
303 1 }
304 void RandomRead_2464(unsigned int waddr,/*读取的数据放到外部的数据存储器waddr就是外部的数据存储
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -