In SX Microcontrollers, SX/B Compiler and SX-Key Tool, user01 wrote: 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 ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=385864 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)