📄 smc1602.lst
字号:
C51 COMPILER V7.50 SMC1602 08/18/2007 19:09:18 PAGE 1
C51 COMPILER V7.50, COMPILATION OF MODULE SMC1602
OBJECT MODULE PLACED IN .\SMC1602.obj
COMPILER INVOKED BY: D:\Program Files\keil\C51\BIN\C51.EXE ..\SMC1602\SMC1602.c LARGE BROWSE DEBUG OBJECTEXTEND PRINT(.\
-SMC1602.lst) OBJECT(.\SMC1602.obj)
line level source
1 #include"SMC1602.h"
2 #include<intrins.h>
3
4 void SendData(char value)
5 {
6 1 char i;
7 1 LcdClk=0;
8 1 _nop_();
9 1 for(i=0;i<8;i++){
10 2 LcdDat=(bit)(value&0x80);
11 2 LcdClk=0;
12 2 value<<=1;
13 2 LcdClk=1;
14 2 }
15 1 }
16
17 void LcdRead()
18 {
19 1 unsigned char i;
20 1 for(i=0;i<255;i++)
21 1 _nop_();
22 1 }
23 void WriteLcd(unsigned char value,bit RS)
24 {
25 1 LcdRS=RS;
26 1 LcdEn=0;
27 1 SendData(value);
28 1 LcdEn=1;
29 1 }
30
31
32 void WriteCmd(unsigned char value,bit atrrib)
33 { if(atrrib)
34 1 LcdRead();
35 1 WriteLcd(value,0);
36 1 }
37
38 void WriteData(unsigned char value)
39 {
40 1 LcdRead();
41 1 WriteLcd(value,1);
42 1 }
43
44 void InitLcd(void)
45 {
46 1 Delay400Ms();
47 1 WriteCmd(0x38,0);
48 1 Delay5Ms();
49 1 WriteCmd(0x38,0);
50 1 Delay5Ms();
51 1 WriteCmd(0x38,0);
52 1 Delay5Ms();
53 1 WriteCmd(0x38,1);
54 1 WriteCmd(0x08,1); // 先设置关屏
C51 COMPILER V7.50 SMC1602 08/18/2007 19:09:18 PAGE 2
55 1 WriteCmd(0x01,1); // 清屏
56 1 WriteCmd(0x06,1); // 设置光标显示模式
57 1 WriteCmd(0x0c,1); // 开屏并显示光标
58 1 }
59
60 void LocateXY(char x,char y)
61 {
62 1 unsigned char temp;
63 1 temp=x&0x0f;
64 1 if(y&0x1)
65 1 temp|=0x40;
66 1 temp|=0x80;
67 1 WriteCmd(temp,1);
68 1 }
69
70 void PutChar(char x , char y , char value)
71 {
72 1 LocateXY(x,y);
73 1 WriteData(value);
74 1 }
75
76 void PutStr(char x,char y,char * str)
77 {
78 1 unsigned char i,len=0;
79 1 while (str[len] >31)
80 1 len++;
81 1 for (i=0;i<len;i++)
82 1 {
83 2 PutChar(x++,y,str[i]);
84 2 if ( x == 16 )
85 2 {
86 3 x = 0; y ^= 1;
87 3 }
88 2 }
89 1 }
90 /*显示0~99999999之间的整型*/
91 void PutLong(char x,char y,unsigned long F)
92 {
93 1 unsigned char dat[8];
94 1 char i;
95 1 dat[7]=F/10000000;
96 1 dat[6]=(F%10000000)/1000000;
97 1 dat[5]=(F%1000000)/100000;
98 1 dat[4]=(F%100000)/10000;
99 1 dat[3]=(F%10000)/1000;
100 1 dat[2]=(F%1000)/100;
101 1 dat[1]=(F%100)/10;
102 1 dat[0]=F%10;
103 1 if(dat[7]){
104 2 for(i=0;i<8;i++)
105 2 PutChar(x+i,y,48+dat[7-i]);
106 2 }
107 1 else if(dat[6]){
108 2 for(i=0;i<7;i++)
109 2 PutChar(x+i,y,48+dat[6-i]);
110 2 }
111 1 else if(dat[5]){
112 2 for(i=0;i<6;i++)
113 2 PutChar(x+i,y,48+dat[5-i]);
114 2 }
115 1 else if(dat[4]){
116 2 for(i=0;i<5;i++)
C51 COMPILER V7.50 SMC1602 08/18/2007 19:09:18 PAGE 3
117 2 PutChar(x+i,y,48+dat[4-i]);
118 2 }
119 1 else if(dat[3]){
120 2 for(i=0;i<4;i++)
121 2 PutChar(x+i,y,48+dat[3-i]);
122 2 }
123 1 else if(dat[2]){
124 2 for(i=0;i<3;i++)
125 2 PutChar(x+i,y,48+dat[2-i]);
126 2 }
127 1 else if(dat[1]){
128 2 for(i=0;i<2;i++)
129 2 PutChar(x+i,y,48+dat[1-i]);
130 2 }
131 1 else
132 1 PutChar(x,y,48+dat[0]);
133 1
134 1 }
135 /*显示0.001~99999之间的浮点型*/
136 void PutFloat(char x,char y, float F)
137 {
138 1 unsigned long temp,temp1,temp2;
139 1 unsigned char d[8],NumI,NumF;
140 1 temp=(long)(F*1000);
141 1 temp1=(long)F;
142 1 temp2=temp%1000;
143 1 d[7]=temp/10000000;
144 1 d[6]=(temp%10000000)/1000000;
145 1 d[5]=(temp%1000000)/100000;
146 1 d[4]=(temp%100000)/10000;
147 1 d[3]=(temp%10000)/1000;
148 1 d[2]=(temp%1000)/100;
149 1 d[1]=(temp%100)/10;
150 1 d[0]=temp%10;
151 1 if(d[7]) NumI=5;
152 1 else if(d[6]) NumI=4;
153 1 else if(d[5]) NumI=3;
154 1 else if(d[4]) NumI=2;
155 1 else if(d[3]) NumI=1;
156 1 else NumI=1;
157 1 if(d[0]) NumF=3;
158 1 else if(d[1]) NumF=2;
159 1 else if(d[2]) NumF=1;
160 1 else NumF=0;
161 1 switch(NumF){
162 2 case 3: PutLong(x,y,temp1);
163 2 PutChar(x+NumI,y,46);
164 2 PutChar(x+1+NumI,y,48+d[2]);
165 2 PutChar(x+2+NumI,y,48+d[1]);
166 2 PutChar(x+3+NumI,y,48+d[0]);
167 2 break;
168 2 case 2: PutLong(x,y,temp1);
169 2 PutChar(x+NumI,y,46);
170 2 PutChar(x+1+NumI,y,48+d[2]);
171 2 PutChar(x+2+NumI,y,48+d[1]);
172 2 break;
173 2 case 1: PutLong(x,y,temp1);
174 2 PutChar(x+NumI,y,46);
175 2 PutChar(x+1+NumI,y,48+d[2]);
176 2 break;
177 2 case 0: PutLong(x,y,temp1);
178 2 break;
C51 COMPILER V7.50 SMC1602 08/18/2007 19:09:18 PAGE 4
179 2 default:PutLong(x,y,temp1);
180 2 PutChar(x+NumI,y,46);
181 2 PutChar(x+1+NumI,y,48+d[2]);
182 2 }
183 1
184 1
185 1 }
186
187 void Delay5Ms(void)
188 {
189 1 unsigned int i =5552;
190 1 while(i--);
191 1 }
192
193 void Delay400Ms(void)
194 {
195 1 unsigned char i = 80;
196 1 while(i--)
197 1 Delay5Ms();
198 1 }
199
200 void Delay(unsigned char dly)
201 {
202 1 char j;
203 1 for(j=dly;j>0;j--)
204 1 Delay5Ms();
205 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1913 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- 49
PDATA SIZE = ---- ----
DATA SIZE = ---- ----
IDATA SIZE = ---- ----
BIT SIZE = ---- 2
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -