Reputation: 21
I am trying to use a RPi2B with Windows IoT to communicate with a GE power supply via I2C. I can do simple reads and writes OK, but anything involving a repeated start is unreliable. Since the power supply's PMBus command set is dominated by WriteRead I2C transactions (which require repeated starts), most of my attempts to read from specific registers fail... but occasionally it works as expected. Here is the relevant code...
public void Read_Firmware_Rev()
{
Windows.Devices.I2c.I2cTransferResult Temp;
byte[] ReadBuffer = new byte[8];
var CommandBuffer = new byte[1] { Firmware_Rev };
Temp = _I2C.WriteReadPartial(CommandBuffer, ReadBuffer);
if (Temp.Status == I2cTransferStatus.FullTransfer)
{
String S = System.Text.Encoding.ASCII.GetString(ReadBuffer);
Debug.WriteLine(S);
}
else Debug.Write("-");
}
The top image is the most common result; the bottom is rare success. A successful transactions has a clock stretch (by whom?) after the first byte as well as a repeated start after the command byte 0xD5.
The power supply's documentation says that it accepts repeated starts and can stretch the clock. It's not a speed problem.... I am querying the power supply only 1/sec at 100kHz. Can anyone suggest why this behavior are occurring?
Upvotes: 1
Views: 176
Reputation: 21
The Raspberry Pi 2b is unable to execute an I2C repeated Start and consequently cannot do a WriteRead sequence. A hardware solution is the NXP SC18IS604 chip which translates SPI to I2C. RPi talks to the SC18IS604 via SPI and SC18IS604 then talks to the external device with I2C. It works well for me. https://www.nxp.com/docs/en/data-sheet/SC18IS604.pdf
Upvotes: 0