Aliases and Modifiers
SteveD
Posts: 64
My understanding according to the Syntax Manual concerning the symbols ".Byte1" and ".Byte0" are identical to ".HIGHBYTE" and ".LOWBYTE."· Is this correct?
Thanks
Steve
Thanks
Steve
Comments
···· jonw
tempIn = tempIn >> 1 ' remove half degree bit
******tempIn.BYTE1 = -tempIn.BIT7 ' extend sign bit*********
tC = tempIn * 100 ' convert to 100ths
tC = tC - 25 + (slope - cRem * 100 / slope) ' fix fractional temp
******IF (tC.BIT15 = 0) THEN***********
tF = tC */ $01CC + 3200 ' convert pos C to Fahr
ELSE
tF = 3200 - ((ABS tC) */ $01CC) ' convert neg C to Fahr
ENDIF
I am not seeing how this line " tempIn.BYTE1 = -tempIn.BIT7 " moves anything to tC.BIT.15. I could see it putting in tC.BIT.8.
The line
tempIn.byte1 = -tempIn.bit7
does what it says: extends the sign bit. If that bit happens to be a 1, then all the bits in tempIn.byte1 become ones.
Suppose the temperature is +2 degrees. The the DS1620 returns a 9 bit raw value of %000000010.
But if the temperature is -2, then the DS1620 returns a 9 bit raw value of %111111110. In 16 bit twos complement, the correct binary for -2 is, %1111111111111110. The ninth bit from the DS1620 thus has to be "extended" to fill all the bits. So, tC bit 15 is in fact affected if the original value is negative.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com