Communication with I2C device not working correctly

Hello all,

I have recently been assigned a task to sort of automate I2C communication with a TI DS90UB949-Q1 Serializer but I am running into some trouble. I think a good portion of my troubles is due to my lack of I2C knowledge, so I’ve come here for guidance.

I’m essentially trying to convert a raspberry pi script to Arduino. Here is part of the Raspberry Pi script:

# Enable passthrough for I2C
i2cset -y -f 1 0x0C 0x03 0xDA

# Enable I2C address 0x2D (Backlight controller)
i2cset -y -f 1 0x0C 0x08 0x5A
i2cset -y -f 1 0x0C 0x07 0x5A

# Enable I2C address 0x52 (MCU)
i2cset -y -f 1 0x0C 0X70 0xA4
i2cset -y -f 1 0x0C 0X77 0XA4

# Enable I2C address 0x24 (Touch controller)
i2cset -y -f 1 0x0C 0X71 0x48
i2cset -y -f 1 0x0C 0X78 0X48

# Enable GPIO3 (Backlight enable) SER -> DES
i2cset -y -f 1 0x0C 0x0f 0x03
i2cset -y -f 1 0x34 0x1f 0X05

# Enable GPIO1 (Diagnostic IRQ) and GPIO2 (ALS IRQ) DES -> SER
i2cset -y -f 1 0x0C 0x0e 0x55
i2cset -y -f 1 0x34 0x1e 0x33

# Enable GPIO0 (Backlight fault) DES -> SER
i2cset -y -f 1 0x0c 0x0d 0x05
i2cset -y -f 1 0x34 0x1d 0x03

I want to convert i2cset to an Arduino function, but the code I currently have does nothing. Here is my Arduino code:

Setup

#include <Wire.h>
byte eval = 0x0C;
int code;
void setup()
{
  Serial.begin(115200);
  Wire.begin(eval);
  delay(2000);

  sendData(0x0C, 0x03, 0xDA); //Enable passthrough for I2C
  delay(200);
  sendData(0x0C, 0x08, 0x5A); //Enable I2C address 45 (Backlight controller)
  delay(200);
  sendData(0x0C, 0x07, 0x5A);
  delay(200);
  sendData(0x0C, 0x70, 0xA4); //Enable I2C address 0x52 (MCU)
  delay(200);
  sendData(0x0C, 0x77, 0xA4);
  delay(200);
  sendData(0x0C, 0x71, 0x48); //Enable I2C address 0x24 (Touch controller)
  delay(200);
  sendData(0x0C, 0x78, 0x48);
  delay(200);
  sendData(0x0C, 0x0F, 0x03); //Enable GPIO3 (Backlight enable) SER -> DES
  delay(200);
  sendData(0x34, 0x1F, 0x05);
  delay(200);
  sendData(0x0C, 0x0E, 0x55); //Enable GPIO1 (Diagnostic IRQ) and GPIO2 (ALS IRQ) DES -> SER
  delay(200);
  sendData(0x34, 0x1E, 0x33);
  delay(200);
  sendData(0x0C, 0x0D, 0x05); //Enable GPIO0 (Backlight fault) DES -> SER
  delay(200);
  sendData(0x34, 0x1D, 0x03);
  delay(200);
  sendData(0x2D, 0x1A, 0x08); //Unlock EEPROM
  delay(200);
  sendData(0x2D, 0x1A, 0xBA);
  delay(200);
  sendData(0x2D, 0x1A, 0xEF);
  delay(200);
  sendData(0x2D, 0x19, 0x02); //Program EEPROM
  delay(200);
  sendData(0x2D, 0x19, 0x00);
  delay(200);
  sendData(0x2D, 0x00, 0xFF); //FF = 100% brightness; 80 = 50% brightness; 00 = 0% brightness
  delay(200);
  sendData(0x2D, 0x01, 0xFF);

  Serial.write("Pass complete");
}

Send Data Function

void sendData(byte a, byte b, byte c)
{
  Serial.print("\na is:");
  Serial.print(a);
  Serial.print("\nb is:");
  Serial.print(b);
  Serial.print("\nc is:");
  Serial.print(c);
  Serial.print("\n");
  
  Wire.beginTransmission(eval);
  Wire.write(a);
  Wire.write(b);
  Wire.write(c);
  code = Wire.endTransmission();
  Serial.print(code);
  Serial.print("\n");
}

Can anyone give me any guidance of what I am doing wrong? I assume it’s because I’m not writing the values to the correct registers, but I have hit a wall on how to move forward.

Thanks for the help!

Your code doesn't compile!

Your sendData() should look like this to more or less emulate the i2cset call:

void sendData(byte a, byte b, byte c)
{
  Serial.print("\na is:");
  Serial.print(a);
  Serial.print("\nb is:");
  Serial.print(b);
  Serial.print("\nc is:");
  Serial.print(c);
  Serial.print("\n");
 
  Wire.beginTransmission(a);
  Wire.write(b);
  Wire.write(c);
  code = Wire.endTransmission();
  Serial.print(code);
  Serial.print("\n");
}

Thanks for the response, pylon! I realized once I posted the code that I accidentally had "Serial.write()" instead of "Serial.print()", but I fixed that once I started seeing garbage values in the serial terminal.

Your suggestion worked like a charm! Thank you so much for the help, I appreciate it very much.