Партнерка на США и Канаду по недвижимости, выплаты в крипто

  • 30% recurring commission
  • Выплаты в USDT
  • Вывод каждую неделю
  • Комиссия до 5 лет за каждого referral

MOV B,#200 ; 2. Set time interval.

DJNZ B,$ ;400. Wait with Data low.

SETB THERM1 ; 1. Release Data line.

MOV B,#6 ; 2. Set time interval.

CLR C ; 1. Clear presence flag.

WAITL1: JB THERM1,WH1 ;Exit loop if line high.

DJNZ B, WAITL1 ;Hang around for 3360

DJNZ ACC, WAITL1 ;us if line is low.

SJMP SHORT1 ;Line could not go high.

WH1: MOV B,#101 ;Delay for presence detect.

HL1: ORL C,/THERM1 ;202. Catch presence pulse.

DJNZ B, HL1 ;202. Wait with Data high.

SHORT1: RET ;Return.

; This procedure sends the byte in the accumulator

; to the 1-Wire device, and returns a byte from the

; 1-Wire device in the accumulator. Note that the NOPs

; in the following code are intended to give the

; optimum performance when using a 10 MHz crystal.

TOUCHBY1: PUSH B ;Save the B register.

MOV B,#8 ;Setup for 8 bits.

B_LOOP1: RRC A ;1. Get bit in carry.

LCALL TOUCHB1 ;2. Send bit.

DJNZ B, B_LOOP1 ;2. Get next bit.

RRC A ; Get final bit in ACC.

POP B ;Restore B register.

RET ;Return to caller.

TOUCHB1: CLR THERM1 ; 1. Start the time slot.

INC DPTR ; 2.

INC DPTR ; 2.

MOV THERM1,C ; 2. Send out the data bit.

INC DPTR ; 2.

INC DPTR ; 2.

INC DPTR ; 2.

MOV C, THERM1 ; 1. Sample input data bit.

PUSH B ; 2. Save B register.

MOV B,#16 ; 2. Delay until the end

DJNZ B,$ ;32. of the time slot.

POP B ;Restore B register.

SETB THERM1 ;Terminate time slot.

RET ;Return to caller.

; Read temperature from 1-wire thermometer DS1821.

; Returns C=1 in case of valid code, else C=0.

НЕ нашли? Не то? Что вы ищете?

; Returns R1=DIG1, R2=DIG2, MINUS of themperature (-55..99).

; 1-wire port line called as THERM1.

; Calls TRESET1, TOUCHBY1

READ_T1: LCALL TRESET1 ;Issue reset pulse.

JNC RT1 ;Fail if no part on bus.

MOV A,#0AAH ;Read temperature command.

LCALL TOUCHBY1 ;Send command byte.

MOV A,#0FFH ;perform read

LCALL TOUCHBY1 ;Read temperature.

LCALL TCONV ;HEX to BCD conversion

SETB C

RT1: RET

; Start conversion in 1-wire thermometer DS1821.

; 1-wire port line called as THERM2.

; Calls TRESET2, TOUCHBY2

START_T2: LCALL TRESET2 ;Issue reset pulse.

JNC ACSRET2 ;Fail if no part on bus.

MOV A,#0CH ;Write status command.

LCALL TOUCHBY2 ;Send command byte.

MOV A,#00H ;Continuously conversion.

LCALL TOUCHBY2 ;Send command byte.

ST_T2: LCALL TRESET2 ;Issue reset pulse.

JNC ACSRET2 ;Fail if no part on bus.

MOV A,#0EEH ;Start convert command.

LCALL TOUCHBY2 ;Send command byte.

SETB C

ACSRET2: RET

; This procedure transmits the Reset signal to the 1-Wire

; device and watches for a presence pulse. On return,

; the Carry bit is set if a presence pulse was detected,

; otherwise the Carry is cleared. The code is timed for

; an 10 MHz crystal.

TRESET2: MOV A,#4 ;Load outer loop variable.

CLR THERM2 ;Start the reset pulse.

MOV B,#200 ; 2. Set time interval.

DJNZ B,$ ;400. Wait with Data low.

SETB THERM2 ; 1. Release Data line.

MOV B,#6 ; 2. Set time interval.

CLR C ; 1. Clear presence flag.

WAITL2: JB THERM2,WH2 ;Exit loop if line high.

DJNZ B, WAITL2 ;Hang around for 3360

DJNZ ACC, WAITL2 ;us if line is low.

SJMP SHORT2 ;Line could not go high.

WH2: MOV B,#101 ;Delay for presence detect.

HL2: ORL C,/THERM2 ;202. Catch presence pulse.

DJNZ B, HL2 ;202. Wait with Data high.

SHORT2: RET ;Return.

; This procedure sends the byte in the accumulator

; to the 1-Wire device, and returns a byte from the

; 1-Wire device in the accumulator. Note that the NOPs

; in the following code are intended to give the

; optimum performance when using a 10 MHz crystal.

TOUCHBY2: PUSH B ;Save the B register.

MOV B,#8 ;Setup for 8 bits.

B_LOOP2: RRC A ;1. Get bit in carry.

LCALL TOUCHB2 ;2. Send bit.

DJNZ B, B_LOOP2 ;2. Get next bit.

RRC A ; Get final bit in ACC.

POP B ;Restore B register.

RET ;Return to caller.

TOUCHB2: CLR THERM2 ; 1. Start the time slot.

INC DPTR ; 2.

INC DPTR ; 2.

MOV THERM2,C ; 2. Send out the data bit.

INC DPTR ; 2.

INC DPTR ; 2.

INC DPTR ; 2.

MOV C, THERM2 ; 1. Sample input data bit.

PUSH B ; 2. Save B register.

MOV B,#16 ; 2. Delay until the end

DJNZ B,$ ;32. of the time slot.

POP B ;Restore B register.

SETB THERM2 ;Terminate time slot.

RET ;Return to caller.

; Read temperature from 1-wire thermometer DS1821.

; Returns C=1 in case of valid code, else C=0.

; Returns R1=DIG1, R2=DIG2, MINUS of themperature (-55..99).

; 1-wire port line called as THERM2.

; Calls TRESET2, TOUCHBY2

READ_T2: LCALL TRESET2 ;Issue reset pulse.

JNC RT2 ;Fail if no part on bus.

MOV A,#0AAH ;Read temperature command.

LCALL TOUCHBY2 ;Send command byte.

MOV A,#0FFH ;perform read

LCALL TOUCHBY2 ;Read temperature.

LCALL TCONV ;HEX to BCD conversion

SETB C

RT2: RET

; Start conversion in 1-wire thermometer DS1821.

; 1-wire port line called as THERM3.

; Calls TRESET3, TOUCHBY3

START_T3: LCALL TRESET3 ;Issue reset pulse.

JNC ACSRET3 ;Fail if no part on bus.

MOV A,#0CH ;Write status command.

LCALL TOUCHBY3 ;Send command byte.

MOV A,#00H ;Continuously conversion.

LCALL TOUCHBY3 ;Send command byte.

ST_T3: LCALL TRESET3 ;Issue reset pulse.

JNC ACSRET3 ;Fail if no part on bus.

MOV A,#0EEH ;Start convert command.

LCALL TOUCHBY3 ;Send command byte.

SETB C

ACSRET3: RET

; This procedure transmits the Reset signal to the 1-Wire

; device and watches for a presence pulse. On return,

; the Carry bit is set if a presence pulse was detected,

; otherwise the Carry is cleared. The code is timed for

; an 10 MHz crystal.

TRESET3: MOV A,#4 ;Load outer loop variable.

CLR THERM3 ;Start the reset pulse.

MOV B,#200 ; 2. Set time interval.

DJNZ B,$ ;400. Wait with Data low.

SETB THERM3 ; 1. Release Data line.

MOV B,#6 ; 2. Set time interval.

CLR C ; 1. Clear presence flag.

WAITL3: JB THERM3,WH3 ;Exit loop if line high.

DJNZ B, WAITL3 ;Hang around for 3360

DJNZ ACC, WAITL3 ;us if line is low.

SJMP SHORT3 ;Line could not go high.

WH3: MOV B,#101 ;Delay for presence detect.

HL3: ORL C,/THERM3 ;202. Catch presence pulse.

DJNZ B, HL3 ;202. Wait with Data high.

SHORT3: RET ;Return.

; This procedure sends the byte in the accumulator

; to the 1-Wire device, and returns a byte from the

; 1-Wire device in the accumulator. Note that the NOPs

; in the following code are intended to give the

; optimum performance when using a 10 MHz crystal.

TOUCHBY3: PUSH B ;Save the B register.

MOV B,#8 ;Setup for 8 bits.

B_LOOP3: RRC A ;1. Get bit in carry.

LCALL TOUCHB3 ;2. Send bit.

DJNZ B, B_LOOP3 ;2. Get next bit.

RRC A ; Get final bit in ACC.

POP B ;Restore B register.

RET ;Return to caller.

TOUCHB3: CLR THERM3 ; 1. Start the time slot.

INC DPTR ; 2.

INC DPTR ; 2.

MOV THERM3,C ; 2. Send out the data bit.

INC DPTR ; 2.

INC DPTR ; 2.

INC DPTR ; 2.

MOV C, THERM3 ; 1. Sample input data bit.

PUSH B ; 2. Save B register.

MOV B,#16 ; 2. Delay until the end

DJNZ B,$ ;32. of the time slot.

POP B ;Restore B register.

SETB THERM3 ;Terminate time slot.

RET ;Return to caller.

; Read temperature from 1-wire thermometer DS1821.

; Returns C=1 in case of valid code, else C=0.

; Returns R1=DIG1, R2=DIG2, MINUS of themperature (-55..99).

; 1-wire port line called as THERM3.

; Calls TRESET3, TOUCHBY3

READ_T3: LCALL TRESET3 ;Issue reset pulse.

JNC RT3 ;Fail if no part on bus.

MOV A,#0AAH ;Read temperature command.

LCALL TOUCHBY3 ;Send command byte.

MOV A,#0FFH ;perform read

LCALL TOUCHBY3 ;Read temperature.

LCALL TCONV ;HEX to BCD conversion

SETB C

RT3: RET

; Themperature HEX to BCD conversion

; Input A=0..0C9H

; Returns R1=DIG1, R2=DIG2, MINUS of themperature (-55..99).

TCONV: JNB ACC.7,TPL

SETB MINUS

CPL A

INC A

MOV R2,A

SJMP L99

TPL: CLR MINUS

MOV R2,A

CLR C

SUBB A, R3

JC L99

SETB TOV ;set T overflow flag

MOV R02,R3 ;if R2>R3 then R2=R3 (R3=99 OR 55)

L99: MOV A, R2

MOV B,#10 ;HEX to BCD conversion

DIV AB

MOV R1,B

MOV R2,A

RET

; ------ 3-Wire Clock support ------

SET_CL: MOV A,#B ;CONTROL

MOV R0,#B

LCALL SHWR

MOV A,#B ;TRICKLE CHARGER

MOV R0,#B ;8K, 2 DIODES

LCALL SHWR

MOV A, CL1

SWAP A

ORL A, CL2

MOV R0,A

MOV A,#B ;HR

LCALL SHWR

MOV A, CL3

SWAP A

ORL A, CL4

MOV R0,A

MOV A,#B ;MIN

LCALL SHWR

MOV A,#B ;SEC

MOV R0,#00H

LCALL SHWR

RET

GET_CL: MOV A,#B ;HR

LCALL SHRD

MOV R0,A

SWAP A

ANL A,#0FH

MOV CL1,A

MOV A, R0

ANL A,#0FH

MOV CL2,A

MOV A,#B ;MIN

LCALL SHRD

MOV R0,A

SWAP A

ANL A,#0FH

MOV CL3,A

MOV A, R0

ANL A,#0FH

MOV CL4,A

RET

;Data read into serial port

;Input: A = address, Out: A = data

SHRD: SETB RST

MOV R1,#8H ;bit counter load

SHRD1: RRC A

MOV DATA, C

SETB CLK

CLR CLK

DJNZ R1,SHRD1

MOV R1,#8H ;bit counter load

SHRD2: MOV C, DATA

RRC A

SETB CLK

CLR CLK

DJNZ R1,SHRD2

Из за большого объема этот материал размещен на нескольких страницах:
1 2 3 4 5 6 7 8 9 10 11 12