?? main.lst
字號:
C51 COMPILER V8.02 MAIN 04/01/2009 11:20:18 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include <at89x52.h>
2 #include <intrins.h>
3
4 sbit CS1 =P1^3; //1片選
5 sbit CS2 =P1^5; //2片選
6 sbit CS3 =P1^6; //3片選
7 sbit RS =P1^0; //數據指令
8 sbit RW =P1^1; //讀寫
9 sbit E =P1^2; //使能
10 sbit RST =P1^5;//復位
11
12
13 #define DATA P2
14 #define uchar unsigned char
15 #define uint unsigned int
16
17 /*----------------------------------------------------------------------------
18 Delay some time//延時
19 ------------------------------------------------------------------------------*/
20 void delay10ms(unsigned char x)
21 {
22 1 unsigned char i,j,k;
23 1 for(i=0;i<x;i++)
24 1 for(j=0;j<10;j++)
25 1 for(k=0;k<120;k++);
26 1 }
27 /*----------------------------------------------------------------------------
28 Send the instruction to the First KS0108 window
29 ------------------------------------------------------------------------------
30 --*/
31 void OutFI(uchar i)
32 {
33 1 unsigned char data_sta;
34 1 do{
35 2 E=0;RW=1;RS=0;CS1=0;_nop_();
36 2 E=1;_nop_();
37 2 data_sta=DATA;
38 2 E=0;RW=0;CS1=1;E=1;
39 2 }while(data_sta&0x80);
40 1
41 1 E=0;RW=0;RS=0;CS1=0;_nop_();
42 1 E=1;_nop_();
43 1 DATA=i;
44 1 _nop_();E=0;RW=1;CS1=1;E=1;
45 1 }
46
47 /*----------------------------------------------------------------------------
48 Send the instruction to the Second KS0108 window.
49 ------------------------------------------------------------------------------
50 --*/
51 void OutSI(uchar i)
52 {
53 1 unsigned char data_sta;
54 1 do{
55 2 E=0;RW=1;RS=0;CS2=0;_nop_();
C51 COMPILER V8.02 MAIN 04/01/2009 11:20:18 PAGE 2
56 2 E=1;_nop_();
57 2 data_sta=DATA;
58 2 E=0;RW=0;CS2=1;E=1;
59 2 }while(data_sta&0x80);
60 1
61 1 E=0;RW=0;RS=0;CS2=0;_nop_();
62 1 E=1;_nop_();
63 1 DATA=i;
64 1 _nop_();E=0;RW=1;CS2=1;E=1;
65 1 }
66 /*----------------------------------------------------------------------------
67 Send the instruction to the Third KS0108 window
68 ------------------------------------------------------------------------------
69 --*/
70 void OutTI(uchar i)
71 {
72 1 unsigned char data_sta;
73 1 do{
74 2 E=0;RW=1;RS=0;CS3=0;_nop_();
75 2 E=1;_nop_();
76 2 data_sta=DATA;
77 2 E=0;RW=0;CS3=1;E=1;
78 2 }while(data_sta&0x80);
79 1
80 1 E=0;RW=0;RS=0;CS3=0;_nop_();
81 1 E=1;_nop_();
82 1 DATA=i;
83 1 _nop_();E=0;RW=1;CS3=1;E=1;
84 1 }
85
86 /*----------------------------------------------------------------------------
87 Send the data to the First ks0108 Window
88 ------------------------------------------------------------------------------
89 --*/
90 void OutFD(uchar i)
91 {
92 1 unsigned char data_sta;
93 1 do{
94 2 E=0;RW=1;RS=0;CS1=0;_nop_();
95 2 E=1;_nop_();
96 2 data_sta=DATA;
97 2 E=0;RW=0;CS1=1;E=1;
98 2 }while(data_sta&0x80);
99 1
100 1 E=0;RW=0;RS=1;CS1=0;_nop_();
101 1 E=1;_nop_();
102 1 DATA=i;
103 1 _nop_();E=0;RW=1;CS1=1;E=1;
104 1 }
105 /*----------------------------------------------------------------------------
106 Send the data to the Second ks0108 Window
107 ------------------------------------------------------------------------------
108 --*/
109 void OutSD(uchar i)
110 {
111 1 unsigned char data_sta;
112 1 do{
113 2 E=0;RW=1;RS=0;CS2=0;_nop_();
114 2 E=1;_nop_();
115 2 data_sta=DATA;
116 2 E=0;RW=0;CS2=1;E=1;
117 2 }while(data_sta&0x80);
C51 COMPILER V8.02 MAIN 04/01/2009 11:20:18 PAGE 3
118 1
119 1 E=0;RW=0;RS=1;CS2=0;_nop_();
120 1 E=1;_nop_();
121 1 DATA=i;
122 1 _nop_();E=0;RW=1;CS2=1;E=1;
123 1 }
124 /*----------------------------------------------------------------------------
125 Send the data to the Third ks0108 Window
126 ------------------------------------------------------------------------------
127 --*/
128 void OutTD(uchar i)
129 {
130 1 unsigned char data_sta;
131 1 do{
132 2 E=0;RW=1;RS=0;CS3=0;_nop_();
133 2 E=1;_nop_();
134 2 data_sta=DATA;
135 2 E=0;RW=0;CS3=1;E=1;
136 2 }while(data_sta&0x80);
137 1
138 1 E=0;RW=0;RS=1;CS3=0;_nop_();
139 1 E=1;_nop_();
140 1 DATA=i;
141 1 _nop_();E=0;RW=1;CS3=1;E=1;
142 1 }
143
144 /*----------------------------------------------------------------------------
145 Read the data to the First ks0108 Window
146 ------------------------------------------------------------------------------
147 --*/
148 /*unsigned char RD_data_F()
149 {
150 unsigned char data_sta;
151 do{
152 E=0;RW=1;RS=0;CS1=0;_nop_();
153 E=1;_nop_();
154 data_sta=DATA;
155 E=0;RW=0;CS1=1;E=1;
156 }while(data_sta&0x80);
157
158 E=0;RW=1;RS=1;CS1=0;_nop_();
159 E=1;_nop_();_nop_();_nop_();
160 data_sta=DATA;
161 _nop_();E=0;RW=0;CS1=1;E=1;
162
163 return (data_sta);
164 }
165 /*----------------------------------------------------------------------------
166 Read the data to the Second ks0108 Window
167 ------------------------------------------------------------------------------
168 --*/
169 /*unsigned char RD_data_S()
170 {
171 unsigned char data_sta;
172 do{
173 E=0;RW=1;RS=0;CS2=0;_nop_();
174 E=1;_nop_();_nop_();_nop_();
175 data_sta=DATA;
176 E=0;RW=0;CS2=1;E=1;
177 }while(data_sta&0x80);
178
179 E=0;RW=1;RS=1;CS2=0;_nop_();
C51 COMPILER V8.02 MAIN 04/01/2009 11:20:18 PAGE 4
180 E=1;_nop_();
181 data_sta=DATA;
182 _nop_();E=0;CS2=1;E=1;
183
184 return (data_sta);
185 }
186 /*----------------------------------------------------------------------------
187 Read the data to the Third ks0108 Window
188 ------------------------------------------------------------------------------
189 --*/
190 /*unsigned char RD_data_T()
191 {
192 unsigned char data_sta;
193 do{
194 E=0;RW=1;RS=0;CS3=0;_nop_();
195 E=1;_nop_();_nop_();_nop_();
196 data_sta=DATA;
197 E=0;RW=0;CS3=1;E=1;
198 }while(data_sta&0x80);
199
200 E=0;RW=1;RS=1;CS3=0;_nop_();
201 E=1;_nop_();
202 data_sta=DATA;
203 _nop_();E=0;CS3=1;E=1;
204
205 return(data_sta);
206 }
207 /*------------------------------------------------------------------------------
208 Initialize the LCD,The system reset,invoke First time
209 --------------------------------------------------------------------------------
210 -*/
211 void InitLCD()
212 {
213 1 OutFI(0x40); /*Set the Y address 0 */
214 1 OutSI(0x40);
215 1 OutTI(0x40);
216 1 OutFI(0xb8); /*Set the Page 0 */
217 1 OutSI(0xb8);
218 1 OutTI(0xb8);
219 1 OutFI(0xc0); /*Set the display start line 0 */
220 1 OutSI(0xc0);
221 1 OutTI(0xc0);
222 1 OutFI(0x3f); /*Display ON */
223 1 OutSI(0x3f);
224 1 OutTI(0x3f);
225 1 }
226 /*------------------------------------------------------------------------------
227 Clear the three ks0108's display ram.
228 Clrscr screen
229 --------------------------------------------------------------------------------
230 -*/
231 void Clrscreen()
232 {
233 1 unsigned char i,j;
234 1 for(i=0;i<8;i++)
235 1 {
236 2 OutFI(0xb8|i);
237 2 for(j=0;j<64;j++)
238 2 {
239 3 OutFI(j|0x40);
240 3 OutFD(0);
241 3 }
C51 COMPILER V8.02 MAIN 04/01/2009 11:20:18 PAGE 5
242 2 }
243 1 for(i=0;i<8;i++)
244 1 {
245 2 OutSI(0xb8|i);
246 2 for(j=0;j<64;j++)
247 2 {
248 3 OutSI(j|0x40);
249 3 OutSD(0);
250 3 }
251 2 }
252 1
253 1 for(i=0;i<8;i++)
254 1 {
255 2 OutTI(0xb8|i);
256 2 for(j=0;j<64;j++)
257 2 {
258 3 OutTI(j|0x40);
259 3 OutTD(0);
260 3 }
261 2 }
262 1 }
263
264 /*------------------------------------------------------------------------------
265 --
266 Display Chinese ideograph;x_add is the x address;It has 4 layers,0,1,2,3;
267 Width is the Chinese ideograph width;bmp is the table's name
268 --------------------------------------------------------------------------------
269 -*/
270 void DrawBmp(uchar x_add,uchar layer,uchar width,uchar *bmp)
271 {
272 1 unsigned char x;
273 1 unsigned int i=0;
274 1
275 1 for(x=x_add;x<x_add+width;x++)
276 1 {
277 2 if (x>127) /*The Third KS0108*/
278 2 {
279 3 OutTI((x-128)|0x40); /*Set the x address*/
280 3 OutTI(layer|0xb8); /*Set the y address*/
281 3 OutTD(bmp[i]); /*Send thd data to LCD ram*/
282 3
283 3 OutTI((x-128)|0x40); /*Display the down screen*/
284 3 OutTI((layer|0xb8)+1);
285 3 i++; /*Display zimo table address add 1*/
286 3 OutTD(bmp[i]);
287 3 }
288 2 else if (x>63) /*The Second ks0108*/
289 2 {
290 3 OutSI((x-64)|0x40);
291 3 OutSI(layer|0xb8);
292 3 OutSD(bmp[i]);
293 3
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -