?? lcd.lst
字號:
C51 COMPILER V8.02 LCD 01/14/2009 21:15:27 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE LCD
OBJECT MODULE PLACED IN LCD.OBJ
COMPILER INVOKED BY: D:\單片機\C51\BIN\C51.EXE LCD.c BROWSE DEBUG OBJECTEXTEND
line level source
1 #include <c8051f020.h>
2 #include "initial.h"
3 //---------------------------------
4 //#define uchar unsigned char
5 //#define uint unsigned int
6 //--------------------------------
7 //bit bf=0;
8 #define uchar unsigned char
9
10 void Lcd1602_Initial( )
11 {
12 1 Lcd1602_Write_Command(0x38);//顯示模式設置
13 1 Lcd1602_Write_Command(0x0c);//開顯示,顯示光標,光標閃爍
14 1 Lcd1602_Write_Command(0x01);//顯示清屏。
15 1 Lcd1602_Write_Command(0x06);//顯示光標自動右移,整屏不移動。
16 1
17 1 Lcd1602_Write_Command(0x80);//將數據指針設置到第一行的第一個字符。
18 1 Lcd1602_Write_Command(0x02);//數據指針清零
19 1 Lcd1602_Write_Command(0x0c);//開顯示,顯示光標,光標閃爍
20 1 Lcd1602_Write_Command(0x80);//將數據指針設置到第一行的第一個字符。
21 1
22 1 }
23 //===========================
24 //寫一個命令字節
25 //===========================
26 void Lcd1602_Write_Command(uchar Command_Code)
27 {
28 1 P4=0x00;
29 1 delay(1); //寫指令 RS=0
30 1 P4=0x04;
31 1 P5=Command_Code; //送數據
32 1 delay(1);
33 1 P4=0x00;
34 1 }
35 //===========================
36 //寫一個字節數據
37 //===========================
38 void Lcd1602_Write_Data(uchar row,uchar column,uchar digital)
39 {
40 1
41 1 if (row==2)
42 1 column |= 0x40; //當要顯示第二行時地址碼+0x40;
43 1 column |= 0x80; // 算出指令碼
44 1
45 1 Lcd1602_Write_Command(column); //這里不檢測忙信號,發送地址碼
46 1
47 1 P4=0x01;
48 1 delay(1); //寫指令 RS=0
49 1 P4=0x05;
50 1 P5=digital; //送數據
51 1 delay(1);
52 1 P4=0x00;
53 1
54 1 }
55
C51 COMPILER V8.02 LCD 01/14/2009 21:15:27 PAGE 2
56
57 //===========================================
58 //寫字符串到LCD,如果一行寫不下,則寫到下一行,
59 //如果一屏寫不下,則只寫一屏
60 //row的值從1-2,column的值從1-16,不進行值的
61 //有效性檢查,有調用者自己保證
62 //===========================================
63
64 void Lcd1602_Write_String(uchar row,uchar column,uchar *dis_buffer)
65 {
66 1 uchar i=0;
67 1
68 1 while(dis_buffer[i]!='\0')
69 1 {
70 2 Lcd1602_Write_Data(row,column,dis_buffer[i]);
71 2 i++;column++;
72 2 if(column==40)
73 2 {
74 3 column=1;
75 3 row++;
76 3 if(row==2)
77 3 return;
78 3 else
79 3 {
80 4 switch(row) //這種結構保持以后升級到多行顯示液晶
81 4 {
82 5 case 1:Lcd1602_Write_Command(0x80);break;
83 5 case 2:Lcd1602_Write_Command(0x80+0x40);break;//重新調整數據地址指針
84 5 default:break;
85 5 }
86 4 }
87 3 }
88 2 }
89 1 }
90
91
92 //==================================================
93 //清除指定的位置的字符,光標返回最左邊第一個字符位置
94 //==================================================
95 /*void Lcd1602_Clear_Char(uchar row,uchar column)
96 {
97 Lcd1602_Write_String(row,column," ");
98 }
99
100 //==========================================
101 //清除指定的行,光標返回最左邊第一個字符位置
102 //========================================== */
103 void Lcd1602_Clear_Line(uchar line)
104 {
105 1 Lcd1602_Write_String(line,0," ");
106 1 switch(line)//這種結構保持以后升級到多行顯示液晶
107 1 {
108 2 case 1:Lcd1602_Write_Command(0x80);break; //將數據地址指針定位到第一行
109 2 case 2:Lcd1602_Write_Command(0x80+0x40);break; //將數據地址指針定位到第二行
110 2 default: break;
111 2 }
112 1 }
113
114 void Lcd1602_Clear_All( )
115 {
116 1 Lcd1602_Write_Command(0x01);//顯示清屏。
117 1 Lcd1602_Write_Command(0x80);//將數據指針設置到第一行的第一個字符。
C51 COMPILER V8.02 LCD 01/14/2009 21:15:27 PAGE 3
118 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 234 ----
CONSTANT SIZE = 17 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = ---- 9
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 + -