Programming is as follows:
First, use assembly language and save it as ds.asm
/* -
Program name: temperature data assembly and accurate time acquisition
Du yang compiled
- */
DSSP segment code; program segmentation
Public decision support system; Entry address, jump to DL tag to execute assembler.
RSEG·DSSP; program segmentation
At eqp1.6
flag 1 EQU 05H; DS 18B20 Equipment Existence Flag
TTL EQU 07H; Temperature reading (high in TTL- 1, low in TTL)
; -DS 18B20 data reading program (0~99 degrees).
; This is DS 18B20 reset initialization subroutine.
INIT_ 1820:
SETB is at
Nototherwiseprovided(for) unless otherwise specified.
CLR input
; The host sends a reset low pulse with a delay of 537 microseconds.
MOV R 1,# 18; #3
TSR 1:MOV R0,# 107
DJNZ R0 dollars
DJNZ R 1,TSR 1
SETB is here; Then pull up the data cable.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
NOP 12 times
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
MOV R0,# 0DEH#25H
TSR2:
JNB is here, TSR3 is waiting for a response from DS 18B20.
DJNZ R0,TSR2
LJMP TSR4 delay
TSR3:
SETB flag 1; Set a flag to indicate that DS 1820 exists.
LJMP TSR5
TSR4:
CLR flag 1; Clear the flag, indicating that DS 1820 does not exist.
LJMP TSR7
TSR5:
MOV R7, No.6
TSR6:
MOV R0,# 1 17
DJNZ R0,$; Timing needs a certain time delay */
DJNZ R7, TSR6 timing needs a certain time delay */
TSR7:
SETB is at
Soak in water to soften
; -Read the converted temperature value.
DSS:
DS 1820PRO:
; Here, the display subroutine is called and delayed for a period of time, waiting for the end of AD conversion. If the bit is 12, it is 750 microseconds.
SETB is at
LCALL INIT _ 1820; Reset DS 18B20 first.
JB logo 1, TSS2
Jmp BCD33, do you know whether DS 1820 exists? If DS 18B20 does not exist, it is returned.
TSS2:
MOV A, # 0CCH skips ROM matching.
LCALL WRITE_ 1820
MOV A, # 44H issues a temperature conversion command.
LCALL WRITE_ 1820
Call dl 1 ms
SETB is at
LCALL INIT _ 1820; Reset before reading the temperature.
MOV A, # 0CCH skips ROM matching.
LCALL WRITE_ 1820
MOV A, # 0BEH gives the temperature reading command.
LCALL WRITE_ 1820
LCALL READ _ 18200; Save the read temperature data to 35H/36H.
MOV A,TTL
MOV B,TTL- 1
MOV C, B.0 puts the lowest displacement in 28 hours into c.
RRC A
MOV,B. 1
RRC A
MOV bay no.2
RRC A
MOV C,B.3
RRC A
MOV TTL,A
BCD33:
JB logo 1, BCD44
mov R7,#0FFH
JMP· Torre
BCD44:
MOV R7,TTL
TORET:
Soak in water to soften
; -Write a subroutine of DS 18B20 (with specific timing requirements).
WRITE_ 1820:
MOV·R2, ranked eighth; A ***8-bit data
CLR C
WR 1:
CLR input
MOV R3,# 36; #6
DJNZ R3, USD
RRC A
MOV is in C.
MOV R3,# 192; #23
DJNZ R3, USD
SETB is at
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
DJNZ R2,WR 1
SETB is at
Soak in water to soften
; -Read the program of DS 18B20, and read two bytes of temperature data from DS 18B20.
READ_ 18200:
MOV·R4, ranked second; Read high and low temperatures from DS 18B20.
MOV R 1, # TTL29-hour low deposition (tempering _L) and 28-hour high deposition (tempering _H).
RE00:
MOV·R2, ranked eighth; The data 1 * * * has 8 bits.
RE0 1:
CLR C
SETB is at
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
CLR input
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
Nototherwiseprovided(for) unless otherwise specified.
SETB is at
MOV R3,# 54; #9
RE 10:
DJNZ R3,RE 10
MOV, Indiana
MOV R3,# 138; #23
RE20:
DJNZ R3,RE20
RRC A
DJNZ R2,RE0 1
MOV @R 1,A
December R 1
DJNZ R4,RE00
Soak in water to soften
Dl 1 ms:
MOV R7, No.6
DL 1MS2:
MOV·R6, No.255
DJNZ R6, USD
DJNZ R7,DL 1MS2
Soak in water to soften
end
Then it can be called in C language (in Keil, the main program file and ds.asm are placed in the same folder, and here is a complete program, 128×64LCD screen with Chinese character library).
sbit dq = p 1 ^ 6; //DS 18B20 Definition of Temperature Sensor
Unsigned character DSS (void); //Read 18B20 temperature program statement in assembly language.
I = DSS(); //Put the temperature value obtained by DSS assembler into the temperature register variable.
If (I & lt60){// cannot read the temperature data, the word temperature will not be displayed.
lcm_w_test(0,0x9c); //The temperature is written on the LCM.
Lcm_w_word ("temperature"); //Celsius
lcm_w_test( 1,I/ 10+0x 30); //Display the temperature in ten digits.
lcm_w_test( 1,I % 10+0x 30); //bit
LCM _ w _ word(“℃”); //Celsius
}
}