;dssensonsor auf portd0 ;*************************temp eines sensors lesen********************* ds18_0: rcall ds_reset ;wer ist da??? rcall skip_rom ;ansprechen aller slaves+vorbereitung der tempmessung rcall convert_t ;start tempmessung rcall ds_reset ;wer ist da??? rcall skip_rom ;ansprechen aller slaves+vorbereitung der tempmessung rcall read_scratchpad rcall ds_reset rcall ausgabe ret ;*****************************RESETPULS***************************************** ds_reset: sbi ddrd,0 cbi portd,0 rcall w500u cbi ddrd,0 rcall w70u wait_puls: sbic pind,0 rjmp wait_puls ;falls bus high zurück wait_puls_end: sbis pind,0 rjmp wait_puls_end ;falls bus low zurück ret ;*********ansprechen aller slave's, tempmessung auslösen aller sensoren** ;***nachfolgend muss keine adr gesendet werden nur 1slave einfache ***** ;***kommunikation ohne adr zu senden *********************************** skip_rom: ldi temp1,$cc rcall write_command ;read or write ret ;**************************read rom 64bits=8byte********************* read_rom: ldi temp1,$33 rcall write_command rcall lesen ;daten empfangen und lesen ret ;*******************read_scratchpad(auslesen der 9byte)**************** read_scratchpad: ldi temp1,$be rcall write_command rcall lesen ret ;***********Convert---T temperaturmessung starten im ds************* convert_t: ldi temp1,$44 rcall write_command rcall w6u cbi ddrd,0 rcall w9u ; rcall w750ms ;unterdrückung 85.00 im disp. convert_t1: sbis pind,0 rjmp convert_t1 ret ;*********************auslesen***************************************** lesen: rcall read_bit ;0 sts temp_lsb,temp3 rcall read_bit ;1 sts temp_msb,temp3 rcall read_bit ;2 sts th_register,temp3 rcall read_bit ;3 sts tl_register,temp3 rcall read_bit ;4 sts res_byte4,temp3 rcall read_bit ;5 sts res_byte5,temp3 rcall read_bit ;6 sts count_remain,temp3 rcall read_bit ;7 sts count_per_c,temp3 rcall read_bit ;8 sts crc,temp3 ret ;************************Unterprogramme****************************** write_command: ldi temp2,$08 write_command1: sbrs temp1,0 rcall write_0 sbrc temp1,0 rcall write_1 ror temp1 dec temp2 brne write_command1 ret write_1:cbi portd,0 sbi ddrd,0 rcall w6u cbi ddrd,0 rcall w64u ret write_0:cbi portd,0 sbi ddrd,0 rcall w60u cbi ddrd,0 rcall w10u ret read_bit: clr temp3 ;datenwort in temp3 ldi temp4,$08 read_bit0: ror temp3 cbi portd,0 sbi ddrd,0 rcall w6u cbi ddrd,0 rcall w9u sbis pind,0 rjmp read_bit1 ;0 lesen ldi temp2,$80 ;1 lesen add temp3,temp2 rjmp read_bit2 read_bit1: ldi temp2,$00 add temp3,temp2 read_bit2: rcall w55u dec temp4 brne read_bit0 ret ;***********************Zeiteschleifen******************************* wait_500us: ldi temp1,$03 wait_500us1: ldi temp0,$dd wait_500us2: dec temp0 brne wait_500us2 dec temp1 brne wait_500us1 ret wait_70us: ldi temp0,$5a nop wait_70us1: dec temp0 brne wait_70us1 nop nop ret wait_64us: ldi temp0,$54 wait_64us1: dec temp0 brne wait_64us1 ret wait_60us: ldi temp0,$4e wait_60us1: dec temp0 brne wait_60us1 ret wait_55us: ldi temp0,$41 wait_55us1: dec temp0 brne wait_55us1 ret wait_10us: ldi temp0,$0c wait_10us1: dec temp0 brne wait_10us1 ret wait_9us: ldi temp0,$0a wait_9us1: dec temp0 brne wait_9us1 ret wait_6us: ldi temp0,$06 wait_6us1: dec temp0 brne wait_6us1 ret