Hi,
I am trying to communicate between a FEZmini and DS75 I2C temperature sensor.
Here is part of the program. It is a thread that interrogates the DS75. I always get the following error :
Exception System.ArgumentException - 0xfd000000 (5)
Microsoft.SPOT.Hardware.I2CDevice::Execute [IP: 0000]
MicroFrameworkTest01.Program::Thread03 [IP: 0047]
A first chance exception of type ‘System.ArgumentException’ occurred in Microsoft.SPOT.Hardware.dll
We got exceptionSystem.ArgumentException
What could be the problem? The software seems OK.
public static void Thread03()
{
//create I2C object
I2CDevice.Configuration con = new I2CDevice.Configuration(0x9F, 400);
I2CDevice MyI2C = new I2CDevice(con);
//create transactions (we need 2 in this example)
I2CDevice.I2CTransaction[] xActions = new I2CDevice.I2CTransaction[3];
// create write buffer (we need one byte)
byte[] RegisterNum = new byte[1] {0};
xActions[0] = MyI2C.CreateWriteTransaction(RegisterNum);
// create read buffer to read the register
byte[] RegisterValue = new byte[2];
xActions[1] = MyI2C.CreateReadTransaction(RegisterValue);
while (true)
{
// Now we access the I2C bus and timeout in one second if no responce
try
{
MyI2C.Execute(xActions, 5000);
}
catch (Exception e)
{
Debug.Print(“We got exception” + e.ToString());
}
Debug.Print("Register value: " + RegisterValue[0].ToString() + RegisterValue[1].ToString() );
}