
See the latest version in the documentation wiki.
The 24AA02E48 is an I2C EEPROM with 256bytes of data storage. It’s similar to other EEPROMs we’ve looked at in the past, but this chip has a 48bit EUI-48 ethernet MAC address permanently burned into the upper-most six bytes. This is an easy and cheap way to buy a legit, totally unique MAC address for your ethernet projects.
Keep reading for a complete 24AA02E48 demo using the Bus Pirate universal serial interface. If you’re not using a Bus Pirate, that’s OK, you can still follow along and get a better understanding of how to implement this chip in your own application.
You can preorder assembled Bus Pirate hardware at Seeed Studio for $30, including worldwide shipping. This preorder will end October 15, 2009.
Chip: 24AA02E48 256byte EEPROM with EUI-48 ethernet MAC address
Bus: I2C, pull-up resistors required.
Power requirements: 3.3volts (1.7-5.5volts).
References: datasheet [PDF], also 24AA02 datasheet [PDF].
Complete Bus Pirate session log for this demonstration.
Setup

The schematic above shows the 24AA02E48 pinout and minimum circuit. This chip is slightly different than the larger EEPROMs that Microchip sells, the 24AA02 series EEPROMs (and -E48 variant) don’t have configurable I2C address pins or a write protect pin. The chip requires a 1.7-5volt power supply, we used 3.3volts.
| Bus Pirate | 24AA02E48 (pin) |
| MOSI/SDA | SDA (5) |
| CLOCK/SCL | SCL (6) |
| +3.3volts, Vpullup | +3.3volts (1) |
| GND | GND (4) |
Connect the Bus Pirate to the 24AA02E48 as shown in the table. We powered it from the Bus Pirate’s 3.3volt supply, and used the on-board pull-up resistors to hold the I2C bus high.
I2C>W<< power supplies on
POWER SUPPLIES ON
I2C>p<< configure pull-up resistors
1. Pull-ups off
2. Pull-ups on
(1) >2
Pull-up resistors ON
I2C>
In the Bus Pirate terminal select the mode menu (m) and choose I2C. Choose software I2C, any speed 400kHz or less is fine. Turn on the Bus Pirate power supplies (big W) and enable the pull-up resistors (p).
I2C>(1)<< address scan macro
Searching 7bit I2C address space.
Found devices at:
0xA0(0×50 W) 0xA1(0×50 R) 0xA2(0×51 W) 0xA3(0×51 R) 0xA4(0×52 W) 0xA5(0×52 R) 0x
A6(0×53 W) 0xA7(0×53 R) 0xA8(0×54 W) 0xA9(0×54 R) 0xAA(0×55 W) 0xAB(0×55 R) 0xAC
(0×56 W) 0xAD(0×56 R) 0xAE(0×57 W) 0xAF(0×57 R)
I2C>
If you use the I2C address scan macro (1), the 24AA02 will answer at a bunch of addresses. The base address is 1010xxxy, the lower three ‘x’ bits are ignored so any address in that range works. See the 24AA02 general datasheet [PDF] for more about the address.
If you’re not using a Bus Pirate, that’s okay, you can still follow along and get a better understanding of how to implement this chip in your own application.
Interfacing
Write and read this chip like any other I2C EEPROM.
I2C>[0xa0 0 3 2 1]
I2C START BIT
WRITE: 0xA0 ACK<<< write address
WRITE: 0×00 ACK<<< memory write location
WRITE: 0×03 ACK<<< values to write
WRITE: 0×02 ACK
WRITE: 0×01 ACK
I2C STOP BIT
I2C>
Send the I2C write address (0xa0), the address to save at (0) and up to eight values to write (3 2 1).
I2C>[0xa0 0][0xa1 r:3]
I2C START BIT
WRITE: 0xA0 ACK<<< write address
WRITE: 0×00 ACK<<< set memory pointer to 0
I2C STOP BIT
I2C START BIT
WRITE: 0xA1 ACK<<< read address
READ 0×03 BYTES:<<< get three bytes
0×03 ACK 0×02 ACK 0×01 NACK
I2C STOP BIT
I2C>
Verify the operation by positioning the memory pointer with a write command, then read back values from the read address. This is a standard I2C operation, see previous demonstrations for more examples.
Finally we get to the main event, reading your own unique MAC address.
I2C>[0xa0 0xfa][0xa1 r:6]
I2C START BIT
WRITE: 0xA0 ACK<<< write address
WRITE: 0xFA ACK<<< set pointer to 0xFA
I2C STOP BIT
I2C START BIT
WRITE: 0xA1 ACK<<< read address
READ 0×06 BYTES:<<< get six bytes
0×00 ACK 0×04 ACK 0xA3 ACK 0×24 ACK 0xC2 ACK 0×7E NACK
I2C STOP BIT
I2C>
The MAC address is stored in 6 bytes at the very top of the memory, locations 0xFA to 0xFF. First, set the EEPROM memory pointer to the address we want to read (0xfa). Next, read the six bytes that containing the MAC address.
The first three bytes of the MAC address are the organization identifier (0×00 0×04 0xA3 = Microchip). The last three bytes are the unique ID for this chip (0×24 0xC2 0×7E).
If you liked this chip demonstration, there’s a bunch more in the Bus Pirate manual. We love special requests, please post them in the comments (you might even get a free PCB).


No comments
Comments feed for this article