📄 main.lst
字号:
C51 COMPILER V8.02 MAIN 02/21/2009 18:36:44 PAGE 1
C51 COMPILER V8.02, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: D:\单片机\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND
line level source
1 //=========================================
2 //温度传感器18b20测温 2008.4.24
3 // 黄锐
4 //=========================================
5 #include<reg52.h>
6 #include<Lcd1602.h>
7 #include<DS18B20.h>
8 #include<ISD1420.h>
9
10 #define uchar unsigned char
11 #define uint unsigned int
12
13 void temperature_display(uint display_data);
14 void Set_Limit( );
15 uint temperature;
16
17 void main( ) //主函数
18 {
19 1
20 1 uchar stop=0;
21 1 uint temp;
22 1
23 1 TCON=0X01; //设置外中断0边沿触发控制语音报温
24 1 EA=0;
25 1 EX0=1;
26 1
27 1 Lcd1602_Initial( );
28 1 DS18B20_Initial( );
29 1 Lcd1602_Write_String(1,0,"Waiting!");
30 1 Lcd1602_Write_String(2,0,"Set The Limit!");
31 1
32 1 while(1) //死循环
33 1 {
34 2 key_scan( );
35 2
36 2 if(num=='A')
37 2 {
38 3 delay(10,100);
39 3 if(num=='A')
40 3 {
41 4 Lcd1602_Clear_Line(1);
42 4 Lcd1602_Clear_Line(2);
43 4 Lcd1602_Write_String(1,0,"Highlimit is:");
44 4 Lcd1602_Write_String(2,0,"Lowlimit is:");
45 4 Set_Limit( );
46 4 delay(10,100);
47 4 }
48 3
49 3 }
50 2
51 2 if(num=='C')
52 2 {
53 3 Lcd1602_Clear_Line(1);
54 3 Lcd1602_Clear_Line(2);
55 3
C51 COMPILER V8.02 MAIN 02/21/2009 18:36:44 PAGE 2
56 3 while(!stop)
57 3 {
58 4 delay(50,10);
59 4 temperature=Read_temperature( ); //调用读温度函数
60 4 temperature_display(temperature); //调用显示函数
61 4
62 4 if(IE0==1)
63 4 {
64 5 temp = temperature*6.25;
65 5 du_wen(temp);
66 5 IE0=0;
67 5 }
68 4
69 4 if(num=='A')
70 4 stop=1;
71 4 }
72 3 }
73 2 }
74 1
75 1 }
76 //=============================================
77 //设置温度上下限函数
78 //=============================================
79 void Set_Limit( )
80 {
81 1 uchar stop=0;
82 1 uchar Highlimit_shi=0;
83 1 uchar Highlimit_ge=0;
84 1 uchar Lowlimit_shi=0;
85 1 uchar Lowlimit_ge=0;
86 1
87 1 while(!stop)
88 1 {
89 2 num=key_scan( );
90 2 if(num=='0')
91 2 {
92 3 delay(10,100);
93 3
94 3 if(num=='0')
95 3 {
96 4 Highlimit_shi++;
97 4 if(Highlimit_shi==10)
98 4 Highlimit_shi=0;
99 4 }
100 3 }
101 2
102 2 delay(10,100);
103 2 Lcd1602_Write_Data(1,14,Highlimit_shi+'0');
104 2 delay(10,100);
105 2
106 2 if(num=='1')
107 2 {
108 3 delay(10,100);
109 3
110 3 if(num=='1')
111 3 {
112 4 Highlimit_ge++;
113 4 if(Highlimit_ge==10)
114 4 Highlimit_ge=0;
115 4 }
116 3 }
117 2
C51 COMPILER V8.02 MAIN 02/21/2009 18:36:44 PAGE 3
118 2 delay(10,100);
119 2 Lcd1602_Write_Data(1,15,Highlimit_ge +'0');
120 2 delay(10,100);
121 2
122 2 if(num=='2')
123 2 {
124 3 delay(10,100);
125 3
126 3 if(num=='2')
127 3 {
128 4 Lowlimit_shi++;
129 4 if(Lowlimit_shi==10)
130 4 Lowlimit_shi=0;
131 4 }
132 3 }
133 2
134 2 delay(10,100);
135 2 Lcd1602_Write_Data(2,14,Lowlimit_shi+'0');
136 2 delay(10,100);
137 2
138 2 if(num=='3')
139 2 {
140 3 delay(10,100);
141 3
142 3 if(num=='3')
143 3 {
144 4 Lowlimit_ge++;
145 4 if(Lowlimit_ge==10)
146 4 Lowlimit_ge=0;
147 4 }
148 3 }
149 2
150 2 delay(10,100);
151 2 Lcd1602_Write_Data(2,15,Lowlimit_ge+'0');
152 2 delay(10,100);
153 2
154 2 if(num=='B')
155 2 {
156 3 Highlimit = Highlimit_shi*10+Highlimit_ge-1; //此处有误差1°
157 3 Lowlimit = Lowlimit_shi*10+Lowlimit_ge;
158 3 }
159 2
160 2 if(num=='C')
161 2 stop=1;
162 2 }
163 1
164 1 }
165 //=================================================================
166 //显示温度值及报警提示函数
167 //=================================================================
168 void temperature_display(uint display_data) //显示函数
169 {
170 1 uint Temp,Temp2;
171 1 uchar t[5]; //存放温度值数组
172 1
173 1 Temp=display_data*6.25; //最小分辨率0.0625,在此先放大100倍
174 1
175 1 t[0]=Temp/1000; //温度十位
176 1 t[1]=Temp%1000/100; //温度个位
177 1 t[2]='.'-'0';
178 1 t[3]=Temp%1000%100/10; //温度十分位
179 1 t[4]=Temp%1000%100%10; //温度百位
C51 COMPILER V8.02 MAIN 02/21/2009 18:36:44 PAGE 4
180 1 Temp2=Temp/100;
181 1
182 1 if(Temp2>Highlimit) //上限报警
183 1 {
184 2 Lcd1602_Clear_Line(1);
185 2 delay(100,100);
186 2 Lcd1602_Write_String(1,0,"tempe is high!");
187 2
188 2 }
189 1
190 1 else if (Temp2<Lowlimit) //下限报警
191 1 {
192 2 Lcd1602_Clear_Line(1);
193 2 delay(100,100);
194 2 Lcd1602_Write_String(1,0,"tempe is low!");
195 2
196 2 }
197 1
198 1 else
199 1 {
200 2 Lcd1602_Write_String(1,0,"tempe is normal!");
201 2 }
202 1
203 1 Lcd1602_Write_String(2,0,"tempe is:");
204 1 Lcd1602_Write_Data(2,9, t[0]+'0');
205 1 Lcd1602_Write_Data(2,10,t[1]+'0');
206 1 Lcd1602_Write_Data(2,11,t[2]+'0');
207 1 Lcd1602_Write_Data(2,12,t[3]+'0');
208 1 Lcd1602_Write_Data(2,13,t[4]+'0');
209 1 Lcd1602_Write_Data(2,14,0xdf);
210 1 Lcd1602_Write_Data(2,15,'C');
211 1
212 1 }
213
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1746 ----
CONSTANT SIZE = 141 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 8 29
IDATA SIZE = ---- ----
BIT SIZE = 1 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -