📄 lcd.lst
字号:
C51 COMPILER V7.06 LCD 09/13/2007 01:39:04 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE LCD
OBJECT MODULE PLACED IN LCD.OBJ
COMPILER INVOKED BY: C:\tools\Keil\C51\BIN\C51.EXE LCD.C BROWSE DEBUG OBJECTEXTEND
stmt level source
1 /*实验名称:字符型LCD接口实验
2 功能:在LCD上显示
3 AT89S51 DEMO
4 www.mcuprog.com
5 作者:http://www.mcuprog.com
6 05-02-01
7 */
8 #include <reg51.h>
9 sbit E=P2^2;
10 sbit RW=P2^1;
11 sbit RS=P2^0;
12 typedef unsigned char uchar;
13 //-------------------------------------
14 void Delay(unsigned int t) // delay 40us
15 {
16 1 for(;t!=0;t--) ;
17 1 }
18 //=============================================
19 void SendCommandByte(unsigned char ch)
20 {
21 1 RS=0;
22 1 RW=0;
23 1 P0=ch;
24 1 E=1;
25 1 Delay(1);
26 1 E=0;
27 1 Delay(100); //delay 40us
28 1 }
29 //-------------------------------------------------------
30 void SendDataByte(unsigned char ch)
31 { RS=1;
32 1 RW=0;
33 1 P0=ch;
34 1 E=1;
35 1 Delay(1);
36 1 E=0;
37 1 Delay(100); //delay 40us
38 1 }
39 //-------------------------------------------------
40 void InitLcd()
41 {SendCommandByte(0x30);
42 1 SendCommandByte(0x30);
43 1 SendCommandByte(0x30);
44 1 SendCommandByte(0x38); //设置工作方式
45 1 SendCommandByte(0x0c); //显示状态设置
46 1 SendCommandByte(0x01); //清屏
47 1 SendCommandByte(0x06); //输入方式设置
48 1 }
49 //=============================================
50 void DisplayMsg1(uchar *p)
51 {
52 1 unsigned char count;
53 1 SendCommandByte(0x80); //设置DDRAM地址
54 1 for(count=0;count<16;count++)
55 1 {SendDataByte(*p++);
C51 COMPILER V7.06 LCD 09/13/2007 01:39:04 PAGE 2
56 2 }
57 1 }
58 //=============================================
59 void DisplayMsg2(uchar *p)
60 {
61 1 unsigned char count;
62 1 SendCommandByte(0xc0); //设置DDRAM地址
63 1 for(count=0;count<16;count++)
64 1 {SendDataByte(*p++);
65 2 }
66 1 }
67 //=============================================
68 main()
69 {char msg1[16]=" AT89S51 DEMO ";
70 1 char msg2[16]="www.mcuprog.com ";
71 1 InitLcd();
72 1 DisplayMsg1(msg1);
73 1 DisplayMsg2(msg2);
74 1 while(1);
75 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 218 ----
CONSTANT SIZE = 32 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 38
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 + -