📄 bw128x64.lst
字号:
C51 COMPILER V7.09 BW128X64 01/31/2008 16:08:34 PAGE 1
C51 COMPILER V7.09, COMPILATION OF MODULE BW128X64
OBJECT MODULE PLACED IN bw128x64.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE bw128x64.c BROWSE DEBUG OBJECTEXTEND
line level source
1
2 #include <reg52.H>
3
4
5 #define TRUE 1
6 #define FALSE 0
7
8 sbit CS1= P3^0; //0有效
9 sbit CS2= P3^1;
10 sbit DI = P3^2; //1 data,0 instruction
11 sbit RW = P3^3; //1 read,0 write
12
13 sbit E = P3^4; // 1 读状态,0 写状态,下降沿锁存
14 sbit RESET = P3^5; //0 复位,1常态
15 sbit Busy = P1^7;
16
17 //unsigned char COLUMN;
18
19 void Initial();
20 void Delay(unsigned int time);
21 bit Q_Busy();
22 void Data_Write(unsigned char aa);
23 void Code_Write(unsigned char aa);
24 unsigned char Status_Read();
25 unsigned char Data_Read();
26 void location(unsigned y,unsigned x);
27 void Select_Chip1();
28 void Select_Chip2();
29 void Display_LcdWrite();
30 void Display_logo() ;
31 void test89(); // 测试89系统是否正常
32 void Lcd_Clear();
33
34 unsigned char code Logo9616[192];
35
36 //******************************************************
37 void main()
38 {
39 1
40 1 // test89();
41 1 Select_Chip1();
42 1 Initial();
43 1 Select_Chip2();
44 1 Initial();
45 1
46 1
47 1 while(1){
48 2 Lcd_Clear();
49 2 Display_LcdWrite();
50 2 // Display_logo() ;
51 2 };
52 1
53 1 }
54
55 //初始化
C51 COMPILER V7.09 BW128X64 01/31/2008 16:08:34 PAGE 2
56 void Initial()
57 {
58 1
59 1 RESET=0; //复位有效
60 1 Delay(10000);
61 1 RESET=1;
62 1 Delay(10000);
63 1 Code_Write(0x3e); //display off
64 1 Delay(1000);
65 1 Code_Write(0x40); //Sets the Y address in the Y address counter.
66 1 Delay(1000);
67 1 Code_Write(0xb8); //Sets the X address at the X address register.
68 1 Delay(1000);
69 1 Code_Write(0xc0); //Z:Indicates the display data RAM displayed at the top of the screen.
70 1 Delay(1000);
71 1 Code_Write(0x3f); //display on
72 1 Delay(1000);
73 1
74 1 }
75 //延时
76 void Delay(unsigned int time)
77 {
78 1
79 1
80 1
81 1 while(time) time--; /*delay time*/
82 1 }
83
84
85 //查询 busy与否状态
86 bit Q_Busy()
87 {
88 1 bit kk;
89 1 Status_Read();
90 1 kk=Busy;
91 1 return kk; //1,busy;0,free;
92 1 }
93
94 //write 子程序:2个区分数据命令
95 void Data_Write(unsigned char aa)
96 {
97 1 // while(Q_Busy()){};
98 1 DI=1;
99 1 RW=0;
100 1 P1=aa; //作busy状态查询
101 1 E=1;
102 1 E=0;
103 1
104 1 }
105
106 void Code_Write(unsigned char aa)
107 {
108 1 // while(Q_Busy()){}; //作busy状态查询
109 1 DI=0;
110 1 RW=0;
111 1 P1=aa;
112 1 E=1;
113 1 E=0;
114 1
115 1 }
116
117 //读状态
C51 COMPILER V7.09 BW128X64 01/31/2008 16:08:34 PAGE 3
118 unsigned char Status_Read()
119 {
120 1 unsigned char aa;
121 1 P1=0xff; //先写ff,后查询状态
122 1 DI=0;
123 1 RW=1;
124 1 E=1;
125 1 aa=P1;
126 1 E=0;
127 1 return aa;
128 1
129 1 }
130 //读数据
131 unsigned char Data_Read()
132 {
133 1 unsigned char aa;
134 1 // while(Q_Busy()){};
135 1 DI=1;
136 1 RW=1;
137 1 E=1;
138 1 E=0;
139 1 aa=0xff;
140 1 E=1;
141 1 aa=P1;
142 1 E=0;
143 1 return aa;
144 1
145 1 }
146 void location(unsigned y,unsigned x)//希望出现在y列,x页这个位置
147 {
148 1 y=y%128;
149 1 x=x%8; //一页是对应一个字节的8位
150 1
151 1 if(y>=64)
152 1 {
153 2 Select_Chip2();
154 2 y=y-64;
155 2 Code_Write(0x40+y); //Set Y 列
156 2 Code_Write(0xb8+x); //Set X 页
157 2
158 2 Delay(1000);
159 2 }
160 1 else {
161 2 Select_Chip1();
162 2 Code_Write(0x40+y); //Sets Y
163 2 Code_Write(0xb8+x); //X
164 2
165 2 Delay(1000);
166 2 }
167 1 }
168
169 void Select_Chip1()
170 {
171 1 CS1=1;CS2=0;
172 1 }
173
174 void Select_Chip2()
175 {
176 1 CS1=0;CS2=1;
177 1 }
178 //==================
179 //在LCD上清屏
C51 COMPILER V7.09 BW128X64 01/31/2008 16:08:34 PAGE 4
180 //==================
181 void Lcd_Clear()
182 {
183 1
184 1 unsigned int i;
185 1 unsigned int j;
186 1
187 1
188 1 for(i=0;i<8;i++)
189 1 {
190 2 for(j=0;j<128;j++)
191 2 {
192 3 location(j,i); //j列,i 页
193 3 Data_Write(0xff);//1,dark;0,light;
194 3 }
195 2 }
196 1
197 1 }
198 //==================
199 //在LCD上显示写过程
200 //==================
201 void Display_LcdWrite()
202 {
203 1
204 1 unsigned int i;
205 1 unsigned int j;
206 1
207 1
208 1 for(i=0;i<4;i++)
209 1 {
210 2 for(j=0;j<130;j++)
211 2 {
212 3 location(j,i*2); //i 页,j列
213 3 Data_Write(0x00);//1,dark;0,light;
214 3 }
215 2 }
216 1
217 1 }
218 //========================================================
219
220 void Display_logo()
221 {
222 1 unsigned char z=0;
223 1 unsigned char i;
224 1 unsigned char j;
225 1
226 1 for(i=0;i<16;i++) //黑白图像,数组值为0,为亮,一个字节的一位(从高到低)代表了一个像素点
227 1 {
228 2 for(j=0;j<12;j++)
229 2 {
230 3 z=j+(i/8)*12;
231 3 location(z,i);
232 3 Data_Write(Logo9616[i*12+j]); //GD 16H*12L
233 3
234 3 }
235 2 }
236 1 Delay(500);
237 1 }
238
239 unsigned char code Logo9616[]={
240 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, //12列x16行
241 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
C51 COMPILER V7.09 BW128X64 01/31/2008 16:08:34 PAGE 5
242 0xF0,0x00,0x38,0x3F,0x80,0x1F,0xF8,0x00,0xFC,0x00,0x1F,0xFF,
243 0x80,0x00,0x08,0x3F,0x80,0x0F,0xF8,0x00,0xF8,0x04,0x1F,0xFF,
244 0x80,0x00,0x08,0x3F,0x80,0x0F,0xF0,0x00,0xF0,0x0C,0x1F,0xFF,
245 0xC0,0x7E,0x08,0x3F,0x81,0x00,0x00,0x20,0xC0,0x1C,0x1F,0xFF,
246 0xCF,0x80,0x08,0x3F,0x81,0x80,0x00,0x60,0x80,0x3C,0x00,0x07,
247 0xF8,0x00,0x08,0x00,0x01,0xC0,0x00,0x60,0x00,0x0C,0x00,0x01,
248 0xE0,0x00,0x18,0x00,0x01,0xC1,0xC0,0xE0,0x80,0x04,0x00,0x00,
249 0xC0,0x00,0x78,0x00,0x01,0xE1,0x81,0xE0,0xFE,0x00,0x1F,0xC0,
250 0xC0,0x1F,0xD8,0x3F,0x81,0xE0,0x01,0xE0,0xFF,0x00,0x1F,0xE0,
251 0xC0,0xF8,0x18,0x3F,0x81,0xF0,0x03,0xE0,0x7E,0x00,0x1F,0x80,
252 0xC0,0x00,0x08,0x3F,0x81,0xF8,0x03,0xE0,0x00,0x04,0x00,0x00,
253 0xE0,0x00,0x08,0x3F,0x81,0xF8,0x07,0xE0,0x00,0x0C,0x00,0x01,
254 0xF8,0x00,0x38,0x3F,0xC1,0xFE,0x1F,0xF0,0x00,0x7F,0x00,0x1F,
255 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF
256 };
257
258 //=================================================================
259 void test89()
260 {
261 1 do{
262 2 P1=0x0;
263 2 Delay(60000);
264 2 Delay(60000);
265 2 Delay(60000);
266 2
267 2 P1=0xff;
268 2 Delay(60000);
269 2 Delay(60000);
270 2 Delay(60000);
271 2 }while (1) ;
272 1 }
273
274
275
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 506 ----
CONSTANT SIZE = 192 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 15
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 + -