# Problem with DS1620 - temperature on the LCD

Status
Not open for further replies.

#### user0123

##### Newbie level 4
Problem with DS1620

My 68HC11 project is complete, but when show the temperature on the LCD it always show 28.5 oC, or in BCD – 00111001. I don’t know why. I read the code couple of times to make sure that I didn’t make something wrong. Can somebody help me.

This code I took from here: https://www.emicros.com/ds1620.htm and modify it little because it was showing 0 oC

This is fragments of the code:

RSTTEMP equ %00100000
I_O equ %00001000
SCLK equ %00010000

ldx #REGBLK
bset DDRD,x %00111000
bclr PortD,x SCLK
bset PortD,x RSTTEMP
ldaa #$AA ldab #8 ZS: bclr PortD,x I_O lsra bcc NS bset PortD,x I_O NS: bset PortD,x SCLK nop nop nop bclr PortD,x SCLK decb bne ZS clr TempLSB clr TempMSB bclr DDRD,x I_O ldab #8 JJ: nop nop nop bset PortD,x SCLK clc brclr PortD,x I_O HJ sec HJ: ror TempLSB bclr PortD,x SCLK decb bne JJ bset PortD,x SCLK brclr PortD,x I_O AD ldaa #1 staa TempMSB AD: bclr PortD,x SCLK bset DDRD,x I_O bclr PortD,x RSTTEMP ldab TempLSB rts BCD2STR: psha anda #$0F
oraa #$30 staa 1,x pula asra asra asra asra anda #$0F
oraa #$30 staa 0,x rts ldaa Str2+1 cmpa LastSecond beq NoNewTemp staa LastSecond jsr ReadTemperature lsrb bcc Set00 ldaa #'5' bra Set05 Set00: ldaa #'0' Set05: staa Str2+12 clra tba ldx #Str2+9 jsr BCD2STR clrb ldab TempMSB cmpb #$1
bne NoNewTemp
ldaa #'-'
staa Str2+8

#### user0123

##### Newbie level 4
Re: Problem with DS1620

I put this code in the initialization:

ldx #REGBLK
bset DDRD,x %00111000
bclr PortD,x SCLK
bset PortD,x RSTTEMP
ldaa #$EE ldab #8 ZS1: bclr PortD,x I_O lsra bcc NS1 bset PortD,x I_O NS: bset PortD,x SCLK nop nop nop bclr PortD,x SCLK decb bne ZS1 When I done this I begin to get different readings such as 3=, 2> and so on. So I put this code for the convertion from BCD to degrees, showing on LCD: clra ldx #10 idiv orab #$30
stab str2+10
xgdx
ldx #10
idiv
orab #\$30
stab str2+9

When I put it I begin to get from 40oC to 65-70oC, but without any marks or unknown symbols.

I'm surprised of this reading, because the temperature on the corpus of the device is not more than 25-27oC, even colder.

Is there an error in the code for the conversion?
Can somebody tell me better method?

Status
Not open for further replies.

Replies
2
Views
1K
Replies
1
Views
2K
Replies
1
Views
917
Replies
1
Views
2K
Replies
2
Views
3K