Program 24LC01B EEPROM from Aduino

For the discussion of Arduino related topics.
Posts: 1
Joined: Thu Dec 09, 2010 8:41 pm

Program 24LC01B EEPROM from Aduino

Post by cgum »

I've been messing around with the Arduino, systematically plugging it into whatever I have around and trying to get it to work. My wife calls this "nerding-out time." I can't totally disagree with her. I digress...

I had some 1Kbit 24LC01B EEPROMs lying around and I couldn't figure out how to program them. I finally busted out my scope and got it to work. I still don't quite understand how it does work because I don't see how the read bit ever gets set, but I'm not going to look a gift horse in the mouth.

Here's the Arduino code in case I can save anyone else any time.

Code: Select all

#include <Wire.h>

    Wire Hookup for 24LC01B 1 K-bit (128 byte) EEPROM
    Don't forget to read the datasheet!
    1,2,3 are not internally connected.
    It's okay to leave them open.
            -|1   8|- Arduino +5V
            -|2   7|- Jumper to +5V for Write Protect
            -|3   6|- Arduino Pin Analog-5
Arduino Gnd -|4   5|- Arduino Pin Analog-4
    I put a 2.2K pull-up resistor between pin 5 and 8
    because the datasheet suggested it, but I'm not entirely
    sure it's necessary as I think the Wire library enables
    the Arduino's internal pull-ups.  Don't quote me on that,

    You're supposed to be able to write 8 bytes at
    a time, but I had trouble with that.  Try 4 at
    a time with a delay and then push it up until
    your results degrade.
    It seems like you can read as many as you like.
    We're going to write Hello World!
Data       |H|e|l|l|o| |W|o|r|l|d|!|
Address    |0|1|2|3|4|5|6|7|8|9|1|1|
           | | | | | | | | | | |0|1|

void setup()
  Wire.begin(); // join i2c bus (address optional for master)

void loop()
  Wire.beginTransmission(0x50); // This is the 24LC01B device address
  Wire.send(0x0);               // Start writing at address 0
  Wire.send("Hell");            // Send 4 bytes
  delay(10);                    // Without a short delay, the EEPROM is still
                                // writing when you start to write the next block
                                // Feel free to experiment with the delay length
  Wire.send(0x4);               // Write next four bytes starting at address 4
  Wire.send("o Wo");

  Wire.send(0x8);               // Write last four bytes starting at address 8


  Wire.beginTransmission(0x50); // Now we're going to read it back
  Wire.send(0x0);               // Sending address 0, so it knows where we'll want
  Wire.endTransmission();       // to read from

  Wire.requestFrom(0x50,12);    // Start new transmission and keep reading for 12 bytes
    char c = Wire.receive();    // Read a byte and write it out to the Serial port


User avatar
Posts: 31
Joined: Mon Jun 21, 2010 10:17 am
Location: MN, USA

Re: Program 24LC01B EEPROM from Aduino

Post by liudr »

Great! I have a couple 24LC256 and they work the same. With the arduino wire library, I can't tel when the write cycle completes since I can't find how to receive acknowledge bit from slave through arduino wire lib. Do you know how? Without it, I'll have to put a long wait if I want to be safe.

Return to “Arduino”