?? 12232.lst
字號:
C51 COMPILER V7.09 12232 03/11/2004 16:59:54 PAGE 1
C51 COMPILER V7.09, COMPILATION OF MODULE 12232
OBJECT MODULE PLACED IN 12232.OBJ
COMPILER INVOKED BY: C:\KEIL\C51\BIN\C51.EXE 12232.c BROWSE DEBUG OBJECTEXTEND
line level source
1 /*============================================================
2 功能:使用12232液晶顯示圖片演示
3 作者: Mingtree ycxms88@163.com http://www.mcu123.com
4 ==============================================================
5 硬件:TG12232B (122*32)模擬口線接線方式
6 連接線圖:
7 --------------------------------------------------|
8 |DB0-----P0.0 | DB4-----P0.4 | RW-------P1.1 | A0--------P1.0 |
9 |DB1-----P0.1 | DB5-----P0.5 | RS-------P2.1 | V0接1K電阻到GND |
10 |DB2-----P0.2 | DB6-----P0.6 | E1-------P1.3 |
11 |DB3-----P0.3 | DB7-----P0.7 | E2-------P1.2 |
12 ---------------------------------------------------
13
14 本程序源碼只供學習參考,如有需要請聯(lián)系作者。
15
16 [注:AT89x52使用22.1184M或11.0592M晶振,實測使用22.1184M或11.0592都可以]
17 編譯平臺:Keil uV2 7.08
18
19
20 //可能看起來有點亂,不過效果還是不錯的,顯示圖形總的來說比顯示漢字要簡單,當然顯示漢字也不難。
21 希望此程序能給你一些幫助。
22 有什么問題可以發(fā)email 給我或到我的論壇發(fā)問.
23 http://www.mcu123.com/bbs
24 =============================================================*/
25
26
27 #include <AT89X52.H>
28
29 #define uchar unsigned char
30 #define uint unsigned int
31
32 #define E1 P1_3 //塊1 左邊
33 #define E2 P1_2 //塊2 右邊
34 #define RW P1_1
35 #define A0 P1_0 //A0為1時是數(shù)據(jù),0時為指令數(shù)據(jù)
36 #define DATA P0 //數(shù)據(jù)
37
38 extern unsigned char code Bmpt1[];
39 extern unsigned char code Bmpt2[];
40 extern unsigned char code Bmpt3[];
41 extern unsigned char code Bmpt4[];
42 extern unsigned char code Bmpt5[];
43 extern unsigned char code Bmpt6[];
44 extern unsigned char code Bmpt7[];
45 extern unsigned char code Bmptc[];
46 extern unsigned char code bmp001[];
47 extern unsigned char code Bmp08[];
48 extern unsigned char code Bmp07[];
49 extern unsigned char code Bmp06[];
50 extern unsigned char code Bmp05[];
51 extern unsigned char code Bmp04[];
52 extern unsigned char code Bmp03[];
53 extern unsigned char code Bmp02[];
54 extern unsigned char code Bmp01[];
55 extern unsigned char code Bmp012[];
C51 COMPILER V7.09 12232 03/11/2004 16:59:54 PAGE 2
56 extern unsigned char code Bmp003[];
57 extern unsigned char code Bmp002[];
58
59
60 //延時
61 void delay(unsigned int i)
62 {
63 1 unsigned char k=200;
64 1 while(i>0)
65 1 {
66 2 i--;
67 2 }
68 1 while(k>1)k--;
69 1 }
70
71 //左頁
72 //發(fā)送數(shù)據(jù)
73 void OUTMD(unsigned char i)
74 {
75 1 A0=1; //寫數(shù)據(jù)
76 1 //delay(5);
77 1 E1=1;
78 1 //delay(10);
79 1 DATA=i;
80 1 //delay(5);
81 1 E1=0;
82 1
83 1 }
84 //左頁
85 //發(fā)送命令
86 void OUTMI(unsigned char i)
87 {
88 1 A0=0; //寫指令
89 1 //delay(5);
90 1 E1=1;
91 1 //delay(10);
92 1 DATA=i;
93 1 //delay(5);
94 1 E1=0;
95 1
96 1 }
97 //右頁
98 //發(fā)送數(shù)據(jù)
99 void OUTSD(unsigned char i)
100 {
101 1 A0=1; //寫數(shù)據(jù)
102 1 //delay(5);
103 1 E2=1;
104 1 //delay(10);
105 1 DATA=i;
106 1 //delay(5);
107 1 E2=0;
108 1
109 1 }
110 //右頁
111 //發(fā)送命令
112 void OUTSI(unsigned char i)
113 {
114 1 A0=0; //寫指令
115 1 //delay(5);
116 1 E2=1;
117 1 //delay(10);
C51 COMPILER V7.09 12232 03/11/2004 16:59:54 PAGE 3
118 1 DATA=i;
119 1 //delay(5);
120 1 E2=0;
121 1
122 1 }
123
124
125
126 //初始化
127 void lcdini(void)
128 {
129 1 RW=0;
130 1 OUTMI(0XE2);
131 1 OUTSI(0XE2);//復位
132 1 OUTMI(0XAE);
133 1 OUTSI(0XAE);//POWER SAVE
134 1 OUTMI(0XA4);
135 1 OUTSI(0XA4);//動態(tài)驅動
136 1 OUTMI(0XA9);
137 1 OUTSI(0XA9);//1/32占空比
138 1 OUTMI(0XA0);
139 1 OUTSI(0XA0);//時鐘線輸出
140 1 OUTMI(0XEE);
141 1 OUTSI(0XEE);//寫模式
142 1
143 1 OUTMI(0X00);
144 1 OUTMI(0XC0);
145 1 OUTSI(0X00);
146 1 OUTSI(0XC0);
147 1
148 1 OUTMI(0XAF);
149 1 OUTSI(0XAF);
150 1
151 1 }
152 /*
153 函數(shù)說明:同時設置主從顯示頁為0-3頁。(內函數(shù),私有,用戶不直接調用)
154 ------------------------------------------------------------------------
155 */
156 void SetPage(uchar page0,uchar page1)
157 {
158 1 OUTMI(0xB8|page1);OUTSI(0xB8|page0);
159 1 }
160
161 /*
162 --------------------------------------------------------------------------------
163 函數(shù)說明:同時設置主從列地址為0-121。(內函數(shù),私有,用戶不直接調用)
164 --------------------------------------------------------------------------------
165 */
166 void SetAddress(uchar address0,uchar address1)
167 {
168 1 OUTMI(address1);OUTSI(address0);
169 1 }
170
171 /*
172 --------------------------------------------------------------------------------
173
174 調用方式:void PutChar0(uchar ch)
175 函數(shù)說明:在右頁當前地址畫一個字節(jié)8個點。(內函數(shù),私有,用戶不直接調用)
176 --------------------------------------------------------------------------------
177 -*/
178 void PutCharR(uchar ch)
179 {
C51 COMPILER V7.09 12232 03/11/2004 16:59:54 PAGE 4
180 1 OUTSD(ch);
181 1 }
182
183 /*
184 --------------------------------------------------------------------------------
185
186 調用方式:void PutChar1(uchar ch)
187 函數(shù)說明:在左頁當前地址畫一個字節(jié)8個點。(內函數(shù),私有,用戶不直接調用)
188 --------------------------------------------------------------------------------
189 -*/
190 void PutCharL(uchar ch)
191 {
192 1 OUTMD(ch);
193 1 }
194
195 /*
196 --------------------------------------------------------------------------------
197
198 調用方式:void DrawBmp(bit layer,uchar width,uchar *bmp)
199 函數(shù)說明:畫一個圖,layer表示上下層,width是圖形的寬,高都是16,bmp是
200 圖形指針
201 使用zimo3軟件,縱向取模,字節(jié)倒序/240字節(jié)
202 --------------------------------------------------------------------------------
203 -*/
204 void DrawBmp(bit layer,uchar width,uchar *bmp)
205 {
206 1 uchar x,address,i=0; //address表示顯存的物理地址
207 1 uchar page=0; //page表示上下兩頁
208 1 bit window=0; //window表示左右兩頁
209 1 //putcharR //右邊
210 1 //putcharL //左邊
211 1
212 1 for (x=width;x>1;x--)
213 1 {
214 2 if (i>60) {window=1;address=i%61;}
215 2 else address=i;
216 2
217 2 if(layer==0) //顯示一行八個字
218 2 {
219 3 SetPage(0,0);
220 3 SetAddress(address,address);
221 3 if(window==1)PutCharR(bmp[i]);
222 3 else PutCharL(bmp[i]);
223 3 SetPage(1,1);
224 3 SetAddress(address,address);
225 3 if(window==1)PutCharR(bmp[i+width]);
226 3 else PutCharL(bmp[i+width]);
227 3 }
228 2 else
229 2 { //顯示第二行八個漢字
230 3 SetPage(2,2);
231 3 SetAddress(address,address);
232 3 if(window==1)PutCharR(bmp[i]);
233 3 else PutCharL(bmp[i]);
234 3 SetPage(3,3);
235 3 SetAddress(address,address);
236 3 if(window==1)PutCharR(bmp[i+width]);
237 3 else PutCharL(bmp[i+width]);
238 3 }
239 2 i++;
240 2
241 2 }
C51 COMPILER V7.09 12232 03/11/2004 16:59:54 PAGE 5
242 1 }
243
244
245 /*
246 --------------------------------------------------------------------------------
247
248 調用方式:void clrscr(void)
249 函數(shù)說明:清屏
250 --------------------------------------------------------------------------------
251 -*/
252 void clrscr(void)
253 {
254 1 uchar i;
255 1 uchar page;
256 1 for (page=0;page<4;page++)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -