RCALL reset_pulse_1; RCALL skip_rom_1; RCALL convert_t_1; RCALL reset_pulse_1; RCALL skip_rom_1; RCALL read_scratchpad_1; RCALL reset_pulse_1; ... reset_pulse_1: SBI DDRT1, PinT1; //PD5 als Ausgang setzten CBI PortT1, PinT1; //Bit an PD5 löschen(o setzten) RCall wait480us; // Ausgang mind. 480us auf low halten CBI DDRT1,PinT1; wait_presence_pulse_1: // warten, bis Sensor auf LOW geht (presence pulse) sbic pind, PinT1; // Wenn presence pulse, dann nächsten Befehl überspringen rjmp wait_presence_pulse_1; wait_presence_pulse_end_1: // warten, bis Sensor wieder auf high geht (ende presence pulse) sbis pind, PinT1; // Wenn presence pulse ende, dann nächsten befehl überspringen rjmp wait_presence_pulse_end_1; RCALL wait405us; ret; skip_rom_1: LDI temp1, 0xCC; // 0xCC = SKip Rom command mov befehl, temp1; // Ins Register Befehl schieben rcall write_command_1; ret; write_command_1: sbi PortT1,PinT1; sbi DDRT1,PinT1; sbrs befehl,0; rcall write_1_0; sbrc befehl,0; rcall write_1_1; ror befehl; ldi temp1, 7; rcall wait1us; write_command_1_1: sbi PortT1,PinT1; sbi DDRT1,PinT1; sbrs befehl,0; rcall write_1_0; sbrc befehl,0; rcall write_1_1; ror befehl; rcall wait1us; dec temp1; brne write_command_1_1; SBI PortT1,PinT1; SBI DDRT1,PinT1; ret; write_1_1: cbi PortT1,PinT1; //Bit an PortD-5 auf 0, low setzten; sbi DDRT1,PinT1; //PortD-5 als Ausgang setzten RCall wait6us; //6us warten, maximum 15 cbi DDRT1,PinT1; //PortD-5 als Eingang setzten, bus loslassen, durch Widerstand jetzt auf high rcall wait64us; //Muss mindestens auf 60us auf high bleiben; ret; write_1_0: cbi PortT1,PinT1; sbi DDRT1,PinT1; rcall wait64us; cbi DDRT1,PinT1; ret; convert_t_1: ldi temp1, 0x44; mov befehl, temp1; rcall write_command_1; cbi DDRT1,PinT1; cbi PortT1,PinT1; wait_conversion_end_1: // warten, bis Sensor wieder auf high geht (ende presence pulse) sbis pind, PinT1; // Wenn presence pulse ende, dann nächsten befehl überspringen rjmp wait_conversion_end_1; ret; read_scratchpad_1: ldi temp1, 0xBE; mov befehl, temp1; rcall write_command_1; rcall read_bit_1; mov temperature_lsb_1, temp3; ret; read_bit_1: ldi temp3,0; ldi temp1,8; sbi PortT1,PinT1; sbi DDRT1,PinT1; read_bit_1_0: ror temp3; cbi PortT1,PinT1; sbi DDRT1,PinT1; rcall wait1us; cbi DDRT1,PinT1; rcall wait12us; sbis pind,PinT1; //Nachschauen, was jetzt anliegt, wenn 1, dann überspringen, wenn 0 dann nächsten befehl rjmp read_bit_1_1; ldi temp2, 128; add temp3, temp2; rjmp read_bit_1_2; read_bit_1_1: ldi temp2,0; add temp3,temp2; read_bit_1_2: rcall wait120us; dec temp1; brne read_bit_1_0; //fertiges byte in temp3 ret;