📄 lcd_test.lst
字号:
C51 COMPILER V7.06 LCD_TEST 07/30/2007 12:49:24 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE LCD_TEST
OBJECT MODULE PLACED IN D:\C\LCD_TEST.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE D:\C\LCD_TEST.C DB SB OE
stmt level source
1 #include <reg51.h>
2 #include <intrins.h>
3 sbit dc=P2^1; /*P2.1 LCD 的RS 21*/
4 sbit rw=P2^2; /*P2.2 LCD 的R/W 22*/
5 sbit cs=P2^4; /*P2.4 LCD 的E 25*/
6 sfr lcdbus=0x80; /*p0LCD 数据 D0=P0.0*/
7 unsigned int sys10mscounter;
8 unsigned char syslimitcounter;
9 char path1[8]={0x00,0x1f,0x00,0x1f,0x00,0x1f,0x00,0x1f};/*自定义符号横1*/
10 char path2[8]={0x1f,0x00,0x1f,0x00,0x1f,0x00,0x1f,0x00};/*自定义符号横2*/
11 char pats1[8]={0x15,0x15,0x15,0x15,0x15,0x15,0x15,0x15};/*自定义符号竖1*/
12 char pats2[8]={0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a,0x0a};/*自定义符号竖2*/
13 void soft_nop(){}
14 void soft_10ms()/***********12MHZ 提供10MS 软件延时************/
15 { register int i;
16 1 for(i=0;i<711;i++);
17 1 }
18 void soft_20ms()/***********12MHZ 提供20MS 软件延时************/
19 { soft_10ms();
20 1 soft_10ms();
21 1 }
22 void hard_10ms(unsigned int delaytime) /*基于10MS 的硬件延时*/
23 { sys10mscounter=delaytime;
24 1 while(sys10mscounter);
25 1 }
26 unsigned char data lcdcounter;
27 bit lcdusing1,lcdusing2;
28 bit lcd_checkbusy()/*检查LCD 忙*/
29 { register lcdstate;
30 1 dc=0; /*dc=1为数据,=0 为命令.*/
31 1 rw=1; /*rw=1为读,=0为写.*/
32 1 cs=1; /*cs=1选通.*/
33 1 soft_nop();
34 1 lcdstate=lcdbus;
35 1 cs=0;
36 1 return((bit)(lcdstate&0x80));
37 1 }
38 void lcd_wrcmd(unsigned char lcdcmd) /*写LCD命令*/
39 { lcdusing1=1;
40 1 while(lcd_checkbusy());
41 1 lcdbus=lcdcmd;
42 1 dc=0; /*dc=1为数据,=0 为命令.*/
43 1 rw=0; /*rw=1为读,=0为写.*/
44 1 cs=1; /*cs=1选通.*/
45 1 soft_nop();
46 1
47 1 cs=0;
48 1 lcdbus=0xff;
49 1 lcdusing1=0;
50 1 }
51 void lcd_moveto(char position) /*移动光标到指定位.0-79*/
52 { register cmd=0x80;
53 1 lcdcounter=position;
54 1 if (position > 59)
55 1 position += 0x18;
C51 COMPILER V7.06 LCD_TEST 07/30/2007 12:49:24 PAGE 2
56 1 else
57 1 { if (position > 39)position -= 0x14;
58 2 else
59 2 { if (position > 19)position += 0x2c;
60 3 }
61 2 }
62 1 cmd=cmd|position;
63 1 lcd_wrcmd(cmd);
64 1 }
65 void lcd_wrdata(char lcddata) /*在当前显示位置显示数据*/
66 { char i;
67 1 lcdusing2=1;
68 1 while(lcd_checkbusy());
69 1 if(lcdcounter==20){
70 2 lcd_moveto(20);
71 2 while(lcd_checkbusy());
72 2 }
73 1 if(lcdcounter==40){
74 2 lcd_moveto(40);
75 2 while(lcd_checkbusy());
76 2 }
77 1 if(lcdcounter==60){
78 2 lcd_moveto(60);
79 2 while(lcd_checkbusy());
80 2 }
81 1 if(lcdcounter==80){
82 2 lcd_moveto(0);
83 2 while(lcd_checkbusy());
84 2 lcdcounter=0;
85 2 } /*为通用而如此*/
86 1 lcdcounter++;
87 1 lcdbus=lcddata;
88 1 dc=1; /*dc=1为数据,=0 为命令.*/
89 1 rw=0; /*rw=1为读,=0为写.*/
90 1 cs=1; /*cs=1选通.*/
91 1 soft_nop();
92 1 cs=0;
93 1
94 1 lcdbus=0xff;
95 1 lcdusing2=0;
96 1 }
*** WARNING C280 IN LINE 66 OF D:\C\LCD_TEST.C: 'i': unreferenced local variable
97 void lcd_string(char *strpoint) /*在当前显示位置显示LCD 字符串*/
98 { register i=0;
99 1 while(strpoint[i]!=0){
100 2 lcd_wrdata(strpoint[i]);
101 2 i++;
102 2 }
103 1 }
104 void lcd_init()/*初始化*/
105 { lcd_wrcmd(0x38); /*设置8 位格式,2行,5*7*/
106 1 lcd_wrcmd(0x0c); /*整体显示,关光标,不闪烁*/
107 1 lcd_wrcmd(0x06); /*设定输入方式,增量不移位*/
108 1 lcd_wrcmd(0x01); /*清除显示*/
109 1 lcdcounter=0;
110 1 }
111 void lcd_cls()/*清除显示*/
112 { lcd_wrcmd(0x01);
113 1 lcdcounter=0;
114 1 }
115 void timer0(void) interrupt 1 /*T0中断*/
116 { TH0=0xd8; /*12M,10ms*/
C51 COMPILER V7.06 LCD_TEST 07/30/2007 12:49:24 PAGE 3
117 1 TL0=0xf6;
118 1 TR0=1;
119 1 if(sys10mscounter!=0)sys10mscounter--; /*定时器10ms*/
120 1 if(syslimitcounter!=0)syslimitcounter--; /*定时器10ms*/
121 1 }
122 main()
123 {
124 1 unsigned char j;
125 1 IE=0;P0=0xff;P1=0xff;P2=0xff;P3=0xff; /*初始化T*/
126 1 lcd_init();soft_20ms();
127 1 TMOD=0x51;
128 1 TH0=0xd8; /*12M,10ms*/
129 1 TL0=0xf6;
130 1 TR0=1;ET0=1;EA=1;
131 1 while(1)
132 1 {
133 2 /*全黑横一横二竖一竖二U Q ABCD... */
134 2 lcd_init(); /*全黑*/
135 2 for(j=0;j<80;j++){lcd_wrdata(0xff);}
136 2 hard_10ms(50);
137 2 lcd_init(); /*横一可参考自行设计符号*/
138 2 lcd_wrcmd(0x40);
139 2 for(j=0;j<8;j++)lcd_wrdata(path1[j]);
140 2
141 2 for(j=0;j<100;j++)lcd_wrdata(0);
142 2 hard_10ms(50);
143 2 lcd_init(); /*横二*/
144 2 lcd_wrcmd(0x40);
145 2 for(j=0;j<8;j++)lcd_wrdata(path2[j]);
146 2 for(j=0;j<100;j++)lcd_wrdata(0);
147 2 hard_10ms(50);
148 2 lcd_init(); /*竖一*/
149 2 lcd_wrcmd(0x40);
150 2 for(j=0;j<8;j++)lcd_wrdata(pats1[j]);
151 2 for(j=0;j<100;j++)lcd_wrdata(0);
152 2 hard_10ms(50);
153 2 lcd_init(); /*竖二*/
154 2 lcd_wrcmd(0x40);
155 2 for(j=0;j<8;j++)lcd_wrdata(pats2[j]);
156 2 for(j=0;j<100;j++)lcd_wrdata(0);
157 2 hard_10ms(50);
158 2 lcd_init();
159 2 lcd_string("UUUUUUUUUuuuuuuuuuuuuuuuuUU");
160 2 hard_10ms(50);
161 2 lcd_init();
162 2 lcd_string("QQQQQqqqqqqqqqqqqqqqqQQQQQQ");
163 2 hard_10ms(50);
164 2 lcd_init();
165 2 lcd_string("ABCDEJ#$%&3333333333333333?");
166 2 hard_10ms(50);
167 2 }
168 1 }
C51 COMPILER V7.06 LCD_TEST 07/30/2007 12:49:24 PAGE 4
NAME CLASS MSPACE TYPE OFFSET SIZE
==== ===== ====== ==== ====== ====
P0 . . . . . . . . . . . . . . . . . . SFR DATA U_CHAR 0080H 1
lcdbus . . . . . . . . . . . . . . . . SFR DATA U_CHAR 0080H 1
P1 . . . . . . . . . . . . . . . . . . SFR DATA U_CHAR 0090H 1
P2 . . . . . . . . . . . . . . . . . . SFR DATA U_CHAR 00A0H 1
P3 . . . . . . . . . . . . . . . . . . SFR DATA U_CHAR 00B0H 1
EA . . . . . . . . . . . . . . . . . . ABSBIT ----- BIT 00AFH 1
syslimitcounter. . . . . . . . . . . . PUBLIC DATA U_CHAR 0000H 1
IE . . . . . . . . . . . . . . . . . . SFR DATA U_CHAR 00A8H 1
_lcd_string. . . . . . . . . . . . . . PUBLIC CODE PROC 0000H -----
strpoint . . . . . . . . . . . . . . AUTO DATA PTR 0000H 3
i. . . . . . . . . . . . . . . . . . AUTO DATA INT 0003H 2
lcdusing1. . . . . . . . . . . . . . . PUBLIC DATA BIT 0000H 1
lcdusing2. . . . . . . . . . . . . . . PUBLIC DATA BIT 0001H 1
_lcd_moveto. . . . . . . . . . . . . . PUBLIC CODE PROC 0000H -----
position . . . . . . . . . . . . . . * REG * DATA CHAR 0007H 1
cmd. . . . . . . . . . . . . . . . . * REG * DATA INT 0004H 2
_lcd_wrcmd . . . . . . . . . . . . . . PUBLIC CODE PROC 0000H -----
lcdcmd . . . . . . . . . . . . . . . * REG * DATA U_CHAR 0006H 1
_hard_10ms . . . . . . . . . . . . . . PUBLIC CODE PROC 0000H -----
delaytime. . . . . . . . . . . . . . * REG * DATA U_INT 0006H 2
main . . . . . . . . . . . . . . . . . PUBLIC CODE PROC 0000H -----
j. . . . . . . . . . . . . . . . . . * REG * DATA U_CHAR 0002H 1
sys10mscounter . . . . . . . . . . . . PUBLIC DATA U_INT 0001H 2
TMOD . . . . . . . . . . . . . . . . . SFR DATA U_CHAR 0089H 1
lcdcounter . . . . . . . . . . . . . . PUBLIC DATA U_CHAR 0003H 1
dc . . . . . . . . . . . . . . . . . . ABSBIT ----- BIT 00A1H 1
ET0. . . . . . . . . . . . . . . . . . ABSBIT ----- BIT 00A9H 1
lcd_init . . . . . . . . . . . . . . . PUBLIC CODE PROC 0007H -----
TH0. . . . . . . . . . . . . . . . . . SFR DATA U_CHAR 008CH 1
TL0. . . . . . . . . . . . . . . . . . SFR DATA U_CHAR 008AH 1
timer0 . . . . . . . . . . . . . . . . PUBLIC CODE PROC 0000H -----
cs . . . . . . . . . . . . . . . . . . ABSBIT ----- BIT 00A4H 1
TR0. . . . . . . . . . . . . . . . . . ABSBIT ----- BIT 008CH 1
lcd_cls. . . . . . . . . . . . . . . . PUBLIC CODE PROC 0000H -----
lcd_checkbusy. . . . . . . . . . . . . PUBLIC CODE PROC 0000H -----
lcdstate . . . . . . . . . . . . . . * REG * DATA INT 0006H 2
path1. . . . . . . . . . . . . . . . . PUBLIC DATA ARRAY 0004H 8
soft_10ms. . . . . . . . . . . . . . . PUBLIC CODE PROC 0000H -----
i. . . . . . . . . . . . . . . . . . * REG * DATA INT 0006H 2
path2. . . . . . . . . . . . . . . . . PUBLIC DATA ARRAY 000CH 8
soft_20ms. . . . . . . . . . . . . . . PUBLIC CODE PROC 0000H -----
rw . . . . . . . . . . . . . . . . . . ABSBIT ----- BIT 00A2H 1
pats1. . . . . . . . . . . . . . . . . PUBLIC DATA ARRAY 0014H 8
pats2. . . . . . . . . . . . . . . . . PUBLIC DATA ARRAY 001CH 8
soft_nop . . . . . . . . . . . . . . . PUBLIC CODE PROC 0000H -----
_lcd_wrdata. . . . . . . . . . . . . . PUBLIC CODE PROC 0004H -----
lcddata. . . . . . . . . . . . . . . * REG * DATA CHAR 0003H 1
i. . . . . . . . . . . . . . . . . . AUTO DATA CHAR 0000H 1
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 566 ----
CONSTANT SIZE = 84 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 36 6
IDATA SIZE = ---- ----
BIT SIZE = 2 ----
C51 COMPILER V7.06 LCD_TEST 07/30/2007 12:49:24 PAGE 5
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 1 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -