Please help~~~ I2C communication with TI LDC161x

I used to control some small circuit using Arduino, simple code, simple design. Now, I been told to use UNO R3 A4 A5 port to communication with TI LDC161X, get the value from address, and put the value to other address. Is there any one know how to do that?

I really appreciate your time.

double35893904:
I used to control some small circuit using Arduino, simple code, simple design. Now, I been told to use UNO R3 A4 A5 port to communication with TI LDC161X, get the value from address, and put the value to other address. Is there any one know how to do that?

I really appreciate your time.

Maybe this can help you get started? As you may know, the I2C protocol addresses the device using a single byte device address. I did not find it while browsing the document, but I guess it should be there. Alternatively write a loop that tests all 255 of them (0 not valid address I think).

Then communication is usually about querying and writing to registers, and I found lots of register identifiers in the document referenced above.

If unsure about i2c, check out the Wire library at Wire - Arduino Reference - it is fairly easy to use.

[Edit]
See section 7.5.1 for info about i2c. Device address is 0x2A or 0x2B depending on whether an address pin is driven low or high, respectively (thus, supporting two devices per i2c bus)

thanks a lot.

Rupert909:
http://www.ti.com/lit/ds/snoscy9/snoscy9.pdf

Maybe this can help you get started? As you may know, the I2C protocol addresses the device using a single byte device address. I did not find it while browsing the document, but I guess it should be there. Alternatively write a loop that tests all 255 of them (0 not valid address I think).

Then communication is usually about querying and writing to registers, and I found lots of register identifiers in the document referenced above.

If unsure about i2c, check out the Wire library at Wire - Arduino Reference - it is fairly easy to use.

[Edit]
See section 7.5.1 for info about i2c. Device address is 0x2A or 0x2B depending on whether an address pin is driven low or high, respectively (thus, supporting two devices per i2c bus)

Rupert909:
http://www.ti.com/lit/ds/snoscy9/snoscy9.pdf

Maybe this can help you get started? As you may know, the I2C protocol addresses the device using a single byte device address. I did not find it while browsing the document, but I guess it should be there. Alternatively write a loop that tests all 255 of them (0 not valid address I think).

Then communication is usually about querying and writing to registers, and I found lots of register identifiers in the document referenced above.

If unsure about i2c, check out the Wire library at Wire - Arduino Reference - it is fairly easy to use.

[Edit]
See section 7.5.1 for info about i2c. Device address is 0x2A or 0x2B depending on whether an address pin is driven low or high, respectively (thus, supporting two devices per i2c bus)

I been told to read value from TI LDC161X address and write back into another address.

e.g. If I want use UNO A4 to get 002 value on LDC161X, and write back to 00E address. what should I do?

(deleted)

double35893904:
I been told to read value from TI LDC161X address and write back into another address.

e.g. If I want use UNO A4 to get 002 value on LDC161X, and write back to 00E address. what should I do?

This is what I'd try, after conferring with the document I linked to. The source has not been tested, not even compiled. Doing this is a learning experience for me as well, in that I'm getting used to the connection between the diagrams used in data sheets (figures 15 and 16 of the PDF I linked to) and the code. The point being to understand what the Wire library takes care off and not.

I think I will have to look up some more details about the Wire library one of these days, and write me a soft-Wire for verification, as I did with SPI. Programming is fun!!!

const byte ADDR = 0x2A;

void setup() {
	Wire.begin();
	unsigned int value=readTwoByteRegister(0x02);
	writeTwoByteRegister(0x0E, value);
}

unsigned int readTwoByteRegister (byte reg) {
	Wire.beginTransmission(ADDR);

	Wire.write(reg);
	Wire.endTransmission();
	Wire.requestFrom(ADDR, 2); // request 2 bytes back
	//if (Wire.available() >= 2) {
		return (Wire.read() << 8) | Wire.read();
	//} 
	//Serial.println("- NO I2C DATA -");
	//return 0;
}

void writeTwoByteRegister (byte reg, unsigned int value) {
	Wire.beginTransmission(ADDR);

	Wire.write(reg);
	Wire.write(value >> 8);
	Wire.write(value & 0xFF);
	Wire.endTransmission();
}

In other word: please give feedback on whether it succeeds and what changes you needed to do! :slight_smile: