📄 毕设程序2.lst
字号:
C51 COMPILER V8.02 毕设程序2 05/21/2008 13:50:02 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE 毕设程序2
OBJECT MODULE PLACED IN 毕设程序2.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE 毕设程序2.c BROWSE DEBUG OBJECTEXTEND
line level source
1 /*while(1)
2 {delay(1000)
3 temp=_crol_(temp,1); //循环左移函数 ,包含在intrins文件中。
4 P1=temp;
5 }*/
6 #include<reg52.h> //<>表示先找库的,再找工程文件夹的;“”先找工程文件夹的,再找库的;
7 #include<absacc.h>
8 #include<1602LCD.h>
9 #include<intrins.h>
10 #define uchar unsigned char
11 #define uint unsigned int
12 #define ulong unsigned long
13
14 #define addata P0
15 uchar m,t0,t1,flag,flag1,flag2,ADH,ADL,ADH0,ADL0;
16 int u;
17 ulong sum;
18
19 uchar code wel[]={"-temperature?--"};//液晶显示字符
20 uchar code pt[]={"----Pt100?----"};
21 uchar code K[]={"----K?----"};
22 uchar code LM35[]={"----LM35----"};
23
24 uchar code num[]={"0123456789"};
25 uchar data ad_data[2]={0x00,0x00}; //用于存储AD转换后的数据
26 ulong data temperature[]={0x00,0x00,0x00};
27 uint data dis[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}; //要显示的数
28 sbit P14=P1^4;
29 sbit P15=P1^5;
30 sbit P13=P1^3;
31 sbit OE=P2^6;
32
33
34 //控制MAX197转换的端口 ,送模拟信号输入端口地址,启动转换
35 sbit MAX197_CS=P1^6;
36 sbit HBEN=P1^7;
37 sbit wr=P3^6;
38 sbit rd=P3^7;
39
40 //控制热电偶数据输入端口
41 sbit SO=P1^0; //串行数据输出端
42 sbit CS=P1^1; //片选信号,低电平串行接口有效
43 sbit SCK=P1^2; //串行时钟输入端
44
45 void display(uint m);
46 //void delay1(uint c);//delay1()函数声明
47 void delay(uint z); //delay()函数声明
48 void admax197();
49 void K_read();
50 void init();
51 void display3();
52 void display2();
53 void display1();
54 void main()
55 {
C51 COMPILER V8.02 毕设程序2 05/21/2008 13:50:02 PAGE 2
56 1 init();
57 1 while(1)
58 1 {
59 2 if(P14&&P15!=0) //LM35
60 2 {
61 3
62 3 admax197();
63 3 display1();
64 3 }
65 2
66 2 if (P14==0) //PT100
67 2 {
68 3 delay(10);
69 3 if(P14==0)
70 3 {
71 4 while(flag!=1)
72 4 {
73 5 admax197();
74 5 display2();
75 5 }
76 4 }
77 3 }
78 2 if (P15==0) //K
79 2 {
80 3 delay(10);
81 3 if(P15==0)
82 3 {
83 4 K_read();
84 4 display3();
85 4 }
86 3
87 3
88 3 }
89 2 }
90 1 }
91
92
93 void init() //初始化
94 {
95 1 P0=0xff;
96 1 P1=0xff;
97 1 P2=0x00;
98 1 P3=0xff;
99 1
100 1 delay(255); //启动等待,等LCM进入工作状态
101 1 LCMInit(); //LCM初始化
102 1 delay(5); //延时片刻(可不要)
103 1 ReadDataLCM(); //测试用句无意义
104 1 DisplayListChar(0,0,wel); //0列0行开始显示
105 1
106 1 TMOD=0x01;
107 1 // TH0=(65536-50000)/256;
108 1 TL0=(65536-50000)%256;
109 1 // TH1=(65536-50000)/256;
110 1 TL1=(65536-50000)%256;
111 1 EA=1;
112 1 ET0=1;
113 1 // ET1=1;
114 1 TR0=1;
115 1 // TR1=1;
116 1 }
117
C51 COMPILER V8.02 毕设程序2 05/21/2008 13:50:02 PAGE 3
118 void delay(uint z) //延时子程序,z=1时延时1ms
119 {
120 1 uint x,y;
121 1 for(x=z;x>0;x--)
122 1 for(y=110;y>0;y--);
123 1 }
124
125 void admax197() // AD转换使用通道0 ----LM35;
126 {
127 1
128 1 P0=0x50;
129 1 MAX197_CS=0;
130 1 _nop_();
131 1 wr=0;
132 1 _nop_();
133 1 wr=1;
134 1 _nop_();
135 1 _nop_();
136 1 while(INT0==1);
137 1 HBEN=0;
138 1 rd=0;
139 1 ad_data[0]=addata ;
140 1 HBEN=1;
141 1 ad_data[1]=addata&0x0f;
142 1 sum=ad_data[1]*256+ad_data[0];
143 1 rd=1;
144 1 }
145
146
147
148
149 void timer0() interrupt 1 //定时器0溢出中断50ms定时
150 {
151 1
152 1 TH0=(65536-50000)/256;
153 1 TL0=(65536-50000)%256;
154 1 t0++;
155 1 if(t0==1000) //定时50s
156 1 {
157 2 t0=0;
158 2 flag=1;
159 2 }
160 1 }
161
162 //void timer1() interrupt 3
163 //{TH1=(65536-50000)/256;
164 // TL1=(65536-50000)%256;
165 // t1++;
166 // if(t1==2000) //定时100s
167 // {
168 // t1=0;
169 // flag1=1;
170 // }
171 //}
172
173
174 void display1()
175 {
176 1
177 1 uint i;
178 1 uchar x;
179 1 temperature[0]=10000*sum/4095;
C51 COMPILER V8.02 毕设程序2 05/21/2008 13:50:02 PAGE 4
180 1 DisplayListChar(0,0,LM35); //0列0行开始显示
181 1
182 1 dis[0]=temperature[0]/1000;
183 1 dis[4]=temperature[0]%1000;
184 1 dis[1]=dis[4]/100;
185 1
186 1
187 1 dis[4]=dis[4]%100;
188 1 dis[2]=dis[4]/10;
189 1 dis[3]=dis[4]%10;
190 1
191 1 x=10;
192 1
193 1 for(i=3,x=10;i>=0;i--)
194 1 {
195 2 if(x==8)
196 2 {
197 3 DisplayOneChar(x,1,'.');x--;
198 3 }
199 2 DisplayOneChar(x, 1, num[dis[i]]);
200 2 x--;
201 2 }
202 1 }
203
204 void display2()
205 {
206 1 uint i;
207 1 uchar x;
208 1 temperature[1]=sum; //要改的
209 1 DisplayListChar(0,0,pt); //0列0行开始显示
210 1
211 1 dis[0]=temperature[1]/51;
212 1 dis[4]=temperature[1]%51;
213 1 dis[4]=dis[4]*10;
214 1 dis[1]=dis[4]/51;
215 1 dis[4]=dis[4]%51;
216 1 dis[4]=dis[4]*10;
217 1 dis[2]=dis[4]/51;
218 1
219 1 x=10;
220 1
221 1 for(i=2,x=10;i>=0;i--)
222 1 {
223 2 if(x==8)
224 2 {
225 3 DisplayOneChar(x,1,'.');x--;
226 3 }
227 2 DisplayOneChar(x, 1, num[dis[i]]);
228 2 x--;
229 2 }
230 1 }
231
232 void display3()
233 {
234 1 uint i;
235 1 uchar x;
236 1 temperature[0]=100*1023.75*u/4095; //要改的
237 1
238 1 dis[0]=temperature[0]/100000;
239 1 dis[7]=temperature[0]%100000;
240 1 dis[1]=dis[7]/10000;
241 1 dis[7]=dis[7]%10000;
C51 COMPILER V8.02 毕设程序2 05/21/2008 13:50:02 PAGE 5
242 1 dis[2]=dis[7]/1000;
243 1 dis[7]=dis[7]%1000;
244 1 dis[3]=dis[7]/100;
245 1 dis[7]=dis[7]%100;
246 1 dis[4]=dis[7]/10;
247 1 dis[5]=dis[7]%10;
248 1 x=10;
249 1 for(i=5,x=10;i>=0;i--)
250 1 {
251 2 if(x==8)
252 2 {
253 3 DisplayOneChar(x,1,'.');x--;
254 3 }
255 2 DisplayOneChar(x, 1, num[dis[i]]);
256 2 x--;
257 2 }
258 1 }
259
260 /*…………热电偶信号处理…………*/
261
262 void K_read(void)
263 {
264 1 unsigned char i,j;
265 1
266 1 ADH=ADL=0;
267 1 SCK=0;
268 1 CS=0;
269 1
270 1 SCK=1;
271 1 CS=0;
272 1 SCK=0; /*输出数据D15*/
273 1 SCK=1;
274 1
275 1 for(i=4;i>0;i--) /*读取转换结果高4位*/
276 1 {
277 2 SCK=0;
278 2 ADH0=SO;
279 2
280 2 if(ADH0==1)
281 2 {ADH=ADH<<1;
282 3 ADH=ADH||0x01;
283 3 }
284 2 else
285 2 ADH=ADH<<1; /*数据位左移*/
286 2 SCK=1;
287 2
288 2 }
289 1
290 1 for(j=8;j>0;j++)
291 1 /*读取转换结果低8位*/
292 1 {
293 2 SCK=0;
294 2 ADL0=SO;
295 2
296 2 if(ADL0==1)
297 2 {ADL=ADL<<1;
298 3 ADL=ADL||0x01;
299 3 }
300 2 else
301 2 ADL=ADL<<1; /*数据左移*/
302 2 SCK=1;
303 2 }
C51 COMPILER V8.02 毕设程序2 05/21/2008 13:50:02 PAGE 6
304 1 SCK=0;
305 1 flag2=SO; /*读取D2断偶标志*/
306 1 SCK=1;
307 1 SCK=0; /*输出数据D0*/
308 1 CS=1;
309 1 delay(10);
310 1 u=ADH*256+ADL;
311 1 }
312
313
314 // 温度值= 1 023.75 ×转换后的数字量/ 4 095
315
316
317
318
319
320
321
322
323
324
325
326
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1290 ----
CONSTANT SIZE = 83 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 46 17
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 + -