📄 1602.lst
字号:
C51 COMPILER V7.06 1602 11/17/2007 00:19:47 PAGE 1
C51 COMPILER V7.06, COMPILATION OF MODULE 1602
OBJECT MODULE PLACED IN 1602.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE 1602.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include <reg51.h>
2 #define LCDIO P0
3 sbit LCD1602_RS=P1^5;
4 sbit LCD1602_RW=P1^4;
5 sbit LCD1602_EN=P1^3;
6
7 void LCD_delay(void)//使用延时函数代替busy check 该延时函数 使用for语句不能作为精确延时通用函数
8 {
9 1 unsigned char i;
10 1 for(i=40;i>0;i--)
11 1 ;
12 1 }
13
14 void LCD_en_command(unsigned char command)
15 {
16 1 LCDIO=command;
17 1 LCD1602_RS=0;
18 1 LCD1602_RW=0;
19 1 LCD1602_EN=0;
20 1 LCD_delay();
21 1 LCD1602_EN=1;
22 1 }
23
24
25 void LCD_en_dat(unsigned char dat)
26 {
27 1 LCD1602_RS=1;
28 1 LCD1602_RW=0;
29 1 LCD1602_EN=0;
30 1 LCD_delay();
31 1 LCDIO=dat;
32 1 LCD1602_EN=1;
33 1 }
34
35
36 void LCD_set_xy( unsigned char x, unsigned char y )
37 {
38 1 unsigned char address;
39 1 if (y == 0)
40 1 address = 0x80 + x;
41 1 else
42 1 address = 0xC0 + x;
43 1 LCD_en_command(address);
44 1 }
45
46
47 void LCD_write_char( unsigned x,unsigned char y,unsigned char dat)
48 {
49 1 LCD_set_xy( x, y );
50 1 LCD_en_dat(dat);
51 1 }
52
53
54 void LCD_write_string(unsigned char X,unsigned char Y,unsigned char *s)
55 {
C51 COMPILER V7.06 1602 11/17/2007 00:19:47 PAGE 2
56 1 LCD_set_xy( X, Y );
57 1 while (*s)
58 1 {
59 2 LCDIO=*s;
60 2 LCD_en_dat(*s);
61 2 s ++;
62 2 }
63 1 }
64
65
66 void delay_nms(unsigned int n)//长延时函数,同样不能作为精确延时的用函数
67 {
68 1 unsigned int i=0,j=0;
69 1 for (i=n;i>0;i--)
70 1 for (j=0;j<1140;j++);
71 1 }
72
73
74 void LCD_init(void)//初始化函数 具体见 hd44780的命令详解
75 {
76 1 LCD_en_command(0x01);
77 1 delay_nms(5);
78 1 LCD_en_command(0x38);
79 1 delay_nms(5);
80 1 LCD_en_command(0x38);
81 1 delay_nms(5);
82 1 LCD_en_command(0x38);
83 1 delay_nms(5);
84 1 LCD_en_command(0xC0);
85 1 delay_nms(5);
86 1 LCD_en_command(0x80);
87 1 delay_nms(5);
88 1 LCD_en_command(0x01);
89 1 delay_nms(5);
90 1 }
91
92
93 void main(void)
94 {
95 1 LCD_init();
96 1 while(1)
97 1 {
98 2 //CLEARSCREEN;
99 2 delay_nms(2);
100 2 LCD_write_string(0,0," bg8wj");
101 2 LCD_write_string(0,1," cdrom contral ");
102 2 }
103 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 208 ----
CONSTANT SIZE = 23 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
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 + -