;---------------------------------------------------------------------------------------- ;** Funktionen: put1620byte -> Schreibt den Wert von ds1620byte in DS1620 ;---------------------------------------------------------------------------------------- put1620byte: setb p1.0 ; CLK High setb p1.1 ; RST = HIGH mov b, #8 ; Schleifenzähler in b mov a, ds1620byte wordlength: clr p1.0 ; CLK low rrc a ; auszugebenes Bit ins Carry mov p1.2,c ; Carry an dq setb p1.0 ; CLK high djnz b,wordlength go_back: ret ;---------------------------------------------------------------------------------------- ;** Funktionen: get1620byte -> liest den Wert von DS1620 in 1620byte ;---------------------------------------------------------------------------------------- get1620byte: mov p1, #2 ;| DQ = HIGH=INPUT setb p1.0 ; CLK High setb p1.1 ; RST = HIGH mov bit_stelle2, #7 wordlength2: mov a, bit_stelle2 cjne a, #7, vorzeichenbit clr p1.0 ;|CLOCK= LOW inc bit_stelle2 setb p1.0 ;|CLOCK= HIGH mov a, p1 anl a, #2 cjne a, #2, write_0 write_1: mov a, ds1620byte setb c rrc a mov ds1620byte, a jmp wordlength2 write_0: mov a, ds1620byte clr c rrc a mov ds1620byte, a jmp wordlength2 vorzeichenbit: clr p1.0 ;|CLOCK= LOW inc bit_stelle2 setb p1.0 ;|CLOCK= HIGH mov a, p1 anl a, #2 cjne a, #2, kein_vorzeichen mov vorzeichen, #1 mov p1, #0 ;|OUTPUT ret kein_vorzeichen: mov vorzeichen, #0 mov p1, #0 ;|OUTPUT ret ;---------------------------------------------------------------------------------------- ;** Funktionen: liest Temperatur von DS1620 in 1620byte ;---------------------------------------------------------------------------------------- get_temperatur: ;setb p1.0 ; CLK High ;setb p1.1 ;|RST = HIGH | mov ds1620byte, #0EEh ;| | Start call put1620byte ;| |Convert clr p1.1 ;|RST = LOW | ;setb p1.0 ; CLK High ;setb p1.1 ;|RST = HIGH | mov ds1620byte, #022h ;| | Stop call put1620byte ;| | Convert clr p1.1 ;|RST = LOW | setb p1.0 ; CLK High setb 1.1 ;|RST = HIGH | mov ds1620byte, #0AAh ;| | call put1620byte ;| |read value in mov ds1620byte, #0 ;| |"temperatur" call get1620byte ;| | clr p1.1 ;|RST = LOW | mov a, ds1620byte ;| | mov temperatur, a ;| | ret