I may have misunderstood this but the formula in the data sheet has an additional subtraction of ¼°C which when it is in 12 bit format would be minus 4.
I may have misunderstood this but the formula in the data sheet has an additional subtraction of ¼°C which when it is in 12 bit format would be minus 4.
I just assumed they were "rounding" the number. The least significant bit in the DS18S20 temperature word is 1/2° but the "count_remain" byte, or 4 bits actually, is the full fractional portion of the Celsius temperature reading.
Could I be mis-comprehending the info' in the Data Sheet?
That datasheet formulas make me sick.I still cannot have a better understand how the formula works.
DS18S20 gives 0.5 in the LSB of the lower temperature register.
My full try is to make a one decimal digit with a least amount of math routines used.Because I'm showing the temperature on SSD's so no any latch functions.So have to do all the calculations within a unnoticeable time.
Just use the integer portion of the temperature in the low byte (get rid of the 1/2 degree bit by shifting it out). Then use the 'count_remain' byte value as a (reverse) index (0..15) into your fraction table...
I saw your other thread over on Forum.Microchip and I just wanted to mention that the temperature data is a sign-extended two's compliment number.
When the most significant bit is a '1' then the number is negative and you need to two's compliment it to make it positive (the "absolute" subroutine call in my example). You would need to do this on the fractional bits too.
When the most significant bit is a '1' then the number is negative and you need to two's compliment it to make it positive (the "absolute" subroutine call in my example). You would need to do this on the fractional bits too.
Yep I have done that.The problem was with the reverse index.I can understand your code.
But with this line
"I meant that you might do something like this (data in table is reversed)"
means the table must arranged in reverse order? like starting from retlw 15(value) ,retlw14(value).......retlw 1(value).