📄 1602-1.lst
字号:
C51 COMPILER V7.00 1602_1 05/18/2009 11:36:00 PAGE 1
C51 COMPILER V7.00, COMPILATION OF MODULE 1602_1
OBJECT MODULE PLACED IN 1602-1.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE 1602-1.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include<reg52.h>
2 #include<intrins.h>
3
4 sbit RS = P2^2;
5 sbit RW = P2^3;
6 sbit E = P2^4;
7
8 #define dataport P0
9 #define busy 0x80
10
11 //函数声明
12 void init(void); //初始化函数
13 void dellay(unsigned int); //延迟函数
14 void display_char(unsigned char x,unsigned char y,unsigned char wdata); //显示单个字符函数
15 void display_string(unsigned char x,unsigned char y,unsigned char code *str); //显示字符串函数
16 void writecommand(unsigned char wcond); //写命令函数
17 void writedata(unsigned char wdata); //写数据函数
18 void display_xy(unsigned char x,unsigned char y); //光标定位函数
19 void waitforenable(void); //等待检测函数
20 unsigned char code first[] = {"www.xiyou.edu.cn"};
21 unsigned char code second[] = {"guangdian zhaobo"};
22 /*******************延迟函数*******************************/
23
24 void dellay(unsigned int t)
25 {
26 1 while(t--);
27 1 }
28
29
30 /************主程序**************/
31 main()
32 {
33 1 dellay(400);
34 1 init();
35 1
36 1 display_string(0,0,first);
37 1 display_string(0,1,second);
38 1
39 1 while(1);
40 1 }
41
42 /**************写数据函数************************************/
43
44 void writedata(unsigned char wdata)
45 {
46 1 waitforenable();
47 1 RS=1;
48 1 RW=0;
49 1 E=0;
50 1 _nop_(); //空操作为了保证顺利读取数据
51 1 dataport=wdata;
52 1 E=1;
53 1 _nop_();
54 1 E=0;
55 1 RS=0;
C51 COMPILER V7.00 1602_1 05/18/2009 11:36:00 PAGE 2
56 1 }
57 /***************写命令函数***********************************/
58
59 void writecommand(unsigned char wcond)
60 {
61 1 waitforenable();
62 1 RS=0;
63 1 RW=0;
64 1 E=0;
65 1 _nop_();
66 1 dataport=wcond;
67 1 E=1;
68 1 _nop_();
69 1 E=0;
70 1 }
71
72 /***********初始化**************************/
73 void init(void)
74 {
75 1 writecommand(0x38);
76 1 dellay(1000);
77 1 writecommand(0x38); //显示模式设置
78 1 writecommand(0x08); //关闭显示
79 1 writecommand(0x06); //显示光标移动设置
80 1 writecommand(0x0c); //显示开及光标移动设置
81 1 writecommand(0x01); //显示清屏
82 1 }
83 /*****************光标定位函数*********************************/
84
85 void display_xy(unsigned char x,unsigned char y)
86 {
87 1 if(y==1)x+=0x40;
88 1 x+=0x80;
89 1 writecommand(x);
90 1 }
91 /*******************显示单个字符函数*************************************************/
92
93 void display_char(unsigned char x,unsigned char y,unsigned char wdata)
94 {
95 1 display_xy(x,y);
96 1 writedata(wdata);
97 1 }
98
99 /******************显示字符串函数************************************************************/
100 void display_string(unsigned char x, unsigned char y, unsigned char code *str)
101
102 {
103 1 display_xy(x,y);
104 1 while(*str)
105 1 {
106 2 writedata(*str);
107 2 str++;
108 2 }
109 1 }
110 /***********等待检测函数*************************/
111 void waitforenable(void)
112 {
113 1 dataport=0xff;
114 1 RS=0;
115 1 RW=1;
116 1 E=1;
117 1 while(dataport & busy);
C51 COMPILER V7.00 1602_1 05/18/2009 11:36:00 PAGE 3
118 1 E=0;
119 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 198 ----
CONSTANT SIZE = 34 ----
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 + -