I2C Woes

Hello. This is my first question to the forum. I don’t have much experience with Domino and the NETMF, so I hope this question hasn’t been asked too many times before. :slight_smile:

I’m trying to use the I2C example from pages 82 & 83 of the Beginners Guide (dated August 11, 2010) as the basis for talking to an I2C relative humidity sensor. I haven’t gotten to the point where I have to sort out dealing with the sensor yet, so this is a kind of general I2C question.

The code is shown below …


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

namespace FEZ_Domino_Application1
{
    public class Program
    {
        public static void Main()
        {
            // Create I2C object
            I2CDevice.Configuration con = new I2CDevice.Configuration(0x40, 400);
            I2CDevice MyI2C = new I2CDevice(con);

            // Create transactions (we need 2 in this example)
            I2CDevice.I2CTransaction[] xActions = new I2CDevice.I2CTransaction[2];

            // Create write buffer (we need one byte)
            byte[] RegisterNum = new byte[1] { 2 };
            xActions[0] = MyI2C.

            Thread.Sleep(Timeout.Infinite);
        }

    }
}

Also, I should point out I’m using MS NETMF 4.1 SDK and GHI NETMF SDK 4.1 with Visual Studio/C# 2010 …

The problem is the line of code xActions[0] = MyI2C … When I type the “.” following MyI2C, CreateWriteTransaction (or for that matter, CreateReadTransaction) isn’t one of the choices.
I’ve looked at the netMF SDK documentation … I’ve included “using Microsoft.SPOT.Hardware;” … and I have added the Microsoft.SPOT.Hardware assembly in the references. I’ve also looked at some of the discussions of I2C in the forum. I’m starting to get really confused now … I’m probably overlooking something really obvious … any ideas?

Thanks,
Al

If you have you included microsoft.spot.hardware in your reference and the header. I found you have to “save all” and then they appear to work, sometimes i’ve closed the solution and re-opened it.

This might not be the answer but it happened to me. (also happens when I add resources )

Thanks Ian … I gave that a try, but it didn’t help in my case.

It works when you write:

xActions[0] = I2CDevice.CreateReadTransaction(RegisterNum);

instead of myI2C. But don’t ask me why. Maybe an error in the docu, or MS changes something in .NETMF 4.1.

Changed in 4 for some reason.

RobotFreak & bstag,

Thanks … that solved the problem!