📄 yanjing12864new.lst
字号:
C51 COMPILER V7.06 YANJING12864NEW 01/08/2007 16:58:20 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE YANJING12864NEW
OBJECT MODULE PLACED IN yanjing12864new.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE yanjing12864new.c OPTIMIZE(4,SPEED) BROWSE DEBUG OBJECTEXTEND
stmt level source
1 /*128*64液晶模块驱动程序 ,HD61202驱动
2 创建时间:07.1.6
3 功能描述:循环显示李白的诗歌共8行,指定反白显示*/
4 #include <at89x51.h>
5 //#include <intrins.h>
6 #define uchar unsigned char
7 #define uint unsigned int
8 #define lcm P1
9 sbit p_csl=P2^4;
10 sbit p_csr=P2^3;
11 sbit p_di=P2^2;
12 sbit p_rw=P2^1;
13 sbit p_e=P2^0;
14 sbit p_rst=P2^7;
15 uchar code HZ[];
16 uchar code Ez[];
17 /*****函数声明********/
18 void delay(uint k);
19 void wcode(uchar c,uchar csl,uchar csr);
20 void wdata(uchar c,uchar csl,uchar csr);
21 void set_statrline(uchar i);
22 void set_xy(uchar x,uchar y);
23 void dison_off(uchar o);
24 void reset();
25 void lcd_init(void);
26 void lw(uchar x,uchar y,uchar dd);//写数据函数
27 void disp_Hz(uchar xx,uchar yy,uchar n,uchar fb);//显示汉字
28 void disp_Ez(uchar xx,uchar yy,uchar n,uchar fb);
29
30 //延时
31 void delay(uint k)
32 { uint i;
33 1 for(;k>0;k--)
34 1 { for(i=0;i<124;i++)
35 2 {;}
36 2 }
37 1 }
38
39 //
40
41
42 //LCM忙判断
43 void lcd_busy(void)
44 { p_di=0;
45 1 p_rw=1;
46 1 /*lcm=0xff;
47 1 while(1)
48 1 { p_e=1;
49 1 if(lcm<0x80)
50 1 break;
51 1 p_e=0;
52 1 }
53 1 p_e=0;*/
54 1 }
55 //写指令到LCM
C51 COMPILER V7.06 YANJING12864NEW 01/08/2007 16:58:20 PAGE 2
56 void wcode(uchar c,uchar csl,uchar csr)
57 { p_csl=csl;
58 1 p_csr=csr;
59 1 lcd_busy();
60 1 p_di=0;
61 1 p_rw=0;
62 1 lcm=c;//将变量C赋予LCM
63 1 p_e=1;
64 1 p_e=0;
65 1 }
66 //写数据到LCM子函数
67 void wdata(uchar c,uchar csl,uchar csr)
68 { p_csl=csl;
69 1 p_csr=csr;
70 1 lcd_busy();
71 1 p_di=1;
72 1 p_rw=0;
73 1 lcm=c;//将变量C赋予LCM
74 1 p_e=1;
75 1 p_e=0;
76 1 }
77 //设定起始行
78 void set_startline(uchar i)
79 { i=0xc0+i;
80 1 wcode(i,1,1);
81 1 }
82 //定位X方向,Y方向
83 void set_xy(uchar x,uchar y)
84 { x=x+0x40;
85 1 y=y+0xb8;
86 1 wcode(x,1,1);
87 1 wcode(y,1,1);
88 1 }
89 //屏幕开启、关闭
90 void dison_off(uchar o)
91 { o=o+0x3e; //o为1为开,为0是关
92 1 wcode(o,1,1);
93 1 }
94 //复位子函数
95 void reset()
96 {//delay(1000);
97 1 p_rst=0;
98 1 delay(20);
99 1 p_rst=1;
100 1 delay(20);
101 1 }
102 //LCM初始化
103 void lcd_init(void)
104 { uchar x,y;
105 1 reset();
106 1
107 1 dison_off(0);
108 1 for(y=0;y<8;y++)
109 1 { for(x=0;x<128;x++)
110 2 lw(x,y,0);
111 2 }
112 1 dison_off(1);
113 1 set_startline(0);
114 1 }
115 //写数据到LCM
116 void lw(uchar x,uchar y,uchar dd)
117 { if(x>=64)
C51 COMPILER V7.06 YANJING12864NEW 01/08/2007 16:58:20 PAGE 3
118 1 { set_xy(x-64,y);
119 2 wdata(dd,0,1);
120 2 }
121 1 else
122 1 { set_xy(x,y);
123 2 wdata(dd,1,0);
124 2 }
125 1 }
126 //显示汉字子函数
127 void disp_Hz(uchar xx,uchar yy,uchar n,uchar fb)//xx为该行第xx个字,共8字,yy为第几行,共8行。
128 { uchar i,dx;
129 1
130 1 for(i=0;i<16;i++)
131 1 { dx=HZ[2*i+n*32]; //2*i为选择偶数行,因其为列扫描
132 2 if(fb)
133 2 dx=255-dx;//反白显示
134 2 lw(xx*16+i,yy,dx);
135 2 dx=HZ[(2*i+1)+n*32];
136 2 if(fb)
137 2 dx=255-dx;
138 2 lw(xx*16+i,yy+1,dx);
139 2 }
140 1 }
141 void disp_Ez(uchar xx,uchar yy,uchar n,uchar fb)//显示数字或英语
142 { uchar i,dx;
143 1 for(i=0;i<8;i++)
144 1 { dx=Ez[2*i+n*16];
145 2 if(fb)
146 2 dx=255-dx;
147 2 lw(xx*8+i,yy,dx);//
148 2
149 2 dx=Ez[(2*i+1)+n*16];
150 2 if(fb)
151 2 dx=255-dx;
152 2 lw(xx*8+i,yy+1,dx);
153 2 }
154 1 }
155
156 /*****主函数****/
157 void main()
158 { uchar loop,i,y;//
159 1 uchar fb;
160 1 lcd_init();
161 1 delay(300);
162 1 for(loop=0;loop<2;loop++)//菜单
163 1 {
164 2 disp_Hz(loop+1,0,loop+64,1);
165 2 disp_Ez(13,0,10,0);
166 2 disp_Ez(14,0,8,0);
167 2 }
168 1 while(1)
169 1 {for(i=0;i<8;i++)
170 2 { disp_Ez(12,0,i+1,0);
171 3 if(i<3)
172 3 { if(i!=0)fb=0;
173 4 else fb=1;
174 4 for(loop=0;loop<8;loop++)//行1
175 4 { disp_Hz(loop,2,loop,fb);
176 5 }
177 4 }
178 3 if(i<4)
179 3 { if(i!=1)fb=0;
C51 COMPILER V7.06 YANJING12864NEW 01/08/2007 16:58:20 PAGE 4
180 4 else fb=1;
181 4 if(i==3)y=2;
182 4 else y=4;
183 4 for(loop=0;loop<8;loop++)//2
184 4 {
185 5 disp_Hz(loop,y,loop+8,fb);
186 5 } }
187 3 if(i<5)
188 3 { if(i!=2)fb=0;
189 4 else fb=1;
190 4 if((i==0)||(i==1)||(i==2))
191 4 y=6;
192 4 if(i==3)y=4;
193 4 if(i==4)y=2;
194 4 for(loop=0;loop<8;loop++)//3
195 4 {
196 5 disp_Hz(loop,y,loop+16,fb);//第一屏结束,每屏显示3行
197 5 }
198 4 }
199 3 if(i>=3)
200 3 { if(i!=3)fb=0;
201 4 else fb=1;//
202 4
203 4 if(i==3)y=6;
204 4 if(i==4)y=4;
205 4 if(i==5)y=2;
206 4 for(loop=0;loop<8;loop++)//行4
207 4 { disp_Hz(loop,y,loop+24,fb);
208 5 }
209 4 }
210 3 if(i>=4)
211 3 { if(i!=4)fb=0;
212 4 else fb=1;//
213 4
214 4 if(i==4)y=6;
215 4 if(i==5)y=4;
216 4 if(i==6)y=2;
217 4 for(loop=0;loop<8;loop++)//5
218 4 {
219 5 disp_Hz(loop,y,loop+32,fb);//y=1时
220 5 } }
221 3 if(i>=5)
222 3 { if(i!=5)fb=0;
223 4 else fb=1;
224 4
225 4 if(i==5)y=6;
226 4 if(i==6)y=4;
227 4 if(i==7)y=2;
228 4 for(loop=0;loop<8;loop++)//6
229 4 {
230 5 disp_Hz(loop,y,loop+40,fb);
231 5 }
232 4 }
233 3 if(i>=6)
234 3 { if(i!=6)fb=0;
235 4 else fb=1;
236 4 if(i==6)y=6;
237 4 if(i==7)y=4;
238 4 for(loop=0;loop<8;loop++)//行7
239 4 {disp_Hz(loop,y,loop+48,fb);
240 5 }
241 4 }
C51 COMPILER V7.06 YANJING12864NEW 01/08/2007 16:58:20 PAGE 5
242 3 if(i==7)
243 3 { if(i!=7)fb=0;
244 4 else fb=1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -