|
|
C51 COMPILER V9.56.0.0 LCD 04/29/2022 00:07:44 PAGE 1 |
|
|
|
|
|
|
|
|
C51 COMPILER V9.56.0.0, COMPILATION OF MODULE LCD |
|
|
OBJECT MODULE PLACED IN lcd.OBJ |
|
|
COMPILER INVOKED BY: D:\Keil_v5\C51\BIN\C51.EXE lcd.c OPTIMIZE(8,SPEED) BROWSE DEBUG OBJECTEXTEND TABS(2) |
|
|
|
|
|
line level source |
|
|
|
|
|
1 #include"lcd.h" |
|
|
2 |
|
|
3 /******************************************************************************* |
|
|
4 * 函 数 名 : Lcd1602_Delay1ms |
|
|
5 * 函数功能 : 延时函数,延时1ms |
|
|
6 * 输 入 : c |
|
|
7 * 输 出 : 无 |
|
|
8 * 说 名 : 该函数是在12MHZ晶振下,12分频单片机的延时。 |
|
|
9 *******************************************************************************/ |
|
|
10 |
|
|
11 void Lcd1602_Delay1ms(uint c) //误差 0us |
|
|
12 { |
|
|
13 1 uchar a,b; |
|
|
14 1 for (; c>0; c--) |
|
|
15 1 { |
|
|
16 2 for (b=199;b>0;b--) |
|
|
17 2 { |
|
|
18 3 for(a=1;a>0;a--); |
|
|
19 3 } |
|
|
20 2 } |
|
|
21 1 |
|
|
22 1 } |
|
|
23 |
|
|
24 /******************************************************************************* |
|
|
25 * 函 数 名 : LcdWriteCom |
|
|
26 * 函数功能 : 向LCD写入一个字节的命令 |
|
|
27 * 输 入 : com |
|
|
28 * 输 出 : 无 |
|
|
29 *******************************************************************************/ |
|
|
30 #ifndef LCD1602_4PINS //当没有定义这个LCD1602_4PINS时 |
|
|
31 void LcdWriteCom(uchar com) //写入命令 |
|
|
32 { |
|
|
33 1 LCD1602_E = 0; //使能 |
|
|
34 1 LCD1602_RS = 0; //选择发送命令 |
|
|
35 1 LCD1602_RW = 0; //选择写入 |
|
|
36 1 |
|
|
37 1 LCD1602_DATAPINS = com; //放入命令 |
|
|
38 1 Lcd1602_Delay1ms(1); //等待数据稳定 |
|
|
39 1 |
|
|
40 1 LCD1602_E = 1; //写入时序 |
|
|
41 1 Lcd1602_Delay1ms(5); //保持时间 |
|
|
42 1 LCD1602_E = 0; |
|
|
43 1 } |
|
|
44 #else |
|
|
void LcdWriteCom(uchar com) //写入命令 |
|
|
{ |
|
|
LCD1602_E = 0; //使能清零 |
|
|
LCD1602_RS = 0; //选择写入命令 |
|
|
LCD1602_RW = 0; //选择写入 |
|
|
|
|
|
LCD1602_DATAPINS = com; //由于4位的接线是接到P0口的高四位,所以传送高四位不用改 |
|
|
Lcd1602_Delay1ms(1); |
|
|
|
|
|
LCD1602_E = 1; //写入时序 |
|
|
Lcd1602_Delay1ms(5); |
|
|
C51 COMPILER V9.56.0.0 LCD 04/29/2022 00:07:44 PAGE 2 |
|
|
|
|
|
LCD1602_E = 0; |
|
|
|
|
|
// Lcd1602_Delay1ms(1); |
|
|
LCD1602_DATAPINS = com << 4; //发送低四位 |
|
|
Lcd1602_Delay1ms(1); |
|
|
|
|
|
LCD1602_E = 1; //写入时序 |
|
|
Lcd1602_Delay1ms(5); |
|
|
LCD1602_E = 0; |
|
|
} |
|
|
#endif |
|
|
67 /******************************************************************************* |
|
|
68 * 函 数 名 : LcdWriteData |
|
|
69 * 函数功能 : 向LCD写入一个字节的数据 |
|
|
70 * 输 入 : dat |
|
|
71 * 输 出 : 无 |
|
|
72 *******************************************************************************/ |
|
|
73 #ifndef LCD1602_4PINS |
|
|
74 void LcdWriteData(uchar dat) //写入数据 |
|
|
75 { |
|
|
76 1 LCD1602_E = 0; //使能清零 |
|
|
77 1 LCD1602_RS = 1; //选择输入数据 |
|
|
78 1 LCD1602_RW = 0; //选择写入 |
|
|
79 1 |
|
|
80 1 LCD1602_DATAPINS = dat; //写入数据 |
|
|
81 1 Lcd1602_Delay1ms(1); |
|
|
82 1 |
|
|
83 1 LCD1602_E = 1; //写入时序 |
|
|
84 1 Lcd1602_Delay1ms(5); //保持时间 |
|
|
85 1 LCD1602_E = 0; |
|
|
86 1 } |
|
|
87 #else |
|
|
void LcdWriteData(uchar dat) //写入数据 |
|
|
{ |
|
|
LCD1602_E = 0; //使能清零 |
|
|
LCD1602_RS = 1; //选择写入数据 |
|
|
LCD1602_RW = 0; //选择写入 |
|
|
|
|
|
LCD1602_DATAPINS = dat; //由于4位的接线是接到P0口的高四位,所以传送高四位不用改 |
|
|
Lcd1602_Delay1ms(1); |
|
|
|
|
|
LCD1602_E = 1; //写入时序 |
|
|
Lcd1602_Delay1ms(5); |
|
|
LCD1602_E = 0; |
|
|
|
|
|
LCD1602_DATAPINS = dat << 4; //写入低四位 |
|
|
Lcd1602_Delay1ms(1); |
|
|
|
|
|
LCD1602_E = 1; //写入时序 |
|
|
Lcd1602_Delay1ms(5); |
|
|
LCD1602_E = 0; |
|
|
} |
|
|
#endif |
|
|
109 /******************************************************************************* |
|
|
110 * 函 数 名 : LcdInit() |
|
|
111 * 函数功能 : 初始化LCD屏 |
|
|
112 * 输 入 : 无 |
|
|
113 * 输 出 : 无 |
|
|
114 *******************************************************************************/ |
|
|
115 #ifndef LCD1602_4PINS |
|
|
116 void LcdInit() //LCD初始化子程序 |
|
|
117 { |
|
|
C51 COMPILER V9.56.0.0 LCD 04/29/2022 00:07:44 PAGE 3 |
|
|
|
|
|
118 1 LcdWriteCom(0x38); //开显示 |
|
|
119 1 LcdWriteCom(0x0c); //开显示不显示光标 |
|
|
120 1 LcdWriteCom(0x06); //写一个指针加1 |
|
|
121 1 LcdWriteCom(0x01); //清屏 |
|
|
122 1 LcdWriteCom(0x80); //设置数据指针起点 |
|
|
123 1 } |
|
|
124 #else |
|
|
void LcdInit() //LCD初始化子程序 |
|
|
{ |
|
|
LcdWriteCom(0x32); //将8位总线转为4位总线 |
|
|
LcdWriteCom(0x28); //在四位线下的初始化 |
|
|
LcdWriteCom(0x0c); //开显示不显示光标 |
|
|
LcdWriteCom(0x06); //写一个指针加1 |
|
|
LcdWriteCom(0x01); //清屏 |
|
|
LcdWriteCom(0x80); //设置数据指针起点 |
|
|
} |
|
|
#endif |
|
|
|
|
|
|
|
|
MODULE INFORMATION: STATIC OVERLAYABLE |
|
|
CODE SIZE = 87 ---- |
|
|
CONSTANT SIZE = ---- ---- |
|
|
XDATA SIZE = ---- ---- |
|
|
PDATA SIZE = ---- ---- |
|
|
DATA SIZE = ---- ---- |
|
|
IDATA SIZE = ---- ---- |
|
|
BIT SIZE = ---- ---- |
|
|
END OF MODULE INFORMATION. |
|
|
|
|
|
|
|
|
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
|
|
|
|