PDA

View Full Version : more-than-8 bit temperature sensor I2C



picster
- 13th March 2006, 17:41
When using I2CREAD or I2CWRITE with a temp sensor that gives data measurements of more than one byte in length, does using a word size VAR automatically send a second address to the device (which I don't want to do), or how does one acquire a 2-byte data word at a single "address"?

(specifically, using the TCN75A temp sensor chip)

Thanks,

-------------------Picster---------------------

DynamoBen
- 13th March 2006, 18:26
I'm using the DS18S20 and it uses two bytes that I place into a word variable.

If you need to read two seperate bytes into one word variable try this:

temp var WORD

[temp.Lowbyte,temp.Highbyte]

picster
- 13th March 2006, 20:18
Are those two bites at one "address" location on the device?

--------------Picster------------

DynamoBen
- 13th March 2006, 20:29
"Are those two bites at one "address" location on the device?"

What is happening is the data starts at the specified address and then read two bytes in a row. My datasheet has byte0 and byte1 listed. Page 11 of your datasheet shows the bit pattern which indicates that the data is two bytes long.

If you want to try to read a whole word in one shot you can:

temp var WORD

[temp]