I am trying to read the 16 bit ambient temperature register of a MCP9800 via I2C
( http://ww1.microchip.com/downloads/en/D ... 21909b.pdf )
Before I even try and perform the calculation to convert the 16 bit code into the temperature can anyone tell me how to read the 16 bit temperature register , and perhaps some pointers on converting the two's complement to temperature + and -,
Thank you in anticipation,
Ben
I have established I2C communication from a 16F877A to the MCP9800, but I am only getting a byte back ( the upper half? ).
An example of what I am getting, returns 11100111 or decimal 231 ( err... I think! ). With the default 9 bit ADC resolution this would have to be halved ( err... I think! ). I am not sure why the MSB is set as this suggests a negative value.
![Image](http://www.robinhoodsbay.org/i2C.jpg)
The flow code. Perhaps this is a little naΓ―ve, but at least I have got the hardware talking!!
From the Microchip data sheet……….
AMBIENT TEMPERATURE
REGISTER (TA) The MCP9800/1/2/3 has a 16-bit read-only ambient
temperature register (TA) that contains 9-bit to 12-bit
temperature data. This data is formatted in two’s
complement. The bit assignments, as well as the
corresponding resolution, is shown in the register
assignment below.
![Image](http://www.robinhoodsbay.org/calc.jpg)
![Image](http://www.robinhoodsbay.org/reg.jpg)