Main Site Documentation

I2C stopped working


#1

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];
       
        }



#2

@ Markdav

When you updated your SDK install, did you:

[ulist]Also update the Spider firmware on your boards?
Also remove and re-add the .NET MF, Gadgeteer, and GHI references in your project (or try starting from a new project)?[/ulist]


#3

Hi, Yes I did update the firmware. I also created a new module and app project and copied over the source code. A confidence check is that web client and web server now appear in the project (and I then removed them). I also deleted all the bin and obj directories and rebuilt.

A bit confused about version numbers. For example the project properties for GADGETEER.DLL shows version 2.41.0.0. If I follow the path in the properties window, the file version says 2.41.404. CopyLocal is set to false. This is ok? Also the mainboard is showing 4.1.1.0 while all the GHI modules appear to be 4.1.8.0.


#4

[quote]the mainboard is showing 4.1.1.0 while all the GHI modules appear to be 4.1.8.0.
[/quote]
What module did you notice that it is 4.1.8.0?
All GHI module’s drivers should be 4.1.10. the 4.1.8.0 is EMX firmware version.


#5

Sorry - you are right - 4.1.1.0. Looking at too many version numbers :wink:

Still an open question on the gadgeteer dll though given the steps I have teken, I am pretty sure the dll used is the latest version as there is no 2.41.0.0 file on my system.


#6

I figured this out. It was a typo in my code.
I2C adresses must be <0x7F (the 8th bit is used to signal read or write operation) so 0x90 is an invalid address.
Thanks, mark.