You can find spec sheet on digikey, page 12 forward is where most of the information related to I2C.
I'm using a Atmega32U4 (Arduino Leonardo) to communicate with the SM72445 controller. (coding interface is same as SM72442)
I'm confidant that that I am indeed reading from the registers, the problem is that the data is incoherent or inconsistent throughout whole register. If I parse the input voltage, it widely swings from near zero to near max. The most logical answer is that a more LSB is pushed into MSB position but I can't figure out how I'm doing it wrong.
The first byte is always read as = 0x7 on every register which is obviously wrong, and even on static registers the blank bytes aren't properly blanked.
I'm working on the assumption that register command value 0xE0 = register0,....0xE5 = register5
Am I not following proper I2C procedure and getting garbage data, or am I completely miss understanding what the spec sheet is saying and splitting the data incorrectly?
Better yet, any example code? I can't find any online.
void getData (int addr, int reg)
{
// uint8_t temp_data[10];
Wire.beginTransmission(addr);
Wire.write(reg); // pointer to register for reading
Wire.endTransmission(false);
Wire.requestFrom(addr, 7); // request data from
temp_data[0] = Wire.read();
temp_data[1] = Wire.read();
temp_data[2] = Wire.read();
temp_data[3] = Wire.read();
temp_data[4] = Wire.read();
temp_data[5] = Wire.read();
temp_data[6] = Wire.read();
// for (int i = 0; i <= 7; i++)
// {
// if (Wire.available())
// temp_data[i] = Wire.read();
// }
sm_data16[0] = temp_data[0] | ((temp_data[1] & B00000011) << 8);
sm_data16[1] = (temp_data[1] >> 2) | ((temp_data[2] & B00001111) << 6);
// sm_data16[2] = (temp_data[2] >> 4) | (temp_data[3] << 4);
// sm_data16[2] = sm_data16[2] & 0x03FF;
//
// sm_data16[3] = (temp_data[3] >> 6) | (temp_data[4] << 2);
// sm_data16[3] = sm_data16[3] & 0x03FF;
current_in = ((double)sm_data16[0] / 1023) * 5; // convert to voltage on pin
current_in /= 0.152418; // add back in op-amp gains and shunt value.
volt_in = ((double)sm_data16[1] / 1023) * 5; // convert to voltage on pin
volt_in *= 49.7; // add voltage divider back
// // current_out =
// // volt_out =
}