Problem with DS1620
user
Posts: 3
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: http://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
ReadTemperature:
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
This code I took from here: http://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
ReadTemperature:
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
Comments
The next time you're craving Chinese food try ordering it from Mexican restaurant and see how they respond.
As Mike points out, if your question is about the DS1620 then fine, but you seem to want code for a processor that is not supported on this forum. The 68HC11 is very popular with the Seattle Robotics Society, you might give them a try.
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, because I don't know other?
Your question will be emailed to all the members and someone always tries to help.