Main Site Documentation

Need some I2C help


#1

I’m still having problems using my I2C modules (http://www.tinyclr.com/forum/21/4898/)

[ulist]I spend hours on debugging and code analysis.
I spend 80 EUR on a logic analyser (http://www.ikalogic.com/scanalogic2/)
Used different power supplies
Used differnt modules
Used latest sourcecode for gadgeteer and modules[/ulist]

And my only result is that there is no data transfered over my I2C bus.

I wrote a very simple test application connected the logic analyser and no trigger fire.

Now I have no idea what else can I try.

Testapplication


using Gadgeteer.Modules.GHIElectronics;
using Gadgeteer.Modules.Seeed;
using Microsoft.SPOT;

namespace I2CLC
{
    public partial class Program
    {
        void ProgramStarted()
        {
            Debug.Print("Program Started");
            button.ButtonPressed += new Button.ButtonEventHandler(button_ButtonPressed);
        }

        void button_ButtonPressed(Button sender, Button.ButtonState state)
        {
            //Start Logic analyser here
            gyro.Calibrate();
            gyro.MeasurementComplete += new Gyro.MeasurementCompleteEventHandler(gyro_MeasurementComplete);
            gyro.StartContinuousMeasurements();
        }

        void gyro_MeasurementComplete(Gyro sender, Gyro.SensorData sensorData)
        {
            Debug.Print(sensorData.ToString());
        }
    }
}

Output:

attached picture shows connected modules and analyser Settings.

Analyser is working fine tested with UART


#2

I don’t have a Gadgeteer board so can’t really help there; but have you tried to program this like a standard EMX application?

I’d also suggest trying out the I2C scanner that Wim has on the code repository, http://code.tinyclr.com/project/356/i2c-scanner/ that might give you confirmation that the I2C device is connected and functioning correctly.

And I hope you also realise that the drivers for the Seeed modules are still stamped “beta”? You may be (un)lucky in that nobody else has tested the Gyro.


#3

Like Brett said, start new NETMF console application, no gadgeteer things. Then write your code as explained here http://wiki.tinyclr.com/index.php?title=I2C_-_EEPROM


#4

I know this wiki paged tried this before now with logic analyser:


        public static void Main()
        {
            I2CDevice.Configuration con =
               new I2CDevice.Configuration(0x68, 50);
            I2CDevice MyI2C = new I2CDevice(con);

          
            I2CDevice.I2CTransaction[] xActions =
               new I2CDevice.I2CTransaction[2];

            // create write buffer (we need one byte)
            byte[] writeBuffer8 = new byte[1];
            writeBuffer8[0] = (byte)0x1B;
            xActions[0] = I2CDevice.CreateWriteTransaction(writeBuffer8);
            // create read buffer to read the register
            byte[] readBuffer64 = new byte[8];
            xActions[1] = I2CDevice.CreateReadTransaction(readBuffer64);

          
            if (MyI2C.Execute(xActions, 1000) == 0) // at this point SDA and SCL went from high to low thats all
            {
                Debug.Print("Failed to perform I2C transaction"); // Result is always 0
            }
            else
            {
                Debug.Print("Register value: " + readBuffer64[0].ToString());
            }
        }

SDA and SCL went from high to low thats all.

No data over the bus :frowning:


#5

That is unusual. Disconnect your salve and try again.


#6

Uh… :whistle:


#7

is 0x68 the address? Since I saw the scanner pointed out a few days ago I would always suggest using that - in that way you get to know the real address (assuming everything works).

Have you had success with other modules on your gedgeteer board? Can you do the normal things, make LED blink etc?

I’ll have two more stabs in the dark here. First, can you check firmware and SDK versioning match? I know the gadgeteer stuff hsan’t been around long and therefore less likely to be an issue, but I really like to confirm this all is aligned. Second, can you check the gadgeteer socket you’re connecting to is right (again, I’d try to use something simple like LED blinkies to verify that we think the pins in question should work). Logic Analyser on them too just to verify.


#8

Even if address is wrong, you should see the address being sent. He said the wires go low which is not possible.


#9

I tested again only extender module and power connected.

Same result :frowning:

Attached you find the Output from the logic analyser

Test application:


 public static void Main()
        {
            I2CDevice.Configuration con =
               new I2CDevice.Configuration(0x68, 100);
            I2CDevice MyI2C = new I2CDevice(con);

          
            I2CDevice.I2CTransaction[] xActions =
               new I2CDevice.I2CTransaction[2];

            // create write buffer (we need one byte)
            byte[] writeBuffer8 = new byte[1];
            writeBuffer8[0] = (byte)0x1B;
            xActions[0] = I2CDevice.CreateWriteTransaction(writeBuffer8);
            // create read buffer to read the register
            byte[] readBuffer64 = new byte[8];
            xActions[1] = I2CDevice.CreateReadTransaction(readBuffer64);

          
            if (MyI2C.Execute(xActions, 1000) == 0) // at this point SDA and SCL went from high to low thats all
            {
                Debug.Print("Failed to perform I2C transaction"); // Result is always 0
            }
            else
            {
                Debug.Print("Register value: " + readBuffer64[0].ToString());
            }
        }

[ulist]
Latest firmeware.
No gadgeteer stuff.
Tried all “I” sockets
tried different I2C clock rates
[/ulist]


#10

OK, so go back and try toggling the pins yourself. As Gus says, that combination of bits does not seem a sensible thing that an I2C protocol would try to drive.


#11

Maybe I’m just too stupid for that. It was a nice experiment but is currently just too frustrating I will change back to normal computer. They’re easier to handle


#12

We will not accept defeat !!! :slight_smile:

seriously, let us know what help you want, and we can try to figure this out and do the things we need to do (give you code snippets etc) so we can figure out what is going on - its very strange !


#13

Yes please let us know and we will also help. This is why we are here :slight_smile:


#14

I have done my best but i have only one additinal Information vor you.

i stepped with with the Debugger through the test code (see above)

SDA and SCL is high after program start.
And went low on exact this line:


MyI2C.Execute(xActions, 1000)

No matter what I do it remains to low.

i tried a Loop and spam executes -> no effect.


#15

I find it impossible but let us try the exact same thing and get back to you.


#16

I work with computers and electronics for several years. The word “impossible” does not exist :smiley:

But Gus has looked exactly right, it is impossible it should at least see something and it looks like the only logical answer would be something is broken. And that’s also almost impossible since everything else seems to work

And that’s just frustrating


#17

By impossible, I mean I am not finding a logical explanation for it. It happened so there is a reason but I am just not understanding it. We will know once we try it tomorrow.


#18

have you tried other frequencies than 50 KHz?


#19

25,50,100,400 doesn’t matter :frowning:


#20

So I tried your code, with nothing but power, an extender, and an analyzer attached.

[quote]•Latest firmeware.
•No gadgeteer stuff.
•Tried all “I” sockets
•tried different I2C clock rates[/quote]

Attached is the result I got on the analyzer.

Have you tried manually setting the pins high and low? What socket/pin combination are you using?