📄 st7920.lst
字号:
C51 COMPILER V7.09 ST7920 10/09/2004 08:53:13 PAGE 1
C51 COMPILER V7.09, COMPILATION OF MODULE ST7920
OBJECT MODULE PLACED IN ST7920.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE ST7920.c BROWSE DEBUG OBJECTEXTEND
line level source
1 /*
2 File:ST7920.c
3 Autor:rgh111
4 E-mail:rgh111@163.com Provide 8x2 & 7.5x2 Chinese character LCD
5 module,operate either into serial mode or parallel mode.
6 Date:2003.12.23
7 Vesion:1.0
8 Function:
9 Write data or command into the ST7920 in serial mode.
10 ST7920 serial clock max frequency 2.5Mhz.
11 */
12 #include <reg52.h>
13 #include <delay.c>
14 //#include <intrans.h>
15 sbit ST7920_Cs=P1^0;
16 sbit ST7920_Clk=P1^1;
17 sbit ST7920_Sda=P1^2;
18 sbit ST7920_Rst=P1^3;
19 //Command Deifne.
20 //#define C_Clear 0x01
21 //#define C_ResetAddress 0x02
22 //#define C_ResetAddress 0x03
23 //#define C_Location 0x0?
24 //#define C_DisplayOnOff 0x0?
25 //#define C_PromptMove 0x0?
26 //#define C_FunctionSet 0x0?
27 //#define C_SetCgramAddress 0x0?
28 //#define C_SetDdramAddress 0x?
29 //#define C_ReadStatus 0x?
30 //#define C_WriteDataToRam 0x?
31 //#define C_ReadDataFromRam 0x?
32
33 //#define C_Idle 0x01
34 //#define C_ReceiveRollAddress 0x0?
35 //#define C_NagetiveDisplay 0x0?
36 //#define C_SleepWakeUp 0x0?
37 //#define C_ExpandFunctionSet 0x0?
38 //#define C_SetIramAddress 0x0?
39 //#define C_SetGramAddress 0x0?
40 void ResetSt7920(void);
41 void WriteSt7920Instruction(unsigned char x);
42 void WriteSt7920Data(unsigned char x);
43 void ExpandFunctionEnable(void);
44 void ExpandFunctionDisable(void);
45 void ClearScreen(void);
46 void CursorGoHome(void);
47 void DisplayOn(void);
48 void DisplayOff(void);
49 void IdleMode(void);
50 void RollInstructionEnable(void);
51 void RollInstructionDisable(void);
52 void SetRollAddress(unsigned char WhichLine);
53 void SetRollAddress(unsigned char WhichLine);
54 void Sleep(void);
55 void WakeUp(void);
C51 COMPILER V7.09 ST7920 10/09/2004 08:53:13 PAGE 2
56
57 void mian(void)
58 {
59 1 ResetSt7920();
60 1 }
61
62 void ResetSt7920(void)
63 {
64 1 ST7920_Rst=0;
65 1 delay(10);
66 1 ST7920_Rst=1;
67 1 delay(100);
68 1 }
69 void WriteSt7920Instruction(unsigned char x)
70 {
71 1 unsigned char i=0;
72 1
73 1
74 1 ST7920_Cs=1;
75 1
76 1 ST7920_Sda=1;
77 1 for(i=0;i<5;i++)
78 1 {
79 2 ST7920_Clk=0;
80 2 ST7920_Clk=1;
81 2 }
82 1 ST7920_Clk=0;
83 1
84 1 ST7920_Sda=0;
85 1 for(i=0;i<3;i++)
86 1 {
87 2 ST7920_Clk=1;
88 2 ST7920_Clk=0;
89 2 }
90 1
91 1 for(i=0;i<4;i++)
92 1 {
93 2 x<<=1;
94 2 ST7920_Sda=CY;
95 2 ST7920_Clk=1;
96 2 ST7920_Clk=0;
97 2 }
98 1
99 1 ST7920_Sda=0;
100 1 for(i=0;i<4;i++)
101 1 {
102 2 ST7920_Clk=1;
103 2 ST7920_Clk=0;
104 2 }
105 1
106 1 for(i=0;i<4;i++)
107 1 {
108 2 x<<=1;
109 2 ST7920_Sda=CY;
110 2 ST7920_Clk=1;
111 2 ST7920_Clk=0;
112 2 }
113 1
114 1 ST7920_Sda=0;
115 1 for(i=0;i<4;i++)
116 1 {
117 2 ST7920_Clk=1;
C51 COMPILER V7.09 ST7920 10/09/2004 08:53:13 PAGE 3
118 2 ST7920_Clk=0;
119 2 }
120 1
121 1 ST7920_Cs=0;
122 1 delay(1);
123 1 }
124 void WriteSt7920Data(unsigned char x)
125 {
126 1 unsigned char i=0;
127 1
128 1
129 1 ST7920_Cs=1;
130 1
131 1 ST7920_Sda=1;
132 1 for(i=0;i<5;i++)
133 1 {
134 2 ST7920_Clk=0;
135 2 ST7920_Clk=1;
136 2 }
137 1
138 1 ST7920_Clk=0;
139 1 ST7920_Sda=0;
140 1 ST7920_Clk=1;
141 1
142 1 ST7920_Clk=0;
143 1 ST7920_Sda=1;
144 1 ST7920_Clk=1;
145 1
146 1 ST7920_Clk=0;
147 1 ST7920_Sda=0;
148 1 ST7920_Clk=1;
149 1
150 1 ST7920_Clk=0;
151 1 for(i=0;i<4;i++)
152 1 {
153 2 x<<=1;
154 2 ST7920_Sda=CY;
155 2 ST7920_Clk=1;
156 2 ST7920_Clk=0;
157 2 }
158 1
159 1 ST7920_Sda=0;
160 1 for(i=0;i<4;i++)
161 1 {
162 2 ST7920_Clk=0;
163 2 ST7920_Clk=1;
164 2 }
165 1 ST7920_Clk=0;
166 1
167 1 for(i=0;i<4;i++)
168 1 {
169 2 x<<=1;
170 2 ST7920_Sda=CY;
171 2 ST7920_Clk=1;
172 2 ST7920_Clk=0;
173 2 }
174 1
175 1 ST7920_Sda=0;
176 1 for(i=0;i<4;i++)
177 1 {
178 2 ST7920_Clk=1;
179 2 ST7920_Clk=0;
C51 COMPILER V7.09 ST7920 10/09/2004 08:53:13 PAGE 4
180 2 }
181 1
182 1 ST7920_Cs=0;
183 1 delay(1);
184 1 }
185 void ExpandFunctionEnable(void)
186 {
187 1 WriteSt7920Instruction(0x24);
188 1 }
189 void ExpandFunctionDisable(void)
190 {
191 1 WriteSt7920Instruction(0x20);
192 1 }
193 void ClearScreen(void)
194 {
195 1 WriteSt7920Instruction(0x01);
196 1 delay(10);
197 1 }
198 void CursorGoHome(void)
199 {
200 1 WriteSt7920Instruction(0x02);
201 1 //WriteSt7920Instruction(0x03);
202 1 }
203 void DisplayOn(void)
204 {
205 1 WriteSt7920Instruction(0x0d);
206 1 }
207 void DisplayOff(void)
208 {
209 1 WriteSt7920Instruction(0x09);
210 1 }
211 void IdleMode(void)
212 {
213 1 WriteSt7920Instruction(0x01);
214 1 }
215 void RollInstructionEnable(void)
216 {
217 1 WriteSt7920Instruction(0x03);
218 1 }
219 void RollInstructionDisable(void)
220 {
221 1 WriteSt7920Instruction(0x02);
222 1 }
223 void SetRollAddress(unsigned char WhichLine)
224 {
225 1 ExpandFunctionEnable();
226 1 RollInstructionEnable();
227 1 WriteSt7920Instruction(WhichLine|0x40);
228 1 ExpandFunctionDisable();
229 1 }
230 /*
231 void NegativeDisplay(unsigned char WhichLine)
232 Function:
233 Expand instruction.
234 WhichLine=1,2,3,4.
235 */
236 void NegativeDisplay(unsigned char WhichLine)
237 {
238 1 if(WhichLine>4) return;
239 1 if(WhichLine==0) return;
240 1 WriteSt7920Instruction((WhichLine-1)|0x04);
241 1 }
C51 COMPILER V7.09 ST7920 10/09/2004 08:53:13 PAGE 5
242 void Sleep(void)
243 {
244 1 WriteSt7920Instruction(0x08);
245 1 }
246 void WakeUp(void)
247 {
248 1 WriteSt7920Instruction(0x0c);
249 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 335 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
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 + -