wo0794:
0000 13 ORG 0000H00000133 14 AJMP START 15 0033 16 ORG 0033H0033 17 START: 00B3 18 DQ BIT P3.3 00A0 19 RS EQU P2.0 00A1 20 RW EQU P2.1 00A2 21 E EQU P2.2 00A6 22 LED8P EQU P2.6 00A7 23 BLA EQU P2.7 24 0080 25 LCD EQU P0 0001 26 DS18B20 BIT 01H 0002 27 TEMPERRB BIT 02H 0003 28 TEMPSBIT BIT 03H 0030 29 TEMPFH EQU 30H ;温度符号位 0031 30 TEMPBW EQU 31H ;温度"百"位 0032 31 TEMPSW EQU 32H ;温度"十"位 0033 32 TEMPGW EQU 33H ;温度"个"位 0034 33 TEMPXS1EQU 34H ;温度小饰坏?1"位 0035 34 TEMPXS2EQU 35H ;温度小饰坏?2"位 0036 35 TEMPXS3EQU 36H ;温度小饰坏?3"位 0037 36 TEMPXS4EQU 37H ;温度小饰坏?4"? 0038 37 TEMPXSDEQU 38H 0039 38 TEMPZS EQU 39H 003A 39 TEMPXS EQU 3AH 003B 40 TEMPL EQU 3BH 003C 41 TEMPH EQU 3CH 003D 42 ID1 EQU 3DH 003E 43 ID2 EQU 3EH 003F 44 ID3 EQU 3FH 0040 45 ID4 EQU 40H 0041 46 ID5 EQU 41H 0042 47 ID6 EQU 42H 0043 48 ID7 EQU 43H 0044 49 ID8 EQU 44H 0046 50 DLCD1 EQU 46H 0047 51 DLCD2 EQU 47H 0048 52 DLCD3 EQU 48H 0049 53 DLCD4 EQU 49H 004A 54 DLCD5 EQU 4AH 004B 55 DLCD6 EQU 4BH 004C 56 DLCD7 EQU 4CH 004D 57 DLCD8 EQU 4DH 004E 58 DLCD9 EQU 4EHA51MACROASSEMBLER LCDTEMP 03/08/200703:05:53PAGE 2 004F 59 DLCD10 EQU 4FH 0050 60 DLCD11 EQU 50H 0051 61 DLCD12 EQU 51H 0052 62 DLCD13 EQU 52H 0053 63 DLCD14 EQU 53H 0054 64 DLCD15 EQU 54H 0055 65 DLCD16 EQU 55H 66 67 ;--------------------------------------------------------- 68 00333133 69 MAIN: ACALL GETTEMP0035200102 70 JB DS18B20,MAIN100380133 71 AJMP MAIN003A 72 MAIN1: 003AC2A6 73 CLR LED8P ;开启事牍芟允?003CD2A7 74 SETB BLA ;关闭液晶模块背光003E120049 75 LCALL DISP0041120119 76 LCALL GETROM0044120049 77 LCALL DISP00470133 78 AJMP MAIN 79 80 81 ;--------事牍芟允咀映绦?-------0049300365 82 DISP: JNB TEMPSBIT,ZHWD ;温度大于0吗?004C7580BF 83 MOV P0,#0BFH ;负号004FC2A0 84 CLR P2.00051D2A1 85 SETB P2.10053D2A2 86 SETB P2.20055D2A3 87 SETB P2.30057D2A4 88 SETB P2.400591202B5 89 LCALL YS4722U 90 005CE532 91 MOV A,TEMPSW ;瘴露认允敬?005E900298 92 MOV DPTR,#SGTB006193 93 MOVC A,@A+DPTR0062F580 94 MOV P0,A0064C2A1 95 CLR P2.10066D2A0 96 SETB P2.00068D2A2 97 SETB P2.2006AD2A3 98 SETB P2.3006CD2A4 99 SETB P2.4006E1202B5 100 LCALL YS4722U 101 0071E533 102 MOV A,TEMPGW0073900298 103 MOV DPTR,#SGTB007693 104 MOVC A,@A+DPTR0077547F 105 ANL A,#01111111B0079F580 106 MOV P0,A007BC2A2 107 CLR P2.2007DD2A0 108 SETB P2.0007FD2A1 109 SETB P2.10081D2A3 110 SETB P2.30083D2A4 111 SETB P2.400851202B5 112 LCALL YS4722U 113 0088E534 114 MOV A,TEMPXS1008A900298 115 MOV DPTR,#SGTB008D93 116 MOVC A,@A+DPTR008EF580 117 MOV P0,A0090F580 118 MOV P0,A0092C2A3 119 CLR P2.30094D2A0 120 SETB P2.00096D2A1 121 SETB P2.10098D2A2 122 SETB P2.2009AD2A4 123 SETB P2.4009C1202B5 124 LCALL YS4722UA51MACROASSEMBLER LCDTEMP 03/08/200703:05:53PAGE 3 125 009F7446 126 MOV A,#01000110B00A1F580 127 MOV P0,A00A3C2A4 128 CLR P2.400A5D2A0 129 SETB P2.000A7D2A1 130 SETB P2.100A9D2A2 131 SETB P2.200ABD2A3 132 SETB P2.300AD1202B5 133 LCALL YS4722U00B022 134 RET 135 00B1E532 136 ZHWD: MOV A,TEMPSW ;瘴露认允敬?00B3900298 137 MOV DPTR,#SGTB00B693 138 MOVC A,@A+DPTR00B7F580 139 MOV P0,A00B9C2A0 140 CLR P2.000BBD2A1 141 SETB P2.100BDD2A2 142 SETB P2.200BFD2A3 143 SETB P2.300C1D2A4 144 SETB P2.400C31202B5 145 LCALL YS4722U 146 00C6E533 147 MOV A,TEMPGW00C8900298 148 MOV DPTR,#SGTB00CB93 149 MOVC A,@A+DPTR00CC547F 150 ANL A,#01111111B00CEF580 151 MOV P0,A00D0C2A1 152 CLR P2.100D2D2A0 153 SETB P2.000D4D2A2 154 SETB P2.200D6D2A3 155 SETB P2.300D8D2A4 156 SETB P2.400DA1202B5 157 LCALL YS4722U 158 00DDE534 159 MOV A,TEMPXS100DF900298 160 MOV DPTR,#SGTB00E293 161 MOVC A,@A+DPTR00E3F580 162 MOV P0,A00E5C2A2 163 CLR P2.200E7D2A0 164 SETB P2.000E9D2A1 165 SETB P2.100EBD2A3 166 SETB P2.300EDD2A4 167 SETB P2.400EF1202B5 168 LCALL YS4722U 169 00F2E535 170 MOV A,TEMPXS200F4900298 171 MOV DPTR,#SGTB00F793 172 MOVC A,@A+DPTR00F8F580 173 MOV P0,A00FAC2A3 174 CLR P2.300FCD2A0 175 SETB P2.000FED2A1 176 SETB P2.10100D2A2 177 SETB P2.20102D2A4 178 SETB P2.401041202B5 179 LCALL YS4722U 180 01077446 181 MOV A,#01000110B0109F580 182 MOV P0,A010BC2A4 183 CLR P2.4010DD2A0 184 SETB P2.0010FD2A1 185 SETB P2.10111D2A2 186 SETB P2.20113D2A3 187 SETB P2.301151202B5 188 LCALL YS4722U011822 189 RET 190 A51MACROASSEMBLER LCDTEMP 03/08/200703:05:53PAGE 4 191 192 ;|------------------------------------------------| 193 ;|读出DS18B20序列号应用程序 194 ;|------------------------------------------------|0119C2AF 195 GETROM:CLR EA011B1201E1 196 LCALL INIT18B20011E200103 197 JB DS18B20,GETROM10121D2AF 198 SETB EA012322 199 RET01247433 200 GETROM1:MOV A,#33H0126120230 201 LCALL WRITE18B20 ;送入读DS18B20的ROM命令01297C08 202 MOV R4,#8 ;从DS18B20中读出8字节ROM示?012B793D 203 MOV R1,#ID1012D120210 204 LCALL READ18B200130D2AF 205 SETB EA013222 206 RET 207 0133C2AF 208 GETTEMP:CLR EA01351201E1 209 LCALL INIT18B20 ;先复位DS18B200138200103 210 JB DS18B20,TSS2013BD2AF 211 SETB EA013D22 212 RET013E74CC 213 TSS2: MOV A,#0CCH ;跳筊OM匹配0140120230 214 LCALL WRITE18B2001437444 215 MOV A,#44H ;发出温度转换命令0145120230 216 LCALL WRITE18B2001481202DB 217 LCALL YS800M ;延时0.8S,延时>750MS014B1201E1 218 LCALL INIT18B20014E74CC 219 MOV A,#0CCH ;跳筊OM匹配0150120230 220 LCALL WRITE18B20015374BE 221 MOV A,#0BEH ;发出读温度命令0155120230 222 LCALL WRITE18B2001587C02 223 MOV R4,#2 ;从DS18B20中读出2字节温度示?015A793B 224 MOV R1,#TEMPL015C120210 225 LCALL READ18B20 ;读温度 226 227 ; MOV TEMPH,#0FEH 228 ; MOV TEMPL,#37H 229 015FD2AF 230 SETB EA 231 232 016175382E 233 DOTEMP:MOV TEMPXSD,#2EH0164E53C 234 TESTS1:MOV A,TEMPH016654F8 235 ANL A,#11111000B0168B4F80A 236 CJNE A,#0F8H,TESTS0016B7530FF 237 MOV TEMPFH,#0FFH016ED203 238 SETB TEMPSBIT0170C202 239 CLR TEMPERRB0172020187 240 LJMP DOTEMP10175B4000A 241 TESTS0:CJNE A,#00H,TEMPERR0178753000 242 MOV TEMPFH,#00H017BC203 243 CLR TEMPSBIT017DC202 244 CLR TEMPERRB017F020187 245 LJMP DOTEMP10182 246 TEMPERR:0182D202 247 SETB TEMPERRB01840201DE 248 LJMP TEMPRET0187 249 DOTEMP1:0187300315 250 JNB TEMPSBIT,DOTEMP2018AE53C 251 MOV A,TEMPH018CF4 252 CPL A018DF53C 253 MOV TEMPH,A018FE53B 254 MOV A,TEMPL0191F4 255 CPL A0192C3 256 CLR CA51MACROASSEMBLER LCDTEMP 03/08/200703:05:53PAGE 501932401 257 ADD A,#10195F53B 258 MOV TEMPL,A0197E53C 259 MOV A,TEMPH01993400 260 ADDC A,#00H019B5407 261 ANL A,#00000111B019DF53C 262 MOV TEMPH,A019F 263 DOTEMP2:019FE53C 264 MOV A,TEMPH01A1C4 265 SWAP A01A2F53C 266 MOV TEMPH,A01A4E53B 267 MOV A,TEMPL01A6540F 268 ANL A,#00001111B01A8F53A 269 MOV TEMPXS,A01AAE53B 270 MOV A,TEMPL01AC54F0 271 ANL A,#11110000B01AEC4 272 SWAP A01AFA93C 273 MOV R1,TEMPH01B149 274 ORL A,R101B2F539 275 MOV TEMPZS,A01B4 276 HBCD:01B4E539 277 MOV A,TEMPZS01B675F064 278 MOV B,#10001B984 279 DIV AB01BAF531 280 MOV TEMPBW,A01BC740A 281 MOV A,#1001BEC5F0 282 XCH A,B01C084 283 DIV AB01C1F532 284 MOV TEMPSW,A01C3E5F0 285 MOV A,B01C5F533 286 MOV TEMPGW,A01C77A04 287 FLXS: MOV R2,#401C9E53A 288 MOV A,TEMPXS01CB540F 289 ANL A,#00001111B01CD75F004 290 MOV B,#401D0A4 291 MUL AB01D1F9 292 MOV R1,A01D27834 293 MOV R0,#TEMPXS101D4900248 294 FLXS1: MOV DPTR,#DISPXS01D7E9 295 MOV A,R101D893 296 MOVC A,@A+DPTR01D9F6 297 MOV @R0,A01DA08 298 INC R001DB09 299 INC R101DCDAF6 300 DJNZ R2,FLXS1 301 01DE 302 TEMPRET:01DED2AF 303 SETB EA01E022 304 RET 305 306 ;-----------------------------------------------------01E1 307 INIT18B20:01E1D2B3 308 SETB DQ01E300 309 NOP01E4C2B3 310 CLR DQ01E6786B 311 MOV R0,#107 ;主机发出延时537微秒的复位低脉冲[2]01E87903 312 MOV R1,#301EAD8FE 313 TSR1: DJNZ R0,TSR101EC786B 314 MOV R0,#10701EED9FA 315 DJNZ R1,TSR101F0D2B3 316 SETB DQ01F200 317 NOP01F300 318 NOP01F400 319 NOP01F57825 320 MOV R0,#25H01F730B304 321 TSR2: JNB DQ,TSR301FAD8FB 322 DJNZ R0,TSR2A51MACROASSEMBLER LCDTEMP &nbs