📄 fyd12864.lst
字号:
C51 COMPILER V7.09 FYD12864 08/24/2007 09:30:56 PAGE 1
C51 COMPILER V7.09, COMPILATION OF MODULE FYD12864
OBJECT MODULE PLACED IN FYD12864.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE FYD12864.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include <reg51.h>
2 #include "FYD12864.h"
3
4 //IO输入输出控制
5 void InitP0(bit i)
6 {
7 1 if(i==1) P0 = 0xff;
8 1 else P0 = 0x00;
9 1 }
10
11 //短延时函数:ShortDelay()
12 void ShortDelay(uchar i)
13 {
14 1 for(;i>0;i--) ;
15 1 }
16
17 //长延时函数:LongDelay()
18 void LongDelay(uint i)
19 {
20 1 uint j;
21 1 for(;i>0;i--)
22 1 { for(j=1000;j>0;j--);}
23 1 }
24
25 //指令/数据选择函数:SetLCD_RS()
26 void SetLCD_RS(bit i)
27 {
28 1 if(i==1) PinRS = 1;
29 1 else PinRS = 0;
30 1 }
31
32 //读写操作控制信号:SetLCD_RW()
33 void SetLCD_RW(bit i)
34 {
35 1 if(i==1) PinRW = 1;
36 1 else PinRW = 0;
37 1 }
38
39 //使能信号:SetLCD_EN()
40 void SetLCD_EN(bit i)
41 {
42 1 if(i==1) PinE = 1;
43 1 else PinE = 0;
44 1 }
45
46 //复位:SetLCD_RST()
47 void SetLCD_RST(bit i)
48 {
49 1 if(i==1) PinRST = 1;
50 1 else PinRST = 0;
51 1 }
52
53 //读状态函数:ReadStatus()
54 uchar ReadStatus(void)
55 {
C51 COMPILER V7.09 FYD12864 08/24/2007 09:30:56 PAGE 2
56 1 uchar i;
57 1 InitP0(1);
58 1 SetLCD_RW(1);
59 1 SetLCD_RS(0);
60 1 SetLCD_EN(0);
61 1 ShortDelay(10);
62 1 SetLCD_EN(1);
63 1 ShortDelay(20);
64 1 i = P0;
65 1 ShortDelay(40);
66 1 SetLCD_EN(0);
67 1 return(i);
68 1 }
69
70 //读一字节数据函数:ReadOneByte()
71 uchar ReadOneByte(void)
72 {
73 1 uchar i;
74 1 InitP0(1);
75 1 SetLCD_RW(1);
76 1 SetLCD_RS(1);
77 1 SetLCD_EN(0);
78 1 ShortDelay(10);
79 1 SetLCD_EN(1);
80 1 ShortDelay(20);
81 1 i = P0;
82 1 ShortDelay(40);
83 1 SetLCD_EN(0);
84 1 return(i);
85 1 }
86
87 //写指令函数:WriteInstruc()
88 void WriteInstruc(uchar Instruction)
89 {
90 1 while((ReadStatus() & 0x80)!= 0x00);
91 1 InitP0(0);
92 1 SetLCD_RW(0);
93 1 SetLCD_RS(0);
94 1 SetLCD_EN(0);
95 1 P0 = Instruction;
96 1 ShortDelay(100);
97 1 SetLCD_EN(1);
98 1 ShortDelay(100);
99 1 SetLCD_EN(0);
100 1 }
101
102 //写一字节数据函数:WriteOneByte()
103 void WriteOneByte(uchar Data)
104 {
105 1 while((ReadStatus() & 0x80)!= 0x00);
106 1 InitP0(0);
107 1 SetLCD_RW(0);
108 1 SetLCD_RS(1);
109 1 SetLCD_EN(0);
110 1 P0 = Data;
111 1 ShortDelay(100);
112 1 SetLCD_EN(1);
113 1 ShortDelay(100);
114 1 SetLCD_EN(0);
115 1 }
116
117 //复位函数:ResetLCD()
C51 COMPILER V7.09 FYD12864 08/24/2007 09:30:56 PAGE 3
118 void ResetLCD(void)
119 {
120 1 LongDelay(40);
121 1 SetLCD_RST(0);
122 1 LongDelay(1);
123 1 SetLCD_RST(1);
124 1 LongDelay(1);
125 1 }
126
127 //初始化函数:InitLCD()
128 void InitLCD(void)
129 {
130 1 ResetLCD();
131 1 FunctionSet(0x30); // Function Set: 8_bits_Data, Base_Instrution
132 1 LongDelay(1);
133 1 FunctionSet(0x30); // Function Set: 8_bits_Data, Base_Instrution
134 1 LongDelay(1);
135 1 Disp_OnOff(0x0c); // Disp_ON: The Whole ALL_ON
136 1 LongDelay(1);
137 1 ClearLCD(); // Clear LCD
138 1 LongDelay(1);
139 1 PointSet(0x06); // Entry Mode Set: DDRAM Address Counter(AC) + 1
140 1 LongDelay(1);
141 1 }
142
143 //显示一个汉字(16x16)函数:DispOneWord()
144 void DispOneWord(uchar X,uchar Y,uint Word)
145 {
146 1 uchar Disp_Address;
147 1 uchar Address_H;
148 1 uchar Address_L;
149 1
150 1 if((X == 0x00)||(X == 0x02)) // 0,2行
151 1 Address_H = 0x80;
152 1 else // 1,3行
153 1 Address_H = 0x90;
154 1
155 1 if((X == 0x00)||(X == 0x01)) // 0,1行
156 1 Address_L = Y;
157 1 else // 2,3行
158 1 Address_L = Y + 0x08;
159 1 Disp_Address = (Address_H | Address_L) & 0xff;
160 1 SetDDRAM_Add(Disp_Address); // Set DDRAM(Disp_Address)
161 1 WriteOneByte(((Word & 0xff00) >> 8) & 0xff); // H_Byte
162 1 WriteOneByte(Word & 0xff); // L_Byte
163 1 }
164
165
166 //显示两个字符(8x16)函数:DispTwoCharacter()
167 void DispTwoCharacter(uchar X,uchar Y,uchar Character1,uchar Character2)
168 {
169 1 uchar Disp_Address;
170 1 uchar Address_H;
171 1 uchar Address_L;
172 1
173 1 if((X == 0x00)||(X == 0x02)) // 0,2行
174 1 Address_H = 0x80;
175 1 else // 1,3行
176 1 Address_H = 0x90;
177 1
178 1 if((X == 0x00)||(X == 0x01)) // 0,1行
179 1 Address_L = Y;
C51 COMPILER V7.09 FYD12864 08/24/2007 09:30:56 PAGE 4
180 1 else // 2,3行
181 1 Address_L = Y + 0x08;
182 1 Disp_Address = Address_H | Address_L;
183 1 SetDDRAM_Add(Disp_Address); // Set DDRAM(Disp_Address)
184 1 WriteOneByte(Character1);
185 1 WriteOneByte(Character2);
186 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 429 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 4
IDATA SIZE = ---- ----
BIT SIZE = ---- 5
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -