📄 lcd_test.lst
字号:
C51 COMPILER V7.50 LCD_TEST 08/17/2007 10:27:18 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE LCD_TEST
OBJECT MODULE PLACED IN LCD_test.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE LCD_test.c BROWSE DEBUG OBJECTEXTEND
line level source
1 /******************************************************/
2 /*作者:赖卫国 email:laiweiguo@163.com */
3 /* */
4 /* 12232F串口驱动程序C51,11.0592M晶振 */
5 /*使用这款LCD应该要注意的问题: */
6 /*一定要在VO与VDD及VSS这三个脚间接一个20K的电位器, */
7 /*电位器的中间脚接VO,其它二脚接VDD和VSS。 */
8 /*然后调节电位器的大小,直到有显示为止。若是不接的话,*/
9 /*显示器可能是一片黑暗,什么也没有显示,发命令也没有反*/
10 /*应的。本程序我已经测试通过了。欢迎大家提出意见。 */
11 /******************************************************/
12 #include <reg51.h>
13 #include <intrins.h>
14 #define uint unsigned int
15 #define uchar unsigned char
16
17
18
19 /*12232f pins define*/
20 sbit CS=P1^5;
21 sbit SID=P1^6;
22 sbit SCLK=P1^7;
23
24
25
26 void delay_1ms(uint x)
27 {
28 1 uint j;
29 1 uchar i;
30 1 for(j=0;j<x;j++)
31 1 {
32 2 for(i=0;i<120;i++);
33 2 }
34 1 }
35
36
37
38 void send_command(uchar command_data)
39 {
40 1 uchar i;
41 1 uchar i_data,temp_data1,temp_data2;
42 1 i_data=0xf8;
43 1 delay_1ms(10);
44 1 CS=1;
45 1 SCLK=0;
46 1 for(i=0;i<8;i++)
47 1 {
48 2 SID=(bit)(i_data&0x80);
49 2 SCLK=0;
50 2 SCLK=1;
51 2 i_data=i_data<<1;
52 2 }
53 1 i_data=command_data;
54 1 i_data&=0xf0;
55 1 for(i=0;i<8;i++)
C51 COMPILER V7.50 LCD_TEST 08/17/2007 10:27:18 PAGE 2
56 1 {
57 2 SID=(bit)(i_data&0x80);
58 2 SCLK=0;
59 2 SCLK=1;
60 2 i_data=i_data<<1;
61 2 }
62 1 i_data=command_data;
63 1 temp_data1=i_data&0xf0;
64 1 temp_data2=i_data&0x0f;
65 1 temp_data1>>=4;
66 1 temp_data2<<=4;
67 1 i_data=temp_data1|temp_data2;
68 1 i_data&=0xf0;
69 1 for(i=0;i<8;i++)
70 1 {
71 2 SID=(bit)(i_data&0x80);
72 2 SCLK=0;
73 2 SCLK=1;
74 2 i_data=i_data<<1;
75 2 }
76 1 CS=0;
77 1 }
78
79 void send_data(uchar command_data)
80 {
81 1 uchar i;
82 1 uchar i_data,temp_data1,temp_data2;
83 1 i_data=0xfa;
84 1 delay_1ms(10);
85 1 CS=1;
86 1 for(i=0;i<8;i++)
87 1 {
88 2 SID=(bit)(i_data&0x80);
89 2 SCLK=0;
90 2 SCLK=1;
91 2 i_data=i_data<<1;
92 2 }
93 1 i_data=command_data;
94 1 i_data&=0xf0;
95 1 for(i=0;i<8;i++)
96 1 {
97 2 SID=(bit)(i_data&0x80);
98 2 SCLK=0;
99 2 SCLK=1;
100 2 i_data=i_data<<1;
101 2 }
102 1 i_data=command_data;
103 1 temp_data1=i_data&0xf0;
104 1 temp_data2=i_data&0x0f;
105 1 temp_data1>>=4;
106 1 temp_data2<<=4;
107 1 i_data=temp_data1|temp_data2;
108 1 i_data&=0xf0;
109 1 for(i=0;i<8;i++)
110 1 {
111 2 SID=(bit)(i_data&0x80);
112 2 SCLK=0;
113 2 SCLK=1;
114 2 i_data=i_data<<1;
115 2 }
116 1 CS=0;
117 1 }
C51 COMPILER V7.50 LCD_TEST 08/17/2007 10:27:18 PAGE 3
118
119
120
121 void lcd_init()
122 {
123 1 uchar command_data;
124 1 delay_1ms(100);
125 1 command_data=0x30;
126 1 send_command(command_data); /*功能设置:一次送8位数据,基本指令集*/
127 1 command_data=0x04;
128 1 send_command(command_data); /*点设定:显示字符/光标从左到右移位,DDRAM地址加1*/
129 1 command_data=0x0f;
130 1 send_command(command_data); /*显示设定:开显示,显示光标,当前显示位反白闪动*/
131 1 command_data=0x01;
132 1 send_command(command_data); /*清DDRAM*/
133 1 command_data=0x02;
134 1 send_command(command_data); /*DDRAM地址归位*/
135 1 command_data=0x80;
136 1 send_command(command_data); /*把显示地址设为0X80,即为第一行的首位*/
137 1 }
138
139
140
141 void display_cpubbs()
142 {
143 1 uchar command_data;
144 1 while(1)
145 1 {
146 2 command_data=0x01;
147 2 send_command(command_data); /*清DDRAM*/
148 2 command_data=0x80;
149 2 send_command(command_data); /*把显示地址设为0X80,即为第一行的首位*/
150 2 command_data=0x68; /*“h”字的编码*/
151 2 send_data(command_data);
152 2 command_data=0x74;
153 2 send_data(command_data); /*“t”字的编码*/
154 2 command_data=0x74;
155 2 send_data(command_data); /*“t”字的编码*/
156 2 command_data=0x70;
157 2 send_data(command_data); /*“p”字的编码*/
158 2 command_data=0x3a;
159 2 send_data(command_data); /*“:”字的编码*/
160 2 command_data=0x2f;
161 2 send_data(command_data); /*“/”字的编码*/
162 2 command_data=0x2f;
163 2 send_data(command_data); /*“/”字的编码*/
164 2 command_data=0x57;
165 2 send_data(command_data); /*“w”字的编码*/
166 2 command_data=0x57;
167 2 send_data(command_data); /*“w”字的编码*/
168 2 command_data=0x57;
169 2 send_data(command_data); /*“w”字的编码*/
170 2 command_data=0x2e;
171 2 send_data(command_data); /*“.”字的编码*/
172 2 command_data=0x63;
173 2 send_data(command_data); /*“c”字的编码*/
174 2 command_data=0x70;
175 2 send_data(command_data); /*“p”字的编码*/
176 2 command_data=0x75;
177 2 send_data(command_data); /*“u”字的编码*/
178 2 command_data=0x62;
179 2 send_data(command_data); /*“b”字的编码*/
C51 COMPILER V7.50 LCD_TEST 08/17/2007 10:27:18 PAGE 4
180 2
181 2 command_data=0x90;
182 2 send_command(command_data); /*把显示地址设为0X90,即为第二行的首位,因为第一行已经满了*/
183 2 command_data=0x62;
184 2 send_data(command_data); /*“b”字的编码*/
185 2 command_data=0x73;
186 2 send_data(command_data); /*“s”字的编码*/
187 2 command_data=0x2e;
188 2 send_data(command_data); /*“.”字的编码*/
189 2 command_data=0x63;
190 2 send_data(command_data); /*“c”字的编码*/
191 2 command_data=0x6f;
192 2 send_data(command_data); /*“o”字的编码*/
193 2 command_data=0x6d;
194 2 send_data(command_data); /*“m”字的编码*/
195 2
196 2 delay_1ms(3000);
197 2
198 2 command_data=0x01;
199 2 send_command(command_data); /*清DDRAM*/
200 2 command_data=0x80;
201 2 send_command(command_data); /*把显示地址设为0X80,即为第一行的首位*/
202 2
203 2 command_data=0xbb;
204 2 send_data(command_data);
205 2 command_data=0xb6;
206 2 send_data(command_data); /*“欢”字的编码*/
207 2 command_data=0xd3;
208 2 send_data(command_data);
209 2 command_data=0xad;
210 2 send_data(command_data); /*“迎”字的编码*/
211 2 command_data=0xb7;
212 2 send_data(command_data);
213 2 command_data=0xc3;
214 2 send_data(command_data); /*“访”字的编码*/
215 2 command_data=0xce;
216 2 send_data(command_data);
217 2 command_data=0xca;
218 2 send_data(command_data); /*“问”字的编码*/
219 2 command_data=0x90;
220 2 send_command(command_data); /*把显示地址设为0X90,即为第二行的首位,因为第一行已经满了*/
221 2 command_data=0x63;
222 2 send_data(command_data); /*“c”字的编码*/
223 2 command_data=0x70;
224 2 send_data(command_data); /*“p”字的编码*
225 2 command_data=0x75;
226 2 send_data(command_data); /*“u”字的编码*/
227 2 command_data=0x62;
228 2 send_data(command_data); /*“b”字的编码*/
229 2 command_data=0x62;
230 2 send_data(command_data); /*“b”字的编码*/
231 2 command_data=0x73;
232 2 send_data(command_data); /*“s”字的编码*/
233 2 command_data=0xc2;
234 2 send_data(command_data);
235 2 command_data=0xdb;
236 2 send_data(command_data); /*“论”字的编码*/
237 2 command_data=0xcc;
238 2 send_data(command_data);
239 2 command_data=0xb3;
240 2 send_data(command_data); /*“坛”字的编码*/
241 2 delay_1ms(3000);
C51 COMPILER V7.50 LCD_TEST 08/17/2007 10:27:18 PAGE 5
242 2 }
243 1 }
244
245
246
247 main()
248 {
249 1 //unsigned char command_data;
250 1 lcd_init();
251 1 display_cpubbs();
252 1 while(1);
253 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 596 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 1
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -