资源描述
单单片片机机数数字字温温度度计计汇汇编编程程序序公司内部编号:(GOOD-TMMT-MMUT-UUPTY-UUYY-DTTI-ORG0000 LJMP MAINORG 0100H;*DAT BIT P1.0 TEMPER_L EQU 40H TEMPER_H EQU 41H A_BIT EQU 60H B_BIT EQU 61H C_BIT EQU 62H D_BIT EQU 63H;*主程序*MAIN:MOV A,#7FH LCALL WRITE_1820 LCALL INIT_1820 LCALL GET_TEMPER LCALL CONVER LCALL DISPLAY LJMP MAIN;*初始db18b20*H化INIT_1820:CLR EAINI10:SETB DAT MOV R2,#200INI11:CLR DAT DJNZ R2,INI11 SETB DAT MOV R2,#30INT12:DJNZ R2,INT12 CLR C ORL C,DAT JC INI10 MOV R6,#80INI13:ORL C,DAT JC INI14 DJNZ R6,INI13 SJMP INI10INI14:MOV R2,#240INT15:DJNZ R2,INT15 RET;*读温度子程*GET_TEMPER:MOV A,#0CCH LCALL WRITE_1820 MOV A,#44H LCALL WRITE_1820 SETB DAT LCALL DISPLAY LCALL INIT_1820 MOV A,#0CCH LCALL WRITE_1820 MOV A,#0BEH LCALL WRITE_1820 LCALL READ_1820 MOV TEMPER_L,A LCALL READ_1820 MOV TEMPER_H,A序 RET;*写ds18b20的程序*WRITE_1820:CLR EA MOV R3,#8WR11:SETB DAT MOV R4,#8 RRC A CLR DATWR12:DJNZ R4,WR12 MOV DAT,C MOV R4,#30WR13:DJNZ R4,WR13 DJNZ R3,WR11 SETB DAT RET;*读ds18b20的程序*READ_1820:CLR EA MOV R6,#8RD11:CLR DAT MOV R4,#8 NOP SETB DATRD12:DJNZ R4,RD12 MOV C,DAT RRC A MOV R5,#30RD13:DJNZ R5,RD13 DJNZ R6,RD11 SETB DAT RET;*计算温度子程序*CONVER:MOV A,#0F0H ANL A,TEMPER_H MOV 64H,A JZ UNSIGN DEC TEMPER_L MOV A,TEMPER_H CPL A MOV TEMPER_H,A MOV A,TEMPER_L CPL A MOV TEMPER_L,AUNSIGN:MOV A,#0FH ANL A,TEMPER_L MOV B,#10 MUL AB MOV B,#16 DIV AB MOV A_BIT,A MOV A,#0F0H ANL A,TEMPER_L SWAP A MOV B,A MOV A,#0FH ANL A,TEMPER_H SWAP A ADD A,B MOV 32H,ABCD:MOV B,#100 DIV AB MOV 30H,A MOV D_BIT,A MOV A,#10 XCH A,B DIV AB MOV C_BIT,A MOV B_BIT,B SWAP A ADD A,B MOV 31H,A RET;*显示温度子程序*DISPLAY:MOV 5FH,#00H MOV 5EH,#03H MOV DPTR,#TAB MOV R3,#100S3:MOV R1,#20S2:MOV R2,#08H MOV R0,#63H MOV R4,#4 SETB CS1:MOV P2,R2 CJNE R4,#4,DLP3 CJNE R0,#00H,DLP6 MOV A,#0FFH LJMP DLP1DLP3:CJNE R4,#3,DLP6 CJNE R0,#00H,DLP6 MOV A,63H CJNE A,#00H,DLP3 MOV A,#0FFH LJMP DLP1DLP6:MOV A,R0 MOVC A,A+DPTR CJNE R4,#2,DLP1 ANL A,#7FHDLP1:MOV R5,64H CJNE R5,#0F0H,DLP2 CJNE R4,#4,DLP5 MOV R6,62H CJNE R6,#0,DLP4 MOV A,#0FFH LJMP DLP2DLP4:MOV A,#0BFH LJMP DLP2DLP5:CJNE R4,#3,DLP2 CJNE R0,#0,DLP2 MOV A,#0BFHDLP2:MOV P0,A LCALL DELAY MOV A,R2 RR A MOV R2,A DEC R0 DJNZ R4,S1 DJNZ R1,S2 DJNZ R3,S3 RETTAB:DB 0C0H,0F9H,0A4H,0B0H,99H,92H,82H,0F8H,80H,90HDELAY:MOV R7,#118 DJNZ R7,$RETEND
展开阅读全文