Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Problem getting I2C to start


  • Please log in to reply
1 reply to this topic

#1 Pablo020

Pablo020

    New Member

  • Members
  • Pip
  • 5 posts

Posted 06 December 2014 - 01:34 AM

Hello folks,

I have a ND+2, VS2103, Latest firmware etc..

 

I run the following code snippet:

using System;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;

namespace BasicMaster
{
    public class Program
    {
        private static I2CDevice.Configuration _i2cDeviceConfiguration = null;
        private static I2CDevice _i2cDevice;
        public static void Main()
        {
            Debug.Print("Main started");
            _i2cDeviceConfiguration = new I2CDevice.Configuration(0x00, 400);
            _i2cDevice = new I2CDevice(_i2cDeviceConfiguration);


            for (int i = 0; i < 100000; i++)
            {
                SendOnlyI2cMessage(i);
                Thread.Sleep(50);
            }
        }
        private static void SendOnlyI2cMessage(Int32 counter)
        {
            I2CDevice.I2CTransaction[] transactions = new I2CDevice.I2CTransaction[1];

            byte[] RegisterNum = new byte[1] { 2 };
            transactions[0] = I2CDevice.CreateWriteTransaction(RegisterNum);
            Int32 executeResult = _i2cDevice.Execute(transactions, 1000);
            if (executeResult == 0)
            {
                Debug.Print("I2C transaction, Counter = " + counter.ToString() + ", ExecuteResult = Failed (value = 0)");
            }
            else
            {
                Debug.Print("I2C transaction, Counter = " + counter.ToString() + ", ExecuteResult = " + executeResult.ToString());
            }
        }
    }
}

I connected the SD and SC pins via 10K resistors to the +3.3V.

A scope is connected to both the clock and the data (SC and SD pins).

 

 

Scenario 1:

- build app

- deploy and debug app

- app starts and code is running, as I see the debug print stuff coming in.

 

Result: 

I see both channels on the scope indicating a flat 3.3V... but no signs of any signal generated by the netduino. (See first attachment)

Strange ... I expected the execute to fail, however, I ought to see some 'proof' of attempts on the signals.

 

Then ... 

- I disconnect 3.3V pin, and reconnect ....

Result:

I see the expected signal. See second attachment.

 

 

The same effect I get in the following scenario:

 

Scenario 2:

- above code is running. I did the 3.3V disconnect - reconnect routine. And i can see the signal.

- I press the reset button of the ND+2

- After restart, again I see the image 1... a flat 3.3V

- Disconnect 3.3V and Reconnect 3.3V 

- Result: image 2, a clear signal!

 

 

Am I doing something wrong?

Can I fix this from the software?

 

Any feedback would be appreciated!!

 

Paul

Attached Files



#2 dino4net

dino4net

    Advanced Member

  • Members
  • PipPipPip
  • 40 posts

Posted 08 December 2014 - 04:02 PM

There was a workaround some time ago I still use in my I2C projects.

Put it at the beginning of the project to give the port the right level. Also advice to get a Scanna Plus device from ikalogic.com to debug this type of problems in minutes.

            //Workaround for a bug where you need to disconnect the I2C bevore it works.
            OutputPort p = new OutputPort(Pins.GPIO_PIN_SDA, true);
            p.Write(false);
            p.Dispose();





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.