📄 lcd_a.lst
字号:
C51 COMPILER V7.06 LCD_A 07/27/2007 23:51:37 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE LCD_A
OBJECT MODULE PLACED IN .\out\LCD_A.obj
COMPILER INVOKED BY: D:\Program Files\C51\BIN\C51.EXE LCD_A.C BROWSE DEBUG OBJECTEXTEND OBJECT(.\out\LCD_A.obj)
stmt level source
1
2 #include "Main.h"
3 #include "Port.h"
4
5 #include "LCD_A.h"
6 #include "Delay_T0.h"
7
8
9
10 extern char LCD_data_G[LCD_LINES][LCD_CHARACTERS+1] ;
11
12
13 static void LCD_Send_Byte(const tByte, const bit) ;
14
15 static void LCD_SetDDRAM(tByte);
16 static void LCD_Delay(void);
17
18 extern char str0[];
19
20
21 #define LCD_DISPLAY_OFF_CURSOR_OFF_BLINKING_OFF 0x08
22 #define LCD_DISPLAY_ON_CURSOR_OFF_BLINKING_OFF 0x0C
23
24 #define LCD_INC_ADDR_NO_SCROLL 0x06
25 #define LCD_CURSOR_OFF 0x08
26 #define LCD_DISPLAY_ON 0x04
27 #define LCD_CLEAR_DISPLAY 0x01
28 #define LCD_4BIT_2LINE_5x8FONT 0x28
29
30
31
32
33 void LCD_Init(const bit TURN_DISPLAY_ON)
34 {
35 1 tByte loop;
36 1 tByte l,c;
37 1
38 1 Hardware_Delay_T0(10);
39 1
40 1 // Set up the LCD port
41 1 LCD_D4 = 1;
42 1 LCD_D5 = 1;
43 1 LCD_D6 = 1;
44 1 LCD_D7 = 1;
45 1
46 1 LCD_RS = 1;
47 1 LCD_EN = 1;
48 1
49 1 Hardware_Delay_T0(10);
50 1
51 1 LCD_RS = 0;
52 1 LCD_EN = 0;
53 1
54 1 // Now wait for the display to initialise
55 1 // - data sheet says at least 40 ms
C51 COMPILER V7.06 LCD_A 07/27/2007 23:51:37 PAGE 2
56 1 Hardware_Delay_T0(100);
57 1
58 1 // Data sheet says send this instruction 3 times...
59 1 for (loop = 0; loop < 3; loop++)
60 1 {
61 2 // Using a 4-bit bus, 2 display lines and a 5x7 dot font
62 2 LCD_Send_Byte(LCD_4BIT_2LINE_5x8FONT,0);
63 2 Hardware_Delay_T0(1);
64 2 }
65 1
66 1 // Turn the display off and the cursor off and blinking off
67 1 LCD_Send_Byte(LCD_DISPLAY_OFF_CURSOR_OFF_BLINKING_OFF,0);
68 1 Hardware_Delay_T0(1);
69 1
70 1 // Clear the display
71 1 LCD_Send_Byte(LCD_CLEAR_DISPLAY,0);
72 1 Hardware_Delay_T0(1);
73 1
74 1 // Invisible cursor (dummy function call to avoid library error)
75 1 LCD_Control_Cursor(0,0,0);
76 1 Hardware_Delay_T0(1);
77 1
78 1 // Clear the display
79 1 LCD_Send_Byte(LCD_CLEAR_DISPLAY,0);
80 1 Hardware_Delay_T0(1);
81 1
82 1 if (TURN_DISPLAY_ON)
83 1 {
84 2 // Increment display address for each character but do not scroll
85 2 LCD_Send_Byte(LCD_INC_ADDR_NO_SCROLL,0);
86 2 Hardware_Delay_T0(1);
87 2
88 2 // Update all characters in the display
89 2 for (l = 0; l < LCD_LINES; l++)
90 2 {
91 3 for (c = 0; c < LCD_CHARACTERS; c++)
92 3 {
93 4 LCD_data_G[l][c] = '*';
94 4 LCD_Update();
95 4 Hardware_Delay_T0(1);
96 4 }
97 3 }
98 2 // LCD_Send_Byte(LCD_DISPLAY_ON_CURSOR_OFF_BLINKING_OFF,0);
99 2 // Hardware_Delay_T0(1);
100 2 }
101 1 }
102
103
104
105 void LCD_Update(void)
106 {
107 1
108 1 tByte Character,Line;
109 1 tByte Data;
110 1
111 1 for(Line=0;Line<2;Line++)
112 1 for(Character=0;Character<16;Character++)
113 1 {
114 2 if (Line == 0)
115 2 {
116 3 LCD_SetDDRAM(0x00 + Character); // First line
117 3 }
C51 COMPILER V7.06 LCD_A 07/27/2007 23:51:37 PAGE 3
118 2 else
119 2 {
120 3 LCD_SetDDRAM(0x40 + Character); // Second line
121 3 }
122 2
123 2 Data = LCD_data_G[Line][Character];
124 2 LCD_Send_Byte(Data,1);
125 2 }
126 1
127 1 }
128
129
130 //不太优化,但是很灵活.DATA_FLAG=0为写入命令,DATA_FLAG=1为写入数据
131 void LCD_Send_Byte(const tByte DATA, const bit DATA_FLAG)
132 {
133 1
134 1
135 1 LCD_D4 = 0;
136 1 LCD_D5 = 0;
137 1 LCD_D6 = 0;
138 1 LCD_D7 = 0;
139 1 LCD_RS = DATA_FLAG; // Data register
140 1 LCD_EN = 0;
141 1 LCD_Delay();
142 1
143 1 // Write the data (high nybble)
144 1 LCD_D4 = ((DATA & 0x10) == 0x10);
145 1 LCD_D5 = ((DATA & 0x20) == 0x20);
146 1 LCD_D6 = ((DATA & 0x40) == 0x40);
147 1 LCD_D7 = ((DATA & 0x80) == 0x80);
148 1
149 1 LCD_Delay();
150 1 LCD_EN = 1;
151 1 LCD_Delay();
152 1 LCD_EN = 0;
153 1 LCD_Delay();
154 1
155 1
156 1 LCD_D4 = 0;
157 1 LCD_D5 = 0;
158 1 LCD_D6 = 0;
159 1 LCD_D7 = 0;
160 1 LCD_RS = DATA_FLAG;
161 1 LCD_EN = 0;
162 1 LCD_Delay();
163 1
164 1
165 1 LCD_D4 = ((DATA & 0x01) == 0x01);
166 1 LCD_D5 = ((DATA & 0x02) == 0x02);
167 1 LCD_D6 = ((DATA & 0x04) == 0x04);
168 1 LCD_D7 = ((DATA & 0x08) == 0x08);
169 1
170 1 LCD_Delay();
171 1 LCD_EN = 1;
172 1 LCD_Delay();
173 1 LCD_EN = 0;
174 1 LCD_Delay();
175 1 }
176
177
178 void LCD_Control_Cursor(const bit VISIBLE, const bit BLINKING,
179 const tByte ADDRESS)
C51 COMPILER V7.06 LCD_A 07/27/2007 23:51:37 PAGE 4
180 {
181 1 // Cursor / blinking appears at current DDRAM address
182 1 // - use SetDDRAM() to alter the cursor position
183 1 tByte Command = 0x0C;
184 1
185 1 if (VISIBLE)
186 1 {
187 2 Command |= 0x02;
188 2 }
189 1
190 1 if (BLINKING)
191 1 {
192 2 Command |= 0x01;
193 2 }
194 1
195 1 LCD_Send_Byte(Command,0);
196 1 LCD_SetDDRAM(ADDRESS);
197 1 }
198
199 /*------------------------------------------------------------------*-
200
201 LCD_SetDDRAM()
202
203 Set the DDRAM to a particular address.
204
205 Used to determine where we write to in the LCD RAM and - thus -
206 whether the text appears on Line 0, Line 1, etc.
207
208 See text for details.
209
210 Params: The DDRAM address we wish to write to.
211
212 -*------------------------------------------------------------------*/
213 void LCD_SetDDRAM(tByte ADDRESS)
214 {
215 1 ADDRESS &= 0x7f;
216 1 ADDRESS |= 0x80;
217 1 LCD_Send_Byte(ADDRESS,0);
218 1 }
219
220
221
222 void LCD_Delay(void)
223 {
224 1 int x;
225 1
226 1 x++;
227 1 x++;
228 1 x++;
229 1 }
230
231
232
233 void Displayonechar( char x, char y, char DData)
234 {
235 1 /*
236 1 x&=1;
237 1 y&=15;
238 1 if(x)
239 1 y|=0x40;
240 1 y|=0x80;
241 1 */
C51 COMPILER V7.06 LCD_A 07/27/2007 23:51:37 PAGE 5
242 1 // LCD_Send_Byte(y,0);
243 1 // LCD_Send_Byte(DData,1);
244 1 // LCD_Update();
245 1
246 1
247 1 // LCD_Send_Byte(Data,1);
248 1 /*
249 1 //memcpy(LCD_data_G[x][y],DData,1);
250 1 //LCD_Update();
251 1
252 1 */
253 1 LCD_data_G[x][y]=DData;
254 1 LCD_Update();
255 1
256 1 }
257
258
259
260 void Displaylistchar( char x, char y, char DData[])
261 {
262 1 int l=0;
263 1 int j;
264 1 // DData="asd";
265 1 j=strlen(DData);
266 1
267 1 //x&=0x1;
268 1 //y&=0xf;
269 1 while(y<=15)
270 1 {
271 2 Displayonechar(x,y,DData[l]);
272 2 l++;
273 2 y++;
274 2 }
275 1
276 1 //memcpy(LCD_data_G[x][y],Info,length);
277 1 //LCD_Update();
278 1 }
279
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 525 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 19
IDATA SIZE = ---- ----
BIT SIZE = ---- 4
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -