At 18:19 19/03/1997 -0500, you wrote: >Hello to all of you! > >Is there any of you who might know how to interface the DS1620 Digital >thermometer/thermostat with a PIC16C84? Can you give me any pointers or code >that could help me with that? > >Thank you! >Jean-Francois J. >--------------- >Jean-Francois & Alain Joly >jolyal@capitalnet.com > >Hello, here's the salvation, please include my name in your code (Alejandro Pieroni ) Bye!!! ;************************************************************** ; DS1620 ROUTINES ;************************************************************** ;**************** CHECK PRESENCE ******** CheckDS1620: clrwdt ; clear Watchdog CBANK0 ; set bank 0 call LCD_Clr ; clear lcd movlw CheckScreen_l1a ; call Print_Table ; bsf CHIPPORT,PWR_ON ; turn on DS1620 sleep ; wait to stabilize nop ; sleep ; wait to stabilize nop ; sleep ; wait to stabilize nop ; sleep ; wait to stabilize nop ; sleep ; wait to stabilize nop ; sleep ; wait to stabilize nop ; call DS1620_READCFG ; read config movfw CONFIG_REGISTER ; put config in w andlw b'00001100' ; sublw b'00001000' ; skpz ; skip if zero goto DS1620_ERROR ; movlw SND_LINE ; 2nd line of display call LCD_Cmd ; do it movlw CheckScreen_l1b ; call Print_Table ; ; movlw 0x02 ; ; movwf ACC_C ; CPU MODE ; call DS1620_WRITECFG ; ; movlw .12 ; ; movwf ACC_C ; ; clrf ACC_D ; ; call DS1620_WRITETH ; 6 grados celsius TOP ; movlw .6 ; ; movwf ACC_C ; ; clrf ACC_D ; ; call DS1620_WRITETL ; 3 grados celsius BOTTOM call DS1620_STARTCONV ; start conversion sleep ; nop ; sleep ; nop ; return ; DS1620_ERROR: bcf CHIPPORT,PWR_ON ; turn off DS1620 movlw SND_LINE ; 2nd line of display call LCD_Cmd ; do it movlw CheckScreen_l1c ; call Print_Table ; _error nop ; sleep ; nop ; goto _error ; ;**************** READ COMMANDS ********* DS1620_READTEMP: ; movlw READTEMP ;Read Temperature command in w call DS1620_SENDCMD ; send it to DS1620 ( 8 bits ) call DS1620_READ9 ; Read Temperature (9 bits) movfw ACC_A ; movwf TEMPERATURE ; movfw ACC_B ; movwf TEMPERATURE9 ; call DS1620_TOGGLE ; return ; DS1620_READTH: ; movlw READTH ; Read Temperature High in w call DS1620_SENDCMD ; send it to DS1620 ( 8 bits ) call DS1620_READ9 ; Read Temperature (9 bits) movfw ACC_A ; movwf TEMPERATURE_HIGH ; movfw ACC_B ; movwf TEMPERATURE_HIGH9 ; call DS1620_TOGGLE ; return ; DS1620_READTL: ; movlw READTL ; Read Temperature Low in w call DS1620_SENDCMD ; send it to DS1620 ( 8 bits ) call DS1620_READ9 ; Read Temperature (9 bits) movfw ACC_A ; movwf TEMPERATURE_LOW ; movfw ACC_B ; movwf TEMPERATURE_LOW9 ; call DS1620_TOGGLE ; return ; DS1620_READCFG: ; movlw READCONFIG ; Read Config byte call DS1620_SENDCMD ; send it to DS1620 ( 8 bits ) call DS1620_READ8 ; Read Config (8 bits) movfw ACC_A ; movwf CONFIG_REGISTER ; call DS1620_TOGGLE ; return ; ;**************** WRITE COMMANDS ******** DS1620_WRITETH: ;ACC_C(low byte)ACC_D(high byte) movlw WRITETH ; call DS1620_SENDCMD ; movfw ACC_C ; movwf ACC_A ; movfw ACC_D ; movwf ACC_B ; call DS1620_WRITE9 ; call DS1620_TOGGLE ; return ; DS1620_WRITETL ; ACC_C: low byte ACC_D: high byte movlw WRITETL ; call DS1620_SENDCMD ; movfw ACC_C ; movwf ACC_A ; movfw ACC_D ; movwf ACC_B ; call DS1620_WRITE9 ; call DS1620_TOGGLE ; return ; DS1620_WRITECFG ; ACC_C: config byte movlw WRITECONFIG ; call DS1620_SENDCMD ; movfw ACC_C ; movwf ACC_A ; call DS1620_WRITE8 ; call DS1620_TOGGLE ; return ; DS1620_STARTCONV: movlw STARTCONV call DS1620_SENDCMD ; bcf CHIPPORT,NOT_RST; reset device call DS1620_TOGGLE ; return ; DS1620_STOPCONV: movlw STOPCONV call DS1620_SENDCMD ; bcf CHIPPORT,NOT_RST; reset device call DS1620_TOGGLE ; return ; DS1620_TOGGLE: bsf CHIPPORT,NOT_RST; enable device nop ; nop ; nop ; bcf CHIPPORT,NOT_RST; reset device return ; ;**************** SEND COMMANDS ********* DS1620_SENDCMD: CBANK0 ; set bank 0 bsf CHIPPORT,CLK ; clk=1 -> DQ=HiZ bsf CHIPPORT,NOT_RST; enable device movwf ACC_A ; save command in ACC_A _w8r movlw .8 ; cant de rotaciones movwf TEMP ; en Temp _cloop bsf CHIPPORT,DQ ; btfss ACC_A,0 ; test if bit=1 bcf CHIPPORT,DQ ; bit=0 bcf CHIPPORT,CLK ; clk LOW nop ; delay bsf CHIPPORT,CLK ; clk HIGH -> latch data nop ; delay rrf ACC_A ; rotate right decfsz TEMP ; test if 7 rotaciones goto _cloop ; do loop return ; DS1620_WRITE8: call _w8r ; goto _wend ; DS1620_WRITE9: call _w8r ; bcf CHIPPORT,CLK ; clk LOW bsf CHIPPORT,DQ ; btfss ACC_B,0 ; test if 9th bit=1 bcf CHIPPORT,DQ ; bit=0 _wend bsf CHIPPORT,CLK ; clk HIGH -> latch data nop ; bcf CHIPPORT,NOT_RST; reset device movlw .255 ; call LCDelay ; movlw .255 ; call LCDelay ; movlw .255 ; call LCDelay ; movlw .255 ; call LCDelay ; return ; DS1620_READ8: call READ_8 ; read 8 bits clrf ACC_B ; goto _rend ; DS1620_READ9: call READ_8 ; bsf CHIPPORT,CLK ; CLK=1 -> DQ HiZ nop ; bcf CHIPPORT,CLK ; clk LOW -> DS1620 put data in DQ movlw .1 ; btfss CHIPPORT,DQ ; test if DQ=1 movlw .0 ; movwf ACC_B ; 9 bit _rend bsf CHIPPORT,CLK ; DQ to HiZ nop ; bcf CHIPPORT,NOT_RST; reset device CBANK1 ; set bank 1 bcf CHIPTRIS,DQ ; DQ as output CBANK0 ; set bank 0 return ; LSB->ACC_A MSB->ACC_B READ_8: CBANK1 ; set bank 1 bsf CHIPTRIS,DQ ; DQ as input CBANK0 ; set bank 0 movlw .8 ; cant de bits 8 movwf TEMP ; en Temp _dloop bsf CHIPPORT,CLK ; CLK=1 -> DQ HiZ nop ; bcf CHIPPORT,CLK ; clk LOW -> DS1620 put data in DQ setc ; carry=1 btfss CHIPPORT,DQ ; test if DQ=1 clrc ; no, carry=0 rrf ACC_A ; put bit in ACC_A decfsz TEMP ; goto _dloop ; return ;