📄 measure.lis
字号:
0572 .dbline 342
0572 ; }
0572 ;
0572 ;
0572 ;
0572 ; if(j) error+=1; // or timeout (~2 sec.) is reached
0572 4F5F subi R20,255 ; offset = 1
0574 5F4F sbci R21,255
0576 L65:
0576 .dbline 343
0576 ; cwendu1=s_read_byte(ACK); //read the first byte (MSB)
0576 01E0 ldi R16,1
0578 90DE xcall _s_read_byte
057A 00930700 sts _cwendu1,R16
057E .dbline 344
057E ; cwendu2=s_read_byte(ACK); //read the second byte (LSB)
057E 01E0 ldi R16,1
0580 8CDE xcall _s_read_byte
0582 00930600 sts _cwendu2,R16
0586 .dbline 345
0586 ; uwendu =cwendu1*256+cwendu2;
0586 20910700 lds R18,_cwendu1
058A 3327 clr R19
058C 00E0 ldi R16,256
058E 11E0 ldi R17,1
0590 0E940000 xcall empy16s
0594 1801 movw R2,R16
0596 40900600 lds R4,_cwendu2
059A 5524 clr R5
059C 240C add R2,R4
059E 351C adc R3,R5
05A0 30920500 sts _uwendu+1,R3
05A4 20920400 sts _uwendu,R2
05A8 .dbline 346
05A8 ; *p_checksum =s_read_byte(noACK);
05A8 0027 clr R16
05AA 77DE xcall _s_read_byte
05AC F501 movw R30,R10
05AE 0083 std z+0,R16
05B0 .dbline 348
05B0 ;
05B0 ; if(error>0)
05B0 4030 cpi R20,0
05B2 4507 cpc R20,R21
05B4 09F0 breq L67
05B6 X27:
05B6 .dbline 349
05B6 ; PORTA |=0x02; //read checksum
05B6 D99A sbi 0x1b,1
05B8 L67:
05B8 .dbline 350
05B8 ; return error;
05B8 042F mov R16,R20
05BA .dbline -2
05BA L47:
05BA 0E940000 xcall pop_xgset5
05BE .dbline 0 ; func end
05BE 0895 ret
05C0 .dbsym r error 20 i
05C0 .dbsym r k 12 i
05C0 .dbsym r i 14 i
05C0 .dbsym r j 22 i
05C0 .dbsym r mode 12 c
05C0 .dbsym r p_checksum 10 pc
05C0 .dbend
05C0 .dbfunc e calc_sth11 _calc_sth11 fV
05C0 ; t_C -> y+4
05C0 ; t -> y+0
05C0 ; p_temperature -> R10,R11
.even
05C0 _calc_sth11::
05C0 AA92 st -y,R10
05C2 BA92 st -y,R11
05C4 5801 movw R10,R16
05C6 2897 sbiw R28,8
05C8 .dbline -1
05C8 .dbline 360
05C8 ; }
05C8 ; void calc_sth11(float *p_temperature)
05C8 ; //void calc_sth11(float *p_humidity ,float *p_temperature)
05C8 ; //----------------------------------------------------------------------------------------
05C8 ; // calculates temperature [癈] and humidity [%RH]
05C8 ; // input : humi [Ticks] (12 bit)
05C8 ; // temp [Ticks] (14 bit)
05C8 ; // output: humi [%RH]
05C8 ; // temp [癈]
05C8 ; {
05C8 .dbline 363
05C8 ;
05C8 ; //float rh=*p_humidity; // rh: Humidity [Ticks] 12 Bit
05C8 ; float t=*p_temperature; // t: Temperature [Ticks] 14 Bit
05C8 F501 movw R30,R10
05CA 2080 ldd R2,z+0
05CC 3180 ldd R3,z+1
05CE 4280 ldd R4,z+2
05D0 5380 ldd R5,z+3
05D2 2882 std y+0,R2
05D4 3982 std y+1,R3
05D6 4A82 std y+2,R4
05D8 5B82 std y+3,R5
05DA .dbline 368
05DA ; //float rh_lin; // rh_lin: Humidity linear
05DA ; //float rh_true; // rh_true: Temperature compensated humidity
05DA ; float t_C; // t_C : Temperature [癈]
05DA ;
05DA ; t_C=t*0.01 - 40;//-327.68; //calc. temperature from ticks to [癈]
05DA 00E0 ldi R16,<L70
05DC 10E0 ldi R17,>L70
05DE 0E940000 xcall lpm32
05E2 CE01 movw R24,R28
05E4 9A93 st -y,R25
05E6 8A93 st -y,R24
05E8 0E940000 xcall fpmule1
05EC 1801 movw R2,R16
05EE 2901 movw R4,R18
05F0 00E0 ldi R16,<L71
05F2 10E0 ldi R17,>L71
05F4 0E940000 xcall lpm32
05F8 3A93 st -y,R19
05FA 2A93 st -y,R18
05FC 1A93 st -y,R17
05FE 0A93 st -y,R16
0600 8101 movw R16,R2
0602 9201 movw R18,R4
0604 0E940000 xcall fpsub2
0608 0C83 std y+4,R16
060A 1D83 std y+5,R17
060C 2E83 std y+6,R18
060E 3F83 std y+7,R19
0610 .dbline 374
0610 ; //rh_lin=C3*rh*rh + C2*rh + C1; //calc. humidity from ticks to [%RH]
0610 ; //rh_true=(t_C-25)*(T1+T2*rh)+rh_lin; //calc. temperature compensated humidity [%RH]
0610 ; //if(rh_true>100)rh_true=100; //cut if the value is outside of
0610 ; //if(rh_true<0.1)rh_true=0.1; //the physical possible range
0610 ;
0610 ; *p_temperature=t_C; //return temperature [癈]
0610 2C80 ldd R2,y+4
0612 3D80 ldd R3,y+5
0614 4E80 ldd R4,y+6
0616 5F80 ldd R5,y+7
0618 F501 movw R30,R10
061A 2082 std z+0,R2
061C 3182 std z+1,R3
061E 4282 std z+2,R4
0620 5382 std z+3,R5
0622 .dbline -2
0622 L69:
0622 2896 adiw R28,8
0624 B990 ld R11,y+
0626 A990 ld R10,y+
0628 .dbline 0 ; func end
0628 0895 ret
062A .dbsym l t_C 4 D
062A .dbsym l t 0 D
062A .dbsym r p_temperature 10 pD
062A .dbend
062A .dbfunc e main _main fV
062A ; checksum -> y+0
062A ; error -> R10
062A ; i -> R10,R11
.even
062A _main::
062A 2197 sbiw R28,1
062C .dbline -1
062C .dbline 401
062C ; //*p_humidity=rh_true; //return humidity[%RH]
062C ; }
062C ;
062C ; /*float calc_dewpoint(float h,float t)
062C ; //--------------------------------------------------------------------
062C ; // calculates dew point
062C ; // input: humidity [%RH], temperature [癈]
062C ; // output: dew point [癈]
062C ; { float logEx,dew_point;
062C ; logEx=0.66077+7.5*t/(237.3+t)+(log10(h)-2);
062C ; dew_point = (logEx - 0.66077)*237.3/(0.66077+7.5-logEx);
062C ; return dew_point;
062C ; }
062C ; */
062C ;
062C ;
062C ;
062C ; void main()
062C ; //----------------------------------------------------------------------------------
062C ; // sample program that shows how to use SHT11 functions
062C ; // 1. connection reset
062C ; // 2. measure humidity [ticks](12 bit) and temperature [ticks](14 bit)
062C ; // 3. calculate humidity [%RH] and temperature [癈]
062C ; // 4. calculate dew point [癈]
062C ; // 5. print temperature, humidity, dew point
062C ;
062C ; { //value temp_val;//humi_val;
062C .dbline 408
062C ; //unsigned int temp_new;
062C ; //float dew_point;
062C ; unsigned char error,checksum;
062C ; unsigned int i;
062C ;
062C ;
062C ; DDRA |=0x07;
062C 8AB3 in R24,0x1a
062E 8760 ori R24,7
0630 8ABB out 0x1a,R24
0632 5DC0 xjmp L74
0634 L73:
0634 .dbline 423
0634 ; //delay();
0634 ; //delay();
0634 ; //newdelay();
0634 ; //init_uart();
0634 ; //while(1)
0634 ;
0634 ;
0634 ;
0634 ;
0634 ; //PORTA &=0xfb;
0634 ;
0634 ;
0634 ;
0634 ; while(1)
0634 ; {
0634 .dbline 424
0634 ; shxx_config();
0634 E5DC xcall _shxx_config
0636 .dbline 425
0636 ; s_connectionreset();
0636 2CDF xcall _s_connectionreset
0638 .dbline 426
0638 ; error=0;
0638 AA24 clr R10
063A .dbline 429
063A ; //error+=s_measure((unsigned char*) &humi_val.i,&checksum,HUMI); //measure humidity
063A ; //error+=s_measure((unsigned char*) &temp_val.i,&checksum,TEMP); //measure temperature
063A ; error+=s_measure(&checksum,TEMP);
063A 2227 clr R18
063C 8E01 movw R16,R28
063E 4BDF xcall _s_measure
0640 A00E add R10,R16
0642 .dbline 430
0642 ; if(error!=0)
0642 11F0 breq L76
0644 X28:
0644 .dbline 431
0644 ; s_connectionreset();
0644 25DF xcall _s_connectionreset
0646 31C0 xjmp L77
0648 L76:
0648 .dbline 433
0648 ; else
0648 ; {
0648 .dbline 441
0648 ; //for (i=0;i<60000;i++);
0648 ;
0648 ; //PORTA &=0xfb; //in case of an error: connection reset
0648 ;
0648 ; //PORTA &=0xfb;
0648 ; //PORTA =0x02;
0648 ; //humi_val.f=(float)humi_val.i; //converts integer to float
0648 ; fwendu=(float)uwendu;
0648 20900400 lds R2,_uwendu
064C 30900500 lds R3,_uwendu+1
0650 00E0 ldi R16,<L78
0652 10E0 ldi R17,>L78
0654 0E940000 xcall lpm32
0658 2801 movw R4,R16
065A 3901 movw R6,R18
065C 8101 movw R16,R2
065E 1695 lsr R17
0660 0795 ror R16
0662 0E940000 xcall int2fp
0666 3A93 st -y,R19
0668 2A93 st -y,R18
066A 1A93 st -y,R17
066C 0A93 st -y,R16
066E 8201 movw R16,R4
0670 9301 movw R18,R6
0672 0E940000 xcall fpmule2
0676 2801 movw R4,R16
0678 3901 movw R6,R18
067A 8101 movw R16,R2
067C 0170 andi R16,1
067E 1070 andi R17,0
0680 0E940000 xcall int2fp
0684 3A93 st -y,R19
0686 2A93 st -y,R18
0688 1A93 st -y,R17
068A 0A93 st -y,R16
068C 8201 movw R16,R4
068E 9301 movw R18,R6
0690 0E940000 xcall fpadd2
0694 10930100 sts _fwendu+1,R17
0698 00930000 sts _fwendu,R16
069C 30930300 sts _fwendu+2+1,R19
06A0 20930200 sts _fwendu+2,R18
06A4 .dbline 442
06A4 ; calc_sth11(&fwendu); //converts integer to float
06A4 00E0 ldi R16,<_fwendu
06A6 10E0 ldi R17,>_fwendu
06A8 8BDF xcall _calc_sth11
06AA .dbline 446
06AA ; //calc_sth11(&humi_val.f,&temp_val.f); //calculate humidity, temperature
06AA ; //dew_point=calc_dewpoint(humi_val.f,temp_val.f); //calculate dew point
06AA ; //printf("temp:%5.1fC humi:%5.1f%% dew point:%5.1fC\n",temp_val.f,humi_val.f,dew_point);
06AA ; }
06AA L77:
06AA .dbline 447
06AA ; if(fwendu>30.0)
06AA 80E0 ldi R24,<_fwendu
06AC 90E0 ldi R25,>_fwendu
06AE 00E0 ldi R16,<L81
06B0 10E0 ldi R17,>L81
06B2 0E940000 xcall lpm32
06B6 9A93 st -y,R25
06B8 8A93 st -y,R24
06BA 0E940000 xcall fpcmp1
06BE 14F4 brge L79
06C0 X29:
06C0 .dbline 448
06C0 ; PORTA |=0x01;
06C0 D89A sbi 0x1b,0
06C2 03C0 xjmp L80
06C4 L79:
06C4 .dbline 450
06C4 ; else
06C4 ; PORTA &=0xfe;
06C4 8BB3 in R24,0x1b
06C6 8E7F andi R24,254
06C8 8BB
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -