Need some I2C help

I’m using Socket 3
I2C is Gadgeteer Pin 8 and 9 this should by Cpu.Pin 12 and 11

I tried this code but dont know if this is correct:


            Microsoft.SPOT.Hardware.Cpu.Pin pinSDA = Cpu.Pin.GPIO_Pin12;
            Microsoft.SPOT.Hardware.Cpu.Pin pinSCL = Cpu.Pin.GPIO_Pin11;

            OutputPort SDA = new OutputPort(pinSDA,true);
            OutputPort SCL = new OutputPort(pinSCL, true);

            bool c1 = true;
            bool c2 = false;

            while (true)
            {
                SDA.Write(c1);
                SCL.Write(c2);
                c1 = !c1;
                c2 = !c2;
                Thread.Sleep(100);
            }

this works:


OutputPort SDA = new OutputPort(pinSDA,true);
OutputPort SCL = new OutputPort(pinSCL, true);

After OutputPort constructor the values are set to the “initalstate”

EDIT: Thats not true:

[quote]No affect on this lines:


SDA.Write(c1);
SCL.Write(c2);

[/quote]

Very strange effect:
Restart Program
Breakpoint @ SDA.Write(c1);
Current: SDA and SCL --> High (from initialize)
Pressed F10 (Step over)
SDA and SCL --> High (thats ok)
F10 --> SCL.Write(c2) --> Both went to LOW (WTF???)
Step Forward to Line:
SDA.Write(c1);
F10 (nothing happens c1 is false so thats ok)
F10 -->SCL.Write(c2) --> (nothing happens c2 is true WTF???)

Next Loop
SDA.Write(c1) --> c1 is true --> SDA and SCL High (???)
SCL.Write(c2) --> c2 is false --> SDA and SCL Low(???)

I’d also try setting the initial state to opposites, and try true / false for each of them and make sure that they chance as expected when they’re constructed.

Simpler code would be:

bool c1 = true;
while (true)
            {
                SDA.Write(c1);
                c1 = !c1;
                SCL.Write(c1);
              Thread.Sleep(100);
            }

but theoretically yours should also work fine. I’m just firing up a Panda to check what I get

posted an update above.
very interesting

here easier to read:


            Microsoft.SPOT.Hardware.Cpu.Pin pinSDA = Cpu.Pin.GPIO_Pin12;
            Microsoft.SPOT.Hardware.Cpu.Pin pinSCL = Cpu.Pin.GPIO_Pin11;

            OutputPort SDA = new OutputPort(pinSDA,true);
            OutputPort SCL = new OutputPort(pinSCL, true);

            

            SDA.Write(true);// SDA and SCL --> High (thats ok)
            Thread.Sleep(1000);
            SCL.Write(false);// --> SDA and SCL went to LOW (WTF???)
            Thread.Sleep(1000);
            SDA.Write(false);// --> nothing happens (ok)
            Thread.Sleep(1000);
            SCL.Write(true);// --> nothing happens (WTF???)
            Thread.Sleep(1000);
            SDA.Write(true);// --> SDA and SCL High (???)
            Thread.Sleep(1000);
            SCL.Write(false);// --> SDA and SCL Low(???)

edit:
And Yes i checked the probes of th logicaalyes multibe times! no short circuit. I also tried different channels on my logic analyser.

        public static void Main()
        {
            // Blink board LED

            bool ledState = false;

            OutputPort led = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.LED, ledState);
            OutputPort sda = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di7, !ledState);
            OutputPort scl = new OutputPort((Cpu.Pin)FEZ_Pin.Digital.Di6, ledState);

            while (true)
            {
                // Sleep for 500 milliseconds
                Thread.Sleep(500);

                // toggle LED state
                sda.Write(ledState);
                ledState = !ledState;
                scl.Write(ledState);
                led.Write(ledState);
            }
        }

thats my simple code; that toggles state as expected, I see 3v3 on my chosen pins when I expect, and ~0v when I expect.

OK reviewing your results seems to lead me to believe that SCL is not connected. I’d be checking the CPU pin and seeing if there’s not a solder issue, or at least measure (when the board is off) continuity between the cpu and the outbound pin. Can you refresh my memory on what board you have and where you have the logic probe connected (ie a breakout or connector of some form?)

Please disconnect power and measure the resistance between SDA and SCL

Good idea Gus

It’s <0.8 Ohms and i think that is not good…

Please contact us for replacement Contact Us – GHI Electronics

Sorry about troubles.

By the way you can fix this by touching the 2 i2c pins with soldering iron. Do this right on the EMX module. There is probably a little tiny hair short between the pads.

Yes, I’d check if you can see a solder bridge; if there is you can see it’d be pretty easy to touch with an iron to clear it. You might need a magnifying glass or lamp to see the bridge.

Thanks for this piece of advice. I have no soldering Equipment so i fixed this bug with a scalpel.

Two solder bridges removed and now it works.

20 hours per $ 120 does $ 2400 for working hours plus $ 100 for a logic analyzer. Who wants the bill :stuck_out_tongue:
ok at least I have learned something

Thanks for helping

It happens the other way everyday here. Someone comes with a question and after long hours of back and forth we find a big in their code, of worse, they have old firmware :slight_smile: who gets that bill :frowning:

I hope you will find development so enjoyable and fast that it compensates for what happened.

That’s development.

As compensation, I would like a monkey at the next order:) maybe if you release the next gadgeteer board ? :smiley:

You actually get more than a monkey. Just put a note in your next order