📄 cs22-1.lst
字号:
C51 COMPILER V7.06 CS22_1 02/20/2007 20:32:52 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE CS22_1
OBJECT MODULE PLACED IN CS22-1.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE CS22-1.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include <REG51.H>
2 #include<INTRINS.H>
3 #define uchar unsigned char
4 #define uint unsigned int
5 #define DataPort P0
6 sbit LCM_RS=P2^0;
7 sbit LCM_RW=P2^1;
8 sbit LCM_EN=P2^2;
9 uchar code str0[]={"-This is a LCD-!"};
10 uchar code str1[]={"-Design by ZXH-!"};
11 uchar code str2[]={" "};
12 /*******************************/
13 void delay(unsigned int k)
14 {
15 1 unsigned int i,j;
16 1 for(i=0;i<k;i++){
17 2 for(j=0;j<121;j++)
18 2 {;}}
19 1 }
20 /*******************************/
21 void WaitForEnable(void)
22 {
23 1 DataPort=0xff;
24 1 LCM_RS=0;LCM_RW=1;_nop_();
25 1 LCM_EN=1;_nop_();_nop_();
26 1 while(DataPort&0x80);
27 1 LCM_EN=0;
28 1 }
29 /*******************************/
30 void WriteCommandLCM(uchar CMD,uchar Attribc)
31 {
32 1 if(Attribc)WaitForEnable();
33 1 LCM_RS=0;LCM_RW=0;_nop_();
34 1 DataPort=CMD;_nop_();
35 1 LCM_EN=1;_nop_();_nop_();LCM_EN=0;
36 1 }
37 /*******************************/
38 void WriteDataLCM(uchar dataW)
39 {
40 1 WaitForEnable();
41 1 LCM_RS=1;LCM_RW=0;_nop_();
42 1 DataPort=dataW;_nop_();
43 1 LCM_EN=1;_nop_();_nop_();LCM_EN=0;
44 1 }
45 /***********************************/
46 void InitLcd()
47 {
48 1 WriteCommandLCM(0x38,1);
49 1 WriteCommandLCM(0x08,1);
50 1 WriteCommandLCM(0x01,1);
51 1 WriteCommandLCM(0x06,1);
52 1 WriteCommandLCM(0x0c,1);
53 1 }
54 /***********************************/
55 void DisplayOneChar(uchar X,uchar Y,uchar DData)
C51 COMPILER V7.06 CS22_1 02/20/2007 20:32:52 PAGE 2
56 {
57 1 Y&=1;
58 1 X&=15;
59 1 if(Y)X|=0x40;
60 1 X|=0x80;
61 1 WriteCommandLCM(X,0);
62 1 WriteDataLCM(DData);
63 1 }
64 /***********************************/
65 void DisplayListChar(uchar X,uchar Y,uchar code *DData)
66 {
67 1 uchar ListLength=0;
68 1 Y&=0x1;
69 1 X&=0xF;
70 1 while(X<=15)
71 1 {
72 2 DisplayOneChar(X,Y,DData[ListLength]);
73 2 ListLength++;
74 2 X++;
75 2 }
76 1 }
77 /***********************************/
78 void main(void)
79 {
80 1 char i,m;
81 1 delay(500);
82 1 InitLcd();
83 1 /*******从右移到显示屏*********************/
84 1 for(i=15;i>=0;i--)
85 1 {
86 2 WriteCommandLCM(0x01,1);
87 2 DisplayOneChar(i,0,0x20);
88 2 DisplayListChar(i,0,str0);
89 2 DisplayListChar(i,1,str1);
90 2 delay(200);
91 2 }
92 1 delay(2800);
93 1 /************向右退出显示屏*************/
94 1 for(i=0;i<16;i++)
95 1 {
96 2 WriteCommandLCM(0x01,1);
97 2 DisplayOneChar(i,0,0x20);
98 2 DisplayListChar(i,0,str0);
99 2 DisplayListChar(i,1,str1);
100 2 delay(200);
101 2 }
102 1 WriteCommandLCM(0x01,1);
103 1 delay(3000);
104 1 /********闪烁5次***********************/
105 1 for(i=0;i<10;i++)
106 1 {
107 2 WriteCommandLCM(0x01,1);
108 2 delay(500);
109 2 DisplayListChar(0,0,str0);
110 2 DisplayListChar(0,1,str1);
111 2 delay(500);
112 2 i++;
113 2 }
114 1 delay(3000);
115 1 /***************************************/
116 1 while(1)
117 1 {
C51 COMPILER V7.06 CS22_1 02/20/2007 20:32:52 PAGE 3
118 2 /********从右移到显示屏**************************/
119 2 for(i=15;i>=0;i--)
120 2 {
121 3 WriteCommandLCM(0x01,1);
122 3 DisplayOneChar(i,0,0x20);
123 3 DisplayListChar(i,0,str0);
124 3 DisplayListChar(i,1,str1);
125 3 delay(200);
126 3 }
127 2 /***********向左退出显示屏************************/
128 2 for(i=1;i<16;i++)
129 2 {
130 3 m=16-i;
131 3 WriteCommandLCM(0x01,1);
132 3 DisplayOneChar(0,0,0x20);
133 3 DisplayListChar(0,0,&str0[i]);
134 3 DisplayListChar(0,1,&str1[i]);
135 3 DisplayListChar(m,0,str2);
136 3 DisplayListChar(m,1,str2);
137 3 delay(200);
138 3 }
139 2 WriteCommandLCM(0x01,1);
140 2 delay(200);
141 2 }
142 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 522 ----
CONSTANT SIZE = 51 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 5
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 + -