?? 12864_serial.lst
字號(hào):
C51 COMPILER V7.10 12864_SERIAL 08/17/2007 18:41:25 PAGE 1
C51 COMPILER V7.10, COMPILATION OF MODULE 12864_SERIAL
OBJECT MODULE PLACED IN 12864_serial.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE 12864_serial.c BROWSE DEBUG OBJECTEXTEND
line level source
1
2
3 /******************************************************/
4 #include<reg52.h>
5 #include <intrins.h>
6 #include"12864_serial.h"
7
8
9
10
11
12 #define uint unsigned int
13 #define uchar unsigned char
14 unsigned char ChangeAddress(unsigned char StartAddress);
15 void WriteLCD(unsigned char StartAddress,unsigned char Charactors[]);
16
17
18
19
20
21 void delay_1ms(uint x)
22 {
23 1 uint j;
24 1 uchar i;
25 1 for(j=0;j<x;j++)
26 1 {
27 2 for(i=0;i<120;i++);
28 2 }
29 1 }
30
31
32
33 void send_command(uchar command_data)
34 {
35 1 uchar i;
36 1 uchar i_data,temp_data1,temp_data2;
37 1 i_data=0xf8;
38 1 delay_1ms(10);
39 1 cs=1;
40 1 sclk=0;
41 1 for(i=0;i<8;i++)
42 1 {
43 2 sid=(bit)(i_data&0x80);
44 2 sclk=0;
45 2 sclk=1;
46 2 i_data=i_data<<1;
47 2 }
48 1 i_data=command_data;
49 1 i_data&=0xf0;
50 1 for(i=0;i<8;i++)
51 1 {
52 2 sid=(bit)(i_data&0x80);
53 2 sclk=0;
54 2 sclk=1;
55 2 i_data=i_data<<1;
C51 COMPILER V7.10 12864_SERIAL 08/17/2007 18:41:25 PAGE 2
56 2 }
57 1 i_data=command_data;
58 1 temp_data1=i_data&0xf0;
59 1 temp_data2=i_data&0x0f;
60 1 temp_data1>>=4;
61 1 temp_data2<<=4;
62 1 i_data=temp_data1|temp_data2;
63 1 i_data&=0xf0;
64 1 for(i=0;i<8;i++)
65 1 {
66 2 sid=(bit)(i_data&0x80);
67 2 sclk=0;
68 2 sclk=1;
69 2 i_data=i_data<<1;
70 2 }
71 1 cs=0;
72 1 }
73
74 void send_data(uchar command_data)
75 {
76 1 uchar i;
77 1 uchar i_data,temp_data1,temp_data2;
78 1 i_data=0xfa;
79 1 delay_1ms(10);
80 1 cs=1;
81 1 for(i=0;i<8;i++)
82 1 {
83 2 sid=(bit)(i_data&0x80);
84 2 sclk=0;
85 2 sclk=1;
86 2 i_data=i_data<<1;
87 2 }
88 1 i_data=command_data;
89 1 i_data&=0xf0;
90 1 for(i=0;i<8;i++)
91 1 {
92 2 sid=(bit)(i_data&0x80);
93 2 sclk=0;
94 2 sclk=1;
95 2 i_data=i_data<<1;
96 2 }
97 1 i_data=command_data;
98 1 temp_data1=i_data&0xf0;
99 1 temp_data2=i_data&0x0f;
100 1 temp_data1>>=4;
101 1 temp_data2<<=4;
102 1 i_data=temp_data1|temp_data2;
103 1 i_data&=0xf0;
104 1 for(i=0;i<8;i++)
105 1 {
106 2 sid=(bit)(i_data&0x80);
107 2 sclk=0;
108 2 sclk=1;
109 2 i_data=i_data<<1;
110 2 }
111 1 cs=0;
112 1 }
113
114
115
116 void lcd_init()
117 {
C51 COMPILER V7.10 12864_SERIAL 08/17/2007 18:41:25 PAGE 3
118 1 uchar command_data;
119 1 //psb=0;
120 1 delay_1ms(100);
121 1 command_data=0x30;
122 1 send_command(command_data); /*功能設(shè)置:一次送8位數(shù)據(jù),基本指令集*/
123 1 command_data=0x04;
124 1 send_command(command_data); /*點(diǎn)設(shè)定:顯示字符/光標(biāo)從左到右移位,DDRAM地址加1*/
125 1 command_data=0x0c;
126 1 send_command(command_data); /*顯示設(shè)定:開(kāi)顯示,不顯示顯示光標(biāo),當(dāng)前顯示位不反白閃動(dòng)*/
127 1 command_data=0x01;
128 1 send_command(command_data); /*清DDRAM*/
129 1 command_data=0x02;
130 1 send_command(command_data); /*DDRAM地址歸位*/
131 1 command_data=0x80;
132 1 send_command(command_data); /*把顯示地址設(shè)為0X80,即為第一行的首位*/
133 1 }
134
135 void welcome()
136 { uchar i,j;
137 1 send_command(0x01);
138 1 delay_1ms(50);
139 1 WriteLCD(0x82,"歡迎使用");
140 1 WriteLCD(0x92,"Welcome ");
141 1 WriteLCD(0x89,"Waiting.");
142 1
143 1 for(j=0;j<=1;j++)
144 1 {
145 2 send_command(0x8d);
146 2 send_data(0x20);
147 2 send_data(0x20);
148 2 send_data(0x20);
149 2 send_data(0x20);
150 2 send_data(0x20);
151 2 send_command(0x8d);
152 2 for(i=0;i<=4;i++)
153 2 {
154 3 send_data(0x2e);
155 3 delay_1ms(1000);
156 3 }
157 2 }
158 1 }
159
160 void WriteLCD(unsigned char StartAddress,unsigned char Charactors[])
161 {
162 1 unsigned char *i=Charactors; //字符串的首地址
163 1 send_command(StartAddress);
164 1 while(*i) //判斷字符串結(jié)尾,*i為0代表結(jié)束
165 1 {
166 2 send_data(*i);
167 2 i++;
168 2 if(*i=='\0')
169 2 break;
170 2 send_data(*i);
171 2 i++;
172 2 StartAddress=ChangeAddress(StartAddress);
173 2 }
174 1 }
175
176 unsigned char ChangeAddress(unsigned char StartAddress)
177 {
178 1 switch(StartAddress)
179 1 {
C51 COMPILER V7.10 12864_SERIAL 08/17/2007 18:41:25 PAGE 4
180 2 case 0x87:send_command(0x90);StartAddress=0x90;break;
181 2 case 0x8F:send_command(0x98);StartAddress=0x98;break;
182 2 case 0x97:send_command(0x88);StartAddress=0x88;break;
183 2 default:StartAddress+=1;
184 2 }
185 1 return StartAddress;
186 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 479 ----
CONSTANT SIZE = 27 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 6
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -