I have an I2C device (breadboarded via the expansion module) that has been working fine.
I updated the SDK to the latest release (this may or may not be a factor). Both install over previous, then tried complete uninstall/reinstall.
I am getting this debug trace from two different spider mainboards. Only the power and the module are plugged in. I have tried 3 different ways of composing the transaction. This debug trace if from example 2 below.
Thoughts on any obvious things to check in either software or hardware?
Thanks, Mark.
DEBUG Trace:
Step into: Stepping over non-user code 'Gadgeteer.Interfaces.I2CBus.Write’
Step into: Stepping over non-user code 'Microsoft.SPOT.Hardware.I2CDevice.CreateWriteTransaction’
Step into: Stepping over non-user code 'Microsoft.SPOT.Hardware.I2CDevice.I2CWriteTransaction.I2CWriteTransaction’
Step into: Stepping over non-user code 'Microsoft.SPOT.Hardware.I2CDevice.I2CTransaction.I2CTransaction’
Step into: Stepping over non-user code 'Microsoft.SPOT.Hardware.I2CDevice.I2CTransaction.I2CTransaction’
Step into: Stepping over non-user code 'Microsoft.SPOT.Hardware.I2CDevice.I2CWriteTransaction.I2CWriteTransaction’
Step into: Stepping over non-user code 'Microsoft.SPOT.Hardware.I2CDevice.CreateWriteTransaction’
Step into: Stepping over non-user code 'Gadgeteer.Interfaces.I2CBus.Write’
Step into: Stepping over non-user code 'Gadgeteer.Interfaces.I2CBus.Execute’
Step into: Stepping over non-user code 'Gadgeteer.Interfaces.I2CBus.I2CLock.get’
Step into: Stepping over non-user code 'Gadgeteer.Interfaces.I2CBus.Execute’
Step into: Stepping over non-user code ‘Gadgeteer.Interfaces.I2CBus.Execute’
#### Exception System.ArgumentException - 0xfd000000 (1) ####
#### Message:
#### Microsoft.SPOT.Hardware.I2CDevice::Execute [IP: 0000] ####
#### Gadgeteer.Interfaces.I2CBus::Execute [IP: 001a] ####
#### Gadgeteer.Interfaces.I2CBus::Write [IP: 0012] ####
#### Gadgeteer.Modules.MarkDavies.FanController6664::GetRegisterByte [IP: 0032] ####
#### Gadgeteer.Modules.MarkDavies.FanController6664::Reset [IP: 0007] ####
#### GadgeteerApp4.Program::ProgramStarted [IP: 0011] ####
#### GadgeteerApp4.Program::Main [IP: 0015] ####
A first chance exception of type ‘System.ArgumentException’ occurred in Microsoft.SPOT.Hardware.dll
An unhandled exception of type ‘System.ArgumentException’ occurred in Microsoft.SPOT.Hardware.dll
public FanController6664(int socketNumber)
{
_socket = socketNumber;
Socket socket = Socket.GetSocket(socketNumber, true, this, null);
ushort ChipAddress = 0x90; //address pin grounded
this._I2CTempChip = new GTI.I2CBus(socket, ChipAddress, 50, this);
}
private byte GetRegisterByte(Registers RegId)
{
if ((byte)RegId > (byte)Registers.LastRegister)
throw new ArgumentOutOfRangeException("Register", "Register Address out of range");
byte[] RegisterNum = new byte[1];
byte[] RegisterReturnValue = new byte[1];
//pick up the actual register value
RegisterNum[0] = (byte)RegId;
// *** EXAMPLE 1 : This worked then started to fail
// _I2CTempChip.WriteRead(RegisterNum, RegisterReturnValue, 500);
// *** EXAMPLE 2: Replaced with a write then read - still fails
// _I2CTempChip.Write(RegisterNum, 500);
// _I2CTempChip.Read(RegisterReturnValue, 500);
//return RegisterValue[0];
// *** EXAMPLE 3: Replaced with a transaction. Fails too.
I2CDevice.I2CTransaction[] Txn = new I2CDevice.I2CTransaction[2];
Txn[0] = I2CDevice.CreateWriteTransaction(RegisterNum);
Txn[1] = I2CDevice.CreateReadTransaction(RegisterReturnValue);
int ret = _I2CTempChip.Execute(Txn, 500);
if (0 == ret)
{
throw new Exception("Failed to perform I2C transaction");
}
return RegisterReturnValue[0];
}