I’ve never worked with I2C before, so this is probably something very basic and stupid, but I can’t figure out what I’m doing wrong.
I’m running this code on my FEZ Panda:
public static void Main()
{
//-- SENDER --
//create I2C object
I2CDevice.Configuration con = new I2CDevice.Configuration(0x38, 400);
I2CDevice MyI2C = new I2CDevice(con);
//create transactions
I2CDevice.I2CTransaction[] xActions = new I2CDevice.I2CTransaction[1];
// create write buffer (we need one byte)
byte[] RegisterNum = new byte[1] { 2 };
xActions[0] = I2CDevice.CreateWriteTransaction(RegisterNum);
while (true)
{
// Now we access the I2C bus and timeout in one second
// if no response
MyI2C.Execute(xActions, 1000);
Debug.Print("Sending: " + RegisterNum[0].ToString());
Thread.Sleep(1000);
}
}
I’m running this code on my FEZ Domino:
public static void Main()
{
//-- RECEIVER --
//create I2C object
I2CDevice.Configuration con = new I2CDevice.Configuration(0x38, 400);
I2CDevice MyI2C = new I2CDevice(con);
//create transactions
I2CDevice.I2CTransaction[] xActions = new I2CDevice.I2CTransaction[1];
// create read buffer to read the register
byte[] RegisterValue = new byte[1];
xActions[0] = I2CDevice.CreateReadTransaction(RegisterValue);
while (true)
{
// Now we access the I2C bus and timeout in one second
// if no response
MyI2C.Execute(xActions, 1000);
Debug.Print("Received: " + RegisterValue[0].ToString());
Thread.Sleep(1000);
}
}
Panda says it’s sending twos, Domino says it’s receiving zeroes.
Here are my wiring:
Panda Domino
A4 A4
A5 A5
GND GND
I also have a 1.2K pullup to 3.3V on A4 and A5.
Could someone point out my mistake? Thanks!