PMBus with Arduino

Hi, I am trying to interface to a power monitoring chip LM5066 data sheet, product information and support | TI.com using an Arduino Pro Mini. I have the right address and the chip "responds", but I get garbage values.

Does the following command sequence to read a register make sense for PMBus? (using Arduino 1.5)

  int addr = 64;
  Wire.beginTransmission(addr);

  // Ask for MFR_MODEL "Retrieves Part number in ASCII characters. (LM5066\0\0)."
  Wire.write(0x9A);
  
  Wire.endTransmission();

  byte n = Wire.requestFrom(addr, 8);
  Serial.print(n);
  Serial.print(" ");

  while (Wire.available())    // slave may send less than requested
  {
    char c = Wire.read();    // receive a byte as character
    Serial.print(c);         // print the character
  }

The output I get is unfortunately:

8 ÿÿÿÿÿÿÿÿ

EDIT: I moved where the endTransmission() is called. Seems from docs it should go after the write() command. I still get the same output.

EDIT 2: I am able to write commands to the device. For example,

  Wire.beginTransmission(addr);
  Wire.write(0x01);
  Wire.write(0x00);
  Wire.endTransmission();

successfully turns off the MOSFET. However, I still don't know how to read registers.

Try to change this line

 byte n = Wire.requestFrom(addr, 8);

to

 byte n = Wire.requestFrom(addr, 8, (uint8_t) false);

to keep the Wire library from sending the stop condition but to send a repeated start condition.

Sorry for bumping this one, but it's relevant to a problem I'm having as well, and since this guy never got a sufficient answer it seems silly to create a new topic. as googling "PMBus Arduino" gives this post as the top answer. The problem the original poster appears to be having is the same as mine, although I think his code may be slightly wrong. It seems the 0xFF being returned all the time may be the result of the I2C lines being pulled up to a voltage too high for the slave to cope with. This isn't the issue I'm having however, my pullup voltage is correct for both Arduino and slave.

The process should be according to the PMBus spec:

PMBus_SPEC:
• The host sends the PMBus device’s seven bit address plus Bit 0 equal to zero.
• The slave device ACKs.
• The host sends the command code for VOUT_OV_FAULT_LIMIT.
• The slave device ACKs.
• The host device sends a Repeated START Condition, the PMBus device’s seven bit address plus Bit 0 equal to one (indicating a read).
• The slave device ACKS and transmits the lower byte of the two data bytes.
• The host ACKS.
• The slave device ACKS and transmits the upper byte of the two data bytes.
• The host does not acknowledge (NACKS) and sends a STOP Condition. This ends the transaction.

Wire.beginTransmission(address); // start transmission
Wire.write(command); // send command
Wire.endTransmission(false); // don't send a stop condition
int l=Wire.requestFrom(address, (uint8_t)lengthExpected); // request expected number of bytes to be returned
while(l>0 && Wire.available()) // loop all bytes if any are available
{
  Serial.print(Wire.read(), HEX); // print em out
  Serial.print(" ");
}

Feel free to correct whatever is wrong with this, as it doesn't work. .Just returns 0xff for everything.

EDIT: Never mind. I can confirm this does actually work. The problem was indeed the pullup, for some reason the 3V3 rail on my Uno was at 4.5V ???? Weird. I used another Uno and it all started working.