C51 COMPILER V9.56.0.0 MAIN 04/08/2023 13:48:13 PAGE 1 C51 COMPILER V9.56.0.0, COMPILATION OF MODULE MAIN OBJECT MODULE PLACED IN .\Objects\main.obj COMPILER INVOKED BY: C:\Keil_v5\C51\BIN\C51.EXE user\main.c OPTIMIZE(8,SPEED) BROWSE INCDIR(.\user) DEBUG OBJECTEXTEND P -RINT(.\Listings\main.lst) TABS(2) OBJECT(.\Objects\main.obj) line level source 1 #include 2 #include "stdio.h" 3 #include "string.h" 4 #include "Timer.h" 5 #include "bsp_seg.h" 6 #include "bsp_key.h" 7 #include "ds1302.h" 8 #include "onewire.h" 9 #include "ne555.h" 10 #include "iic.h" 11 #include "bsp_led.h" 12 13 unsigned char seg_string[10]; 14 unsigned char seg_buf[8]; 15 unsigned char pos; 16 17 unsigned char Key_Value; 18 unsigned char Key_Old,Key_Down,Key_UP; 19 20 unsigned char ucled; 21 22 unsigned int Seg_Slow_down; 23 unsigned int Key_Slow_down; 24 25 unsigned char n=0;//触发次数 26 unsigned char res;//光敏电阻 27 unsigned char res_old; 28 unsigned char ds_time[3]={55,55,23};//ds1302时间 29 unsigned int temptuer;//温度 30 unsigned int count;//ne555频率 31 unsigned int ne555_count; 32 unsigned int ne555_time;//ne555时间参数 33 unsigned char ne555_shidu; 34 unsigned int temptuer_old; 35 unsigned int ne555_shidu_old; 36 unsigned int t_pcf;//采样间隔时间 37 unsigned char cai_h; 38 unsigned char cai_m; 39 unsigned int t_2s; 40 41 42 unsigned int temptuer_num; 43 unsigned int ne555_shidu_num; 44 45 46 unsigned char wendu=30;//温度设定参数 47 unsigned char shidu=68;//湿度设定参数 48 49 unsigned char jiemian_flag;//界面参数 50 unsigned char huixian_flag;//回显界面参数 51 unsigned char cai_flag; //采集标志位 52 bit t_flag=0; 53 //bit ne555_flag;//ne555标志位 54 bit bit_flag; C51 COMPILER V9.56.0.0 MAIN 04/08/2023 13:48:13 PAGE 2 55 bit flag2; 56 57 void Seg_Proc(); 58 void Key_Proc(); 59 void Led_Proc(); 60 61 62 void main() 63 { 64 1 Initsystem(); 65 1 Timer1Init(); 66 1 Timer0Init(); 67 1 EA=1; 68 1 write_ds13(ds_time); 69 1 temptuer=read_temptuer()/16; 70 1 res_old=Read_Pcf8591(0x01); 71 1 res=Read_Pcf8591(0x01); 72 1 while(1) 73 1 { 74 2 75 2 Key_Proc(); 76 2 Seg_Proc(); 77 2 Led_Proc(); 78 2 temptuer_old=temptuer; 79 2 ne555_shidu_old=ne555_shidu; 80 2 } 81 1 } 82 83 84 void ServiceT1() interrupt 3 85 { 86 1 87 1 if(++Seg_Slow_down==200)Seg_Slow_down=0; 88 1 if(++Key_Slow_down==10)Key_Slow_down=0; 89 1 90 1 91 1 Seg_Disp(pos,seg_buf); 92 1 if(++pos==8)pos=0; 93 1 Led_Disp(ucled); 94 1 ne555_time++; 95 1 if(ne555_time==1000) 96 1 { 97 2 ne555_time=0; 98 2 ne555_count=count; 99 2 count=0; 100 2 } 101 1 if(cai_flag==1) 102 1 { 103 2 t_pcf++; 104 2 if(t_pcf==3000) 105 2 { 106 3 t_pcf=0; 107 3 cai_flag=0; 108 3 } 109 2 110 2 } 111 1 if(t_flag==1) 112 1 { 113 2 t_2s++; 114 2 115 2 } 116 1 } C51 COMPILER V9.56.0.0 MAIN 04/08/2023 13:48:13 PAGE 3 117 void ServiceT0() interrupt 1 118 { 119 1 count++; 120 1 } 121 122 123 124 125 void Seg_Proc() 126 { 127 1 if(Seg_Slow_down)return; 128 1 Seg_Slow_down=1; 129 1 // temptuer=read_temptuer()/16; 130 1 if(t_pcf==0) 131 1 { 132 2 res=Read_Pcf8591(0x01); 133 2 if(res<50) 134 2 { 135 3 temptuer=read_temptuer()/16; 136 3 ne555_shidu=10+(ne555_count-200)*0.044; 137 3 n++; 138 3 cai_flag=1; 139 3 temptuer_num+=temptuer; 140 3 ne555_shidu_num+=ne555_shidu; 141 3 t_pcf++; 142 3 read_ds13(ds_time); 143 3 cai_h=ds_time[2]; 144 3 cai_m=ds_time[1]; 145 3 // flag1=1; 146 3 } 147 2 res_old=res; 148 2 } 149 1 if(cai_flag==1) 150 1 { 151 2 if((ne555_count<200)||(ne555_count>2000)) 152 2 { 153 3 sprintf(seg_string,"E %2d-AA",(int)temptuer); 154 3 flag2=1; 155 3 } 156 2 else 157 2 { 158 3 sprintf(seg_string,"E %2d-%2d",(int)temptuer,(int)ne555_shidu); 159 3 flag2=0; 160 3 } 161 2 Seg_Tran(seg_string,seg_buf); 162 2 } 163 1 else 164 1 { 165 2 if(jiemian_flag==0)//界面1 166 2 { 167 3 168 3 read_ds13(ds_time); 169 3 sprintf(seg_string,"%02d-%02d-%02d",(int)ds_time[2],(int)ds_time[1],(int)ds_time[0]); 170 3 } 171 2 else if 172 2 (jiemian_flag==1)//界面2 173 2 { 174 3 if(huixian_flag==0) 175 3 { 176 4 if(n==0) 177 4 { 178 5 sprintf(seg_string,"C "); C51 COMPILER V9.56.0.0 MAIN 04/08/2023 13:48:13 PAGE 4 179 5 } 180 4 else 181 4 { 182 5 sprintf(seg_string,"C %2d-%3.1f",(int)wendu,(float)temptuer_num/n); 183 5 } 184 4 } 185 3 else if(huixian_flag==1) 186 3 { 187 4 if(n==0) 188 4 { 189 5 sprintf(seg_string,"H "); 190 5 } 191 4 else{ 192 5 if(ne555_shidu_num/n) 193 5 { 194 6 sprintf(seg_string,"H %d-%3.1f",(int)shidu,(float)ne555_shidu_num/n); 195 6 } 196 5 197 5 } 198 4 } 199 3 else 200 3 { 201 4 if(n==0) 202 4 { 203 5 sprintf(seg_string,"F%02d ",(int)n); 204 5 205 5 } 206 4 else 207 4 sprintf(seg_string,"F%02d%02d-%02d",(int)n,(int)cai_h,(int)cai_m); 208 4 209 4 210 4 } 211 3 212 3 213 3 214 3 215 3 } 216 2 else //界面3 217 2 { 218 3 sprintf(seg_string,"P %2D",(int)wendu); 219 3 220 3 } 221 2 Seg_Tran(seg_string,seg_buf); 222 2 223 2 } 224 1 225 1 } 226 void Key_Proc() 227 { 228 1 if(Key_Slow_down)return; 229 1 Key_Slow_down=1; 230 1 231 1 Key_Value=Key_Read(); 232 1 Key_Down=Key_Value&(Key_Old^Key_Value); 233 1 Key_UP=~Key_Value&(Key_Old^Key_Value); 234 1 Key_Old=Key_Value; 235 1 236 1 if(cai_flag==0) 237 1 { 238 2 switch(Key_Down) 239 2 { 240 3 case 4: C51 COMPILER V9.56.0.0 MAIN 04/08/2023 13:48:13 PAGE 5 241 3 jiemian_flag++; 242 3 if(jiemian_flag==3)jiemian_flag=0; 243 3 break; 244 3 case 5: 245 3 if(jiemian_flag==1) 246 3 { 247 4 huixian_flag++; 248 4 if(huixian_flag==3)huixian_flag=0; 249 4 } 250 3 break; 251 3 case 8: 252 3 if(jiemian_flag==2) 253 3 { 254 4 255 4 wendu++; 256 4 } 257 3 break; 258 3 case 9: 259 3 if(jiemian_flag==2) 260 3 { 261 4 262 4 wendu--; 263 4 } 264 3 if((jiemian_flag==1)&&(huixian_flag==2)) 265 3 { 266 4 267 4 t_flag=1; 268 4 } 269 3 270 3 break; 271 3 272 3 } 273 2 switch(Key_UP) 274 2 { 275 3 case 9: 276 3 t_flag=0; 277 3 if(t_2s>2000) 278 3 { 279 4 n=0; 280 4 ne555_shidu_num=0; 281 4 temptuer_num=0; 282 4 } 283 3 t_2s=0; 284 3 break; 285 3 286 3 } 287 2 288 2 289 2 290 2 291 2 } 292 1 293 1 294 1 } 295 void Led_Proc() 296 { 297 1 if(cai_flag==1) 298 1 { 299 2 300 2 ucled=ucled&0xf8|0x04; 301 2 } 302 1 else if(jiemian_flag==1) C51 COMPILER V9.56.0.0 MAIN 04/08/2023 13:48:13 PAGE 6 303 1 { 304 2 305 2 ucled=ucled&0xf8|0x02; 306 2 } 307 1 else if(jiemian_flag==0) 308 1 { 309 2 ucled=ucled&0xf8|0x01; 310 2 } 311 1 else 312 1 { 313 2 ucled=ucled&0xf8; 314 2 } 315 1 316 1 if(flag2) 317 1 { 318 2 ucled|=0x10; 319 2 } 320 1 else 321 1 { 322 2 ucled&=0xef; 323 2 } 324 1 325 1 // if(flag1==1) 326 1 // { 327 1 // if(temptuer_old==0) 328 1 // 329 1 // } 330 1 // 331 1 332 1 } MODULE INFORMATION: STATIC OVERLAYABLE CODE SIZE = 1081 ---- CONSTANT SIZE = 115 ---- XDATA SIZE = ---- ---- PDATA SIZE = ---- ---- DATA SIZE = 62 ---- IDATA SIZE = ---- ---- BIT SIZE = 3 ---- END OF MODULE INFORMATION. C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)