I am using TI's TCA9539 for some read and write I2C operation to control some signals on my test board (school project). Per TI, the write operation comprises of the following,
"To write on the I2C bus, the master sends a START condition on the bus with the address of the slave, as well as the last bit (the R/W bit) set to 0, which signifies a write. After the slave sends the acknowledge bit, the master then sends the register address of the register to which it wishes to write. The slave acknowledges again, letting the master know it is ready. After this, the master starts sending the register data to the slave until the master has sent all the data necessary (which is sometimes only a single byte), and the master terminates the transmission with a STOP condition."
However i am always getting a Nack from slave when i send the register address information to the slave.
Here is my sample code (very basic)
int Address = 0x74;
#define control_register 0x02 // command byte for Output Port 0
#define data_register_1 0xFF
void setup()
{
byte ack;
Wire.begin();
Serial.begin(9600);
while (!Serial);
Wire.beginTransmission(Address);
ack = Wire.endTransmission();
if (ack == 0)
{
Wire.beginTransmission(control_register);
Serial.print("Control Register is : ");
byte bck = Wire.endTransmission();
if (bck == 0) // since i dont get a nack, this portion of code doesnt execute
{
Wire.write(control_register);
Wire.write(data_register_1);
}
}
}
beginTransmission
calls is wrong. \$\endgroup\$