Eeprom shield + Gadgeteer

Following to this thread : http://www.tinyclr.com/forum/topic?id=8905&page=2#msg88792

Here’s a working prototype of the shield version of the Eeprom module. On the picture, it’s stacked on a Panda II. You can see the shield, the I2C Eeprom Gadgeteer module with a Seeed compass attached to it and 2 LCDs. All of these devices are i2c.

Here’s a small video : http://www.lsp-fr.com/FEZ/P1120913.MOV

Here’s the code used in the video :


public class Program
    {
        public static BafModule Baf;

        public static void Main()
        {
			// Onboard Eeprom address (set by dip-switch)
            Baf = new BafModule(0x50);
            
			// 4x20 i2c LCD
            Baf.AddDevice("LCD1", new I2CDevice.Configuration((UInt16)(0xC8 >> 1), 91));
            Baf.Write("LCD1", new byte[10] { 0, 12, 0, 19, 0, 4, 0, 3, 2, 2 });

			// 2x16 i2c LCD
            Baf.AddDevice("LCD2", new I2CDevice.Configuration((UInt16)(0xC6 >> 1), 91));
            Baf.Write("LCD2", new byte[10] { 0, 12, 0, 19, 0, 4, 0, 3, 2, 2 });
            
            //Baf.EEWrite(10, "Toto");
            var StrTmp = Baf.EEReadString(10, 4);
            Debug.Print("StrTmp = " + StrTmp);  // Writes string "Toto" to debug window

            Baf.AddDevice("COMPASS", new I2CDevice.Configuration((UInt16)(0x1E), 100));
            while (true)
            {
                // Do a single reading
                Baf.Write("COMPASS", new byte[] { (byte)Register.MR, (byte)Mode.SingleMode });
                // Read values
                Baf.Write("COMPASS", new byte[] { (byte)Register.DXRA });
                byte[] Res = Baf.Read("COMPASS", 6);
                // Only rawX for the example
                int rawX = (Res[0] << 8) | Res[1];
                rawX = (((rawX >> 15) == 1) ? -32767 : 0) + (rawX & 0x7FFF);
                
                Baf.Write("LCD2", new byte[4] { 0, 3, 1, 1 });
                Baf.Write("LCD2", System.Text.Encoding.UTF8.GetBytes((byte)0 + "X = " + rawX.ToString()+"    "));

                Baf.Write("LCD1", new byte[4] { 0, 3, 1, 1 });
                Baf.Write("LCD1", System.Text.Encoding.UTF8.GetBytes((byte)0 + "Compass : X = " + rawX.ToString() + "    "));

                Thread.Sleep(400);
            }
        }

Of course, this shield can also be used with Gadgeteer mainboards, but not in Gadgeteer mode, only in plain NetMF. In this case, Arduino headers can be ignored.
Also, this version is not compatible with Cerbuino because of different pin assignments for i2c on the “Arduino headers”. A separate PCB will be necessary, here.

The next revision will certainly look like the one in this post : http://www.tinyclr.com/forum/topic?id=8993&page=1#msg89804 , with more Gadgeteer headers.

1 Like

That is a nice module! I like the way to program it too! Great job!

Thank you ! :slight_smile:

Here’s the PCB of the next revision, which address some (known) errors in the first prototype and adds more Gadgeteer headers, as ianlee74 asked for.

I will ruin myself by buying Gadgeteer headers

Just made a test with a Cerb40 and the exact same code as above and it’s working perfectly. As expected, in fact, but I prefer to be sure

[em]Edit: I’ve just added the following code to show how it’s working with the second EEPROM (the one on the small board). Both EEPROMs are used in this example.[/em]


// Second EEPROM on small i2c module
Baf.AddDevice("EE", new I2CDevice.Configuration((UInt16)(0x51), 400));
Int32 Address = 1;
// Stores byte value 31 at address 1
//Baf.Write("EE", new Byte[] { (Byte)(Address >> 8), (Byte)(Address & 0xFF), (Byte)31 }, 5);
Baf.Write("EE", new Byte[] { (Byte)(Address >> 8), (Byte)(Address & 0xFF) }, 5);
var b = Baf.Read("EE", 1);
Debug.Print("Byte value @ 1 : " + b[0].ToString()); // Writes "31" to debug window

Also, as expected too (?), it doesn’t work as is with the Hydra :frowning:
ianlee74, could you tell me again what’s the problem with the hydra, please ? I just can’t find it in the two big threads about IO60P16

http://www.tinyclr.com/forum/topic?id=8515&page=7#msg86633

Check the end of that thread. We never got an explanation back from GHI but there is definitely an issue.

Thank you !

Reading a few posts from this thread, though, it seems I should not see any issue with my code since I don’t use interrupts and it’s plain NetMF.
Weird, indeed !

Maybe… Most of the problems we had were due to low level I2C issues. I suspect this is a similar problem.

Hmmm… I think I have to apolopgize, here

In a desperate impulse, I’ve updated my whole environment to the latest available on GHI support page and then updated the Hydra. That is : NETMF 4.2 QFE2 and firmware 4.2.3.0.
Guess what ? It’s now working !!!

Also, my problem with sending more than one Write transaction at once is also solved :open_mouth: (see thread http://www.tinyclr.com/forum/topic?id=9074 for details). I will post there to signify the fix.

[em]Edit: in fact, this specific problem (about more that one write transaction at once) is not solved :frowning: I’ve just tried on the Cerbuino and it’s still showing the same (bad) behaviour… I will still post on the dedicated thread about this.[/em]