?? lcd.lst
字號:
C51 COMPILER V8.09 LCD 06/14/2008 17:45:51 PAGE 1
C51 COMPILER V8.09, COMPILATION OF MODULE LCD
OBJECT MODULE PLACED IN LCD.OBJ
COMPILER INVOKED BY: d:\Keil\C51\BIN\C51.EXE LCD.C BROWSE DEBUG OBJECTEXTEND
line 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=P3^5;
10 sbit RW=P3^6;
11 sbit RS=P3^7;
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<40;count++)
55 1 {SendDataByte(*p++);
C51 COMPILER V8.09 LCD 06/14/2008 17:45:51 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<40;count++)
64 1 {SendDataByte(*p++);
65 2 }
66 1 }
67 //=============================================
68 main()
69 {char msg1[40]=" AT89S51 DEMO 123789009876554322111111";
70 1 char msg2[40]="www.mcuprog.com 123457890098987776111116";
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 = 80 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 86
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 + -