📄 lcd.lst
字号:
C51 COMPILER V7.02b LCD 01/10/2008 11:39:27 PAGE 1
C51 COMPILER V7.02b, COMPILATION OF MODULE LCD
OBJECT MODULE PLACED IN lcd.OBJ
COMPILER INVOKED BY: D:\Keil\C51\BIN\C51.EXE lcd.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 /*//////////////////////////////////*/
2 /* */
3 /* Pressure_Control */
4 /* Version_1.1 */
5 /* AHTL_2007_5 */
6 /* */
7 /* */
8 /* LCD.C */
9 /* */
10 /*//////////////////////////////////*/
11
12 #include <reg52.H>
13 #include <lcd.h>
14 //
15 // 2 X 16 LCD display port and BCD port each bit function
16 //
17 // LCD PORT BCD PORT
18 //
19 // P17 P16 P15 P14 P13 P12 P11 P10 ___ NC SEL1
20 // | | | | | | |_________ NC SEL2
21 // | | | | | |_____________ RS NC
22 // | | | | |_________________ Enable1 NC
23 // | | | |_____________________ D4 D4
24 // | | |_________________________ D5 D5
25 // | |_____________________________ D6 D6
26 // |_________________________________ D7 D7
27 //
28 //
29
30 void delay50us();
31 void set_display(char);
32 void write_char (char);
33 /*-------------------------------------------------------------------------*/
34 void _init_display()
35 {
36 1 set_display(0x2c); //4 bit mode ,2 row ,5 X 10 size
37 1 set_display(0x0f);
38 1 set_display(0x06);
39 1 _delay500us(120);
40 1 }
41 /*-------------------------------------------------------------------------*/
42 void set_display(char v)
43 {
44 1 unsigned char junk;
45 1 junk=v;
46 1 junk &=0xf0;
47 1 junk |=0x0b;
48 1 DispPort=junk;
49 1 junk &=0xf3;
50 1 DispPort=junk;
51 1 junk=(v<<4);
52 1 junk &=0xf0;
53 1 junk |=0x0b;
54 1 DispPort=junk;
55 1 junk &=0xf3;
C51 COMPILER V7.02b LCD 01/10/2008 11:39:27 PAGE 2
56 1 DispPort=junk;
57 1 delay50us();
58 1 delay50us();
59 1 }
60 /*-------------------------------------------------------------------------*/
61 void _cursor_sw(char v)
62 {
63 1 if(v)
64 1 set_display(0x0f); //cursor is on and blinking
65 1 else
66 1 set_display(0x0c); //cursor is off and not blinking
67 1 }
68 /*-------------------------------------------------------------------------*/
69
70 void _cursor_pos(char r, char c)
71 {
72 1 if(r)
73 1 c += 0x40;
74 1 set_display(c | 0x80);
75 1 }
76 /*-------------------------------------------------------------------------*/
77
78 void _clear_display (void)
79 {
80 1 set_display(0x01);
81 1 _delay500us(120);
82 1 }
83 /*-------------------------------------------------------------------------*/
84
85 void _disp_msge (char r, char c, char *msge)
86 {
87 1 unsigned char i=0;
88 1 switch (r)
89 1 {
90 2 case 1 :
91 2 c += 0x40;
92 2 case 0 :
93 2 set_display(c | 0x80);
94 2 while (msge[i] != 0)
95 2 write_char(msge[i++]);
96 2 }
97 1 }
98 /*-------------------------------------------------------------------------*/
99
100 void write_char (char temp)
101 {
102 1 char junk;
103 1 junk=temp;
104 1 junk &=0xf0;
105 1 junk |=0x0f;
106 1 DispPort=junk;
107 1 junk &=0xf7;
108 1 DispPort=junk;
109 1 junk=(temp<<4);
110 1 junk &=0xf0;
111 1 junk |=0x0f;
112 1 DispPort=junk;
113 1 junk &=0xf7;
114 1 DispPort=junk;
115 1 delay50us();
116 1 delay50us();
117 1 }
C51 COMPILER V7.02b LCD 01/10/2008 11:39:27 PAGE 3
118 /*-------------------------------------------------------------------------
119 void _display_bit4 (char r,char c,char v)
120 {
121 _cursor_pos (r,c);
122 write_char((char)('0'+(v%10)));
123 _cursor_pos (r,c);
124 }
125 /*-------------------------------------------------------------------------*/
126 void _display_bit8 (char r,char c,char v)
127 {
128 1 _cursor_pos (r,c);
129 1 write_char((char)('0'+(v/10)));
130 1 write_char((char)('0'+(v%10)));
131 1 _cursor_pos (r,c);
132 1 }
133 /*-------------------------------------------------------------------------
134 void _display_bit12 (char r,char c,unsigned int v)
135 {
136 _cursor_pos (r,c);
137 write_char('0'+(v/100));
138 v %= 100;
139 write_char((char)('0'+((char)v/10)));
140 write_char((char)('0'+((char)v%10)));
141 _cursor_pos (r,c);
142 }
143 /*-------------------------------------------------------------------------
144 void _display_bit16 (char r,char c,unsigned int v)
145 {
146 _cursor_pos (r,c);
147 write_char('0'+(v/1000));
148 v %= 1000;
149 write_char('0'+(v/100));
150 v %= 100;
151 write_char((char)('0'+((char)v/10)));
152 write_char((char)('0'+((char)v%10)));
153 _cursor_pos (r,c);
154 }
155 /*-------------------------------------------------------------------------*/
156 unsigned char _hex2tobcd (char v)
157 {
158 1 char retu;
159 1 retu = (v/10)*16+v%10;
160 1 return retu;
161 1 }
162 /*-------------------------------------------------------------------------
163 unsigned int _hex4tobcd (unsigned int v_temp)
164 {
165 unsigned int retu;
166 unsigned int v;
167 v=v_temp;
168 retu = (v/1000)<<12;
169 v %= 1000;
170 retu = retu + ((v/100)<<8);
171 v %= 100;
172 retu = retu + ((v/10)*16)+(v%10);
173 return retu;
174 }
175 /*-------------------------------------------------------------------------
176 unsigned int _hex3tobcd (unsigned int v_temp)
177 {
178 unsigned int retu;
179 unsigned int v;
C51 COMPILER V7.02b LCD 01/10/2008 11:39:27 PAGE 4
180 v=v_temp;
181 retu =(v/100)<<8;
182 v %= 100;
183 retu = retu + ((v/10)*16)+(v%10);
184 return retu;
185 }
186 /*-------------------------------------------------------------------------*/
187 void delay50us()
188 {
189 1 unsigned char temp;
190 1 temp=20;
191 1 while(temp)
192 1 temp--;
193 1 }
194 /*-------------------------------------------------------------------------*/
195 void _delay500us(char t)
196 {
197 1 unsigned int i;
198 1 while(t)
199 1 {
200 2 i=124;
201 2 while(i)
202 2 i--;
203 2 t--;
204 2 }
205 1 }
206 /*-------------------------------------------------------------------------
207 void delay_20ms(unsigned char i)
208 {
209 unsigned int j;
210 while(i--)
211 {
212 j=20000;
213 while(j--);
214 }
215 }
216 /*-------------------------------------------------------------------------*/
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 293 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 7
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 + -