📄 lcd.lst
字号:
C51 COMPILER V7.06 LCD 12/17/2006 14:56:13 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE LCD
OBJECT MODULE PLACED IN LCD.OBJ
COMPILER INVOKED BY: E:\My Electronic\Tools\Design tools\keil7.06\C51\BIN\C51.EXE LCD.c LARGE OPTIMIZE(SIZE)
stmt level source
1 #include <REG52.H>
2
3 #ifndef uchar
4 #define uint unsigned int
5 #define uchar unsigned char
6 #endif
7
8 #define LCD_DATA P0
9
10 sbit RS=P2^7;
11 sbit RW=P2^6;
12 sbit EN=P2^5;
13 sbit RST=P2^4;
14 void delay_us(unsigned char us);
15 void delay_ms(unsigned int ms);
16
17 void LCD_Busy_Check() //等待LCD空闲
18 {
19 1 LCD_DATA &=~0x80;
20 1 EN=0;
21 1 RS=0;
22 1 RW=1; //RW=1
23 1 EN=1;
24 1 while (!(LCD_DATA&0x80)==0);
25 1 EN=0;
26 1 LCD_DATA |= 0xff;
27 1 }
28
29 void LCD_write(uchar wdat,uchar mode)
30 {
31 1
32 1 LCD_Busy_Check();
33 1 LCD_DATA |= 0xff;
34 1 EN=0; //EN=0
35 1 RS=mode; //RS=1
36 1 RW=0; //RW=0
37 1 EN=1;
38 1 LCD_DATA &= wdat; //send 8bit
39 1 EN=0;
40 1 RW=1;
41 1 RS=1;
42 1 }
43
44 void LCD_set_position( uchar x, uchar y )
45 {
46 1 uchar address;
47 1 switch(y)
48 1 {
49 2 case 0:
50 2 address = 0x80 + x;
51 2 break;
52 2 case 1:
53 2 address = 0x90 + x;
54 2 break;
55 2 case 2:
C51 COMPILER V7.06 LCD 12/17/2006 14:56:13 PAGE 2
56 2 address = 0x88 + x;
57 2 break;
58 2 case 3:
59 2 address = 0x98 + x;
60 2 break;
61 2 default:address = 0x80 + x;
62 2 }
63 1 LCD_write( address, 0 );
64 1 }
65
66 void LCD_write_string(uchar X,uchar Y,uchar *s)
67 {
68 1 LCD_set_position( X, Y );
69 1 while (*s)
70 1 {
71 2 LCD_write(*s,1);
72 2 s++;
73 2 }
74 1 }
75
76
77 void LCD_set_pic_position(unsigned char x,unsigned char y)
78 {
79 1 if(y>31)
80 1 {
81 2 x+=0x88;
82 2 y=(y-32)+0x80;
83 2 }
84 1 else
85 1 {
86 2 x+=0x80;
87 2 y+=0x80;
88 2 }
89 1 LCD_write(0x34,0);
90 1 LCD_write(y,0);
91 1 LCD_write(x,0);
92 1 LCD_write(0x30,0);
93 1 }
94
95
96 void LCD_Convert(unsigned char x,unsigned char y,unsigned char weith,unsigned char mode) //反白
97 {
98 1 unsigned char flag=0;
99 1 unsigned char px=0;
100 1 unsigned char py=0;
101 1 if (mode) mode=0xff;
102 1 if(x%2)
103 1 {
104 2 flag=1;
105 2 }
106 1 x/=2;
107 1 for(py=0;py<16;py++)
108 1 {
109 2 LCD_set_pic_position(x,y*16+py);
110 2 if(flag) LCD_write(0,1);
111 2 for (px=weith;px>0;px--)
112 2 {
113 3 LCD_write (mode,1);
114 3 }
115 2 }
116 1 LCD_write(0x36,0);
117 1 LCD_write(0x30,0);
C51 COMPILER V7.06 LCD 12/17/2006 14:56:13 PAGE 3
118 1 }
119
120 void LCD_clr_pic()
121 {
122 1 unsigned char i;
123 1 for(i=0;i<4;i++) LCD_Convert(0,i,16,0);
124 1 }
125
126
127 void LCD_init(void)
128 {
129 1 RST=0;
130 1 delay_us(50);
131 1 RST=1;
132 1 delay_us(50);
133 1 LCD_write(0x01,0); //显示清屏
134 1 delay_ms(30);
135 1 LCD_write(0x0c,0); //显示开,不显示光标
136 1 delay_ms(30);
137 1 LCD_write(0x80,0); //显示光标移动设置
138 1 delay_ms(30);
139 1 LCD_clr_pic();
140 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 391 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- 6
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 + -