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.

osno

Member Since 06 Nov 2010
Offline Last Active Jan 05 2011 01:35 PM
-----

Topics I've Started

Help needed with I2C EEPROM

08 November 2010 - 10:26 PM

I've been trying for a few days to get an 24LC256 EEPROM working. I'm in a point where the bytesTransferred I receive from the I2CTransaction is correct for both Write and Read, but when I inspect the buffer for the read operation, it's all 255's (every byte is maxed out). I think it has something to do with the resistors I'm using. I tried 2k connected to 5V and 3.3V and 10k connected to 5V and 3.3V and I get the same in all combinations. If I remove the pull-up's completely, the read operation reports 2 bytes transferred (the address I'm writing, I'm assuming). If anybody can help, I'll be more than grateful.

This is how I'm wiring everything. The digital pins are connected to a 74HC238 to show me some output from what I'm saving. I only drew a few leds... there's more. That part seems to work, though. The graphic:
Attached File  EEPROM.png   54.37KB   150 downloads

And the code for the memory driver is:
        public byte[] ReadBytes(ushort address, int length)
        {
            byte[] data = new byte[length];

            using (I2CDevice eeprom = new I2CDevice(new I2CDevice.Configuration(0x50, 400))) //0x50 is 1010 000, 400 is 400khz
            {
                // Create a new Transaction 
                I2CDevice.I2CTransaction[] transaction = new I2CDevice.I2CTransaction[]{
                    I2CDevice.CreateWriteTransaction(new byte[] { (byte)((address >> 8) & 0x7F), (byte)(address & 0xFF) }),
                    I2CDevice.CreateReadTransaction(data)
                };
    
                int bytesTransfered = eeprom.Execute(transaction, 1500);

                if (bytesTransfered == length + 2)
                    return data;
                else
                    return null;
            }
        }

        public void WriteBytes(ushort address, byte[] data)
        {
            using (I2CDevice eeprom = new I2CDevice(new I2CDevice.Configuration(0x50, 400))) //0x50 is 1010 000, 400 is 400khz
            {
                // Create a new Transaction 
                I2CDevice.I2CTransaction[] transaction = new I2CDevice.I2CTransaction[]{
                    I2CDevice.CreateWriteTransaction(new byte[] { (byte)((address >> 8) & 0x7F), (byte)(address & 0xFF) }),
                    I2CDevice.CreateWriteTransaction(data)};

                // Execute the WriteBytes transaction, check if it was succesfull.
                int bytesTransfered = eeprom.Execute(transaction, 1500);
            }
        }
    }

The program does:

            byte[] sequence = new byte[]{ 2, 1, 2, 3, 2, 1, 0, 3, 1, 2, 0 };
            byte[] data = new byte[11];

            board.Memory.WriteBytes(100, sequence);
            data = board.Memory.ReadBytes(100, 11);

And then loops flashing the leds.

Thanks in advance to any kind soul who can take a look and give me some advice. I have tried 2 different EEPROM chips (same type) to the same result. Many resistor/voltage combinations. Even reversing the SDA and SCL (that didn't help :)). I don't know what to try at this point.

Thanks again,
J

(formatting tips are also appreciated... other people's posts look way better than mine!!)

Native code implementation

06 November 2010 - 10:08 PM

It would be amazing if we could do the following: Have a solution with a C native project that compiles ARM and a Netduino MF project. Deploy both to the device. In the netduino code, use p/invoke (the DLLImportAttribute) to call methods in the C native project. Is this even a possibility? I'd love to help implement that in Visual Studio if it's possible. Regards, J

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.