EEPROM is a type of memory chip that stores data without a continuous power supply. It's useful for permanent data storage in small logger circuits, or holding custom pages in a mini web server. EEPROMs come in lots of sizes and protocols.

Continue reading for an updated, step by step guide to using the DS2431, 24AA-, and 25AA- EEPROMs with the Bus Pirate v2go. We've also got the full session logs as text files so you won't miss a single detail.

Step 1 3EEPROM hardware overview

The goal of this prototype is to learn about EEPROM and three common bus protocols. First, we look at the 3EEPROM PCB, then we demonstrate each EEPROM using a Bus Pirate universal serial interface tool. If you don't have a Bus Pirate, you can still follow along because the basic order of interface operations remains the same no matter how you implement them.

The DS2431 (IC1) draws power parasitically from the 1-Wire bus, it doesn't have an external power supply pin and doesn't require a decoupling capacitor. IC2 and IC3 are empty spots for additional 1-Wire devices, like another DS2431 or a DS1822 temperature sensor. C1 (0.01uF) is optional and only needed if IC2 or IC3 are populated with a powered 1-Wire device.

1-Wire requires a strong pull-up resistor, a maximum of 2.2K ohms. The Bus Pirate's on-board pull-up resistors are 10K, too weak to properly power the DS2431 during writes. The 3EEPROM explorer board includes a 1.8k ohm, 1/8th watt pull-up resistor (R1) on the 1-Wire bus so that no additional pull-up resistor is needed.

The 24AA-(IC4) and 25AA- (IC5) each get a 0.1uF capacitor to decouple them from the power supply (C2, C3). You probably don't need the capacitors in such a simple circuit, we omitted them from the prototype board in the demonstration. The I2C bus used by the 24AA- also requires pull-up resistors, but the Bus Pirate's on-board 10K ohm pull-up resistors are sufficient.

All the components will operate from 2.8volts to 5volts DC. The circuit is powered through the VCC and GND pins of jumper 3. There's two VCC pins, one is for power, the other is for the Bus Pirate's pull-up resistor voltage input pin (Vpullup).

Step 2 25AA- / 25LC- SPI EEPROM

Demonstrations

All EEPROM demos look pretty much the same. We'll write a few numbers to the chip, and then read them. Each device has conditions that apply once you want to write more than a few values, such as page size and boundary limitations. Read more about these in the datasheet for your specific device.

If you can't get a demonstration to work, download the complete terminal log so you don't miss a single thing we did. Pull-up resistors are the most common problem, check the pull-up pin voltage using menu 'v' in the Bus Pirate terminal.

IC5 is a 25AA- series I2C EEPROM from Microchip, these EEPROMs come in a ton of sizes. AA parts run from 1.8volts to 5.5volts, while the 25LC- parts have 2.5volt minimum requirement.

C3 (0.1uF) decouples the SPI EEPROM from the power supply. The write protect (WP) and hold pins could be controlled by a microcontroller, but we disabled them by holding these pins high. The SPI bus pins, CS, DO, CLK, and DI, are brought to header JP4.

Setup

If you're using a Bus Pirate, connect it to the 3EEPROM or 25AA- IC as shown in the chart image below. SPI doesn't normally require pull-up resistors.

Interfacing

In the Bus Pirate terminal press 'm' for the mode menu and select SPI. Configure the SPI library for normal pin output, use the defaults for all other SPI mode settings. Enable the power supplies (big 'W') at the SPI mode prompt. Finally, get a voltage report to make sure the power supplies are working ('v').

Now the EEPROM is writable. First, lower CS to activate the 25AA- ([). Next, send the write command (0x02) and the location to begin writing (0). Send the data to store (3 2 1), then raise CS (]) to save the values.

Note: we used a tiny 128byte EEPROM, bigger chips will use a 16bit (2 byte) address. This command would be [0b10 0 '''0''' 3 2 1] for EEPROMs bigger than 256bytes, note the second 0. Check the datasheet for your EEPROM to be sure.

Finally, read the data back to verify that the write was successful. Select the 25AA- ([), send the read command (0x03) and start address (0), and then read three values (r:3). Raise CS to complete the transaction (]). The values match, the write was successful.

Note: we used a tiny 128byte EEPROM, bigger chips will use a 16bit (2 byte) address. This command would be [0b11 0 '''0''' r:3] for EEPROMs bigger than 256bytes, note the second 0. Check the datasheet for your EEPROM to be sure.

IC4 is a 24AA- series I2C EEPROM from Microchip, these EEPROMs come in a ton of sizes. AA parts work from 1.8volts to 5.5volts, while the 24LC- parts have a 2.5volt minimum requirement.

A 0.1uF capacitor (C2) decouples IC4 from the power supply. The write protect pin (WP) could be controlled from a microcontroller, but for this simple demonstration we disable it with a connection to ground. The I2C bus pins, SDA and SCL, are brought out to header JP2.

The address of most 24AA EEPROMs is 1010AAAS, with the final four bits determined by the address pins (A0, A1, A2) and the read/write mode select bit (S). All the address bits are grounded in this example, so the write address of the EEPROM is 10100000 (datasheet page 6).

Setup

If you're using a Bus Pirate, connect it to the 3EEPROM or 24AA- IC as shown in the chart image below. I2C is a bidirectional bus that requires pull-up resistors on both pins. You can use the Bus Pirate's on-board pull-up resistors by connecting the Vpullup (Vpu) pin to the 3.3volt power supply and enabling them in the terminal.

Interfacing

Note: Not all I2C EEPROMs work the same. The tiny 24AA01, for example, has a completely different addressing and command system. Be sure to check the datasheet for your chip.

Press 'm' in the Bus Pirate terminal and select I2C from the mode menu. Enable the power supplies (big 'W') and the pull-up resistors ('p', option 2) at the I2C prompt. Get a voltage report ('v') to make sure the power supplies are on and the Vpullup pin is connected to a voltage.I2C>(0)<<<get list of macros0.Macro menu1.7bit address searchI2C>(1)<<<use address search macroSearching 7bit I2C address space.Found devices at:0xA0 0xA1 <<<found devices I2C>

We already know that the I2C address is 10100000, but we can also use the Bus Pirate's I2C search macro (1) to search for the 24AA-. The search macro found the device at the expected write (0xA0) and read (0xA1) addresses.

Begin the write with an I2C start condition ([), followed by the 24AA- write address (0xa0). Next, send the 16bit address to write at (0 0) and the data to write (3 2 1). End the I2C transaction with a stop condition (]).

It takes two operations to read from the 24AA-. One positions the read/write pointer, the other returns the values.

Begin with an I2C start condition ([) and the write address (0xa0). Send the 16bit address to read (0 0), and then the stop condition (]). We didn't send any data to write this time, we just positioned the read/write pointer back to the beginning of the data we wrote in step 1.

Step 2 set the read/write pointer to the beginning of the data we want to read. Now we can read the data using the 24AA- read address.

Begin with the I2C start condition ([) and 24AA- read address (0xa1). Read the three values we wrote in step 1 (r:3), and end with a stop condition (]). If the values match, then your write was successful.

The DS2431 draws power from the pull-up resistor and doesn't need an external supply or decoupling capacitor.

1-Wire needs a strong pull-up resistor, a maximum of 2.2Kohms. The Bus Pirate's on-board pull-up resistors are 10K, too weak to properly power the DS2431 during writes. You must use a 2.2Kohm or smaller external resistor between power and the 1-Wire bus pin. If you have difficulties writing data, make sure your pull-up resistor is large enough. The 3EEPROM explorer board includes a 1800 ohm pull-up resistor (R1) on the 1-Wire bus so no external resistor is needed.

Setup

If you're using a Bus Pirate, connect it to the 3EEPROM board or DS2431 as shown in the chart image below. The DS2431 doesn't require the power supply pin, it's used on the 3EEPROM board to power the large pull-up resistor for the 1-Wire bus.

Each 1-Wire device has a unique 8 byte ID. 1-Wire has a search procedure that detects the ID of all attached devices. The Bus Pirate implements the 1-Wire search as macro (240). Type '(240)' in the Bus Pirate terminal to start the 1-Wire search.

Each device address is printed, known devices are identified. The first ten 1-Wire device addresses are stored as macros, in this example our DS2431 address is available by typing '(1)' in the terminal.

Next we'll write 8 bytes to a temporary location in the DS2431 called the scratch pad.

Start the transaction with a 1-Wire bus reset and MATCH command (0x55). Both are available as macro '(0x55)'. This can also be done without a macro by typing '{ 0x55', { sends the 1-Wire reset, 0x55 is the 1-Wire MATCH command.

After the MATCH command, send the 8 byte ID of the device to address. We used the macro (1) which was populated with the DS2431 ID in step 1. You could also enter the 8 byte ID manually. At this point the DS2431 should have received it's address and be ready for commands.

0x0f is the write scratch pad command, it tells the DS2431 to expect data. The next two bytes tell it where to put the data, we'll save it at the beginning (0 0). Finally, we send 8 bytes of values to store, the numbers 8 to 1.

You must write a full 8 bytes to the DS2431. Additionally, the write address must be on an 8 byte boundary. See the datasheet for a complete overview of the write limitations.

Verify that the data was received correctly, and get a write authorization code.

Begin again with a 1-Wire reset and MATCH command macro (0x55), and the device address macro (1). This time send the DS2431 read scratch pad command (0xAA), and then read a total of 15 bytes.

The first 3 bytes read (r:3) are the write authorization code, we'll need it in the next step to copy the scratch pad to the EEPROM. The next 8 bytes (r:8) should match the data we sent in step 2. The final 2 bytes (r:2) are a CRC16 for the data. Reads after the CRC return all 1s.

We have everything we need to store the scratch pad data permanently in the EEPROM.

Address the device, then send the DS2431 copy scratch pad command (0x55) followed by the three byte authorization code we retrieved in step 3 (0x00 0x00 0x07). If the authorization code is correct, the data is moved to the EEPROM.

The DS2431 sets the upper most bit of the write authorization code after a successful copy scratch pad command. Send another read scratch pad command (0xAA) to get the updated authorization code, but just read the first three bytes (r:3). The previous value 0x07 has changed to 0x87, the copy command was received successfully.

Verify the write worked properly by retrieving the values. Address the DS2431, then send the read command (0xf0) and the address to read from(0x00 0x00).

It's possible to read the entire memory range with a single command. We read the eight bytes we wrote earlier (r:8), which returned the expected values. The eight bytes beyond these values haven't been written and return 0.

Step 5 Conclusion

Conclusion

This prototype teaches about EEPROM memory, and demonstrates how to use the Bus Pirate with three common protocols: 1-Wire, I2C, and SPI.

The 3EEPROM explorer board ensures the proper connections to each EEPROM, and provides an external pull-up resistor for the more demanding 1-Wire bus with parasitically powered components.

We can have 3EEPROM explorer board PCBs or kits produced at Seeed Studio. PCBs are about $10, kits are about $15, shipped worldwide. We need to organize a group purchase of 10 PCB or 20 kits to get started.