Categories

Chips: 24AA02E48 I2C EEPROM with MAC address

Posted on Tuesday, October 6th, 2009 in Chips by Ian

24aa02e48

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

24aa02e48

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(0x50 W) 0xA1(0x50 R) 0xA2(0x51 W) 0xA3(0x51 R) 0xA4(0x52 W) 0xA5(0x52 R) 0x
A6(0x53 W) 0xA7(0x53 R) 0xA8(0x54 W) 0xA9(0x54 R) 0xAA(0x55 W) 0xAB(0x55 R) 0xAC
(0x56 W) 0xAD(0x56 R) 0xAE(0x57 W) 0xAF(0x57 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: 0x00 ACK<<< memory write location
WRITE: 0x03 ACK<<< values to write
WRITE: 0x02 ACK
WRITE: 0x01 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: 0x00 ACK<<< set memory pointer to 0
I2C STOP BIT
I2C START BIT
WRITE: 0xA1 ACK<<< read address
READ 0x03 BYTES:<<< get three bytes
0x03 ACK 0x02 ACK 0x01 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 0x06 BYTES:<<< get six bytes
0x00 ACK 0x04 ACK 0xA3 ACK 0x24 ACK 0xC2 ACK 0x7E 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 (0x00 0x04 0xA3 = Microchip). The last three bytes are the unique ID for this chip (0x24 0xC2 0x7E).

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).

This entry was posted on Tuesday, October 6th, 2009 at 8:43 am and is filed under Chips. You can follow any responses to this entry through the RSS 2.0 feed. You can skip to the end and leave a response. Pinging is currently not allowed.

Leave a Reply

Notify me of followup comments via e-mail. You can also subscribe without commenting.

Recent Comments

  • Peter: Yet another Sunday!
  • Jack: Random comment from KM6MEE. Thanks!
  • KH: A lot of projects that we make will never be cheaper than commodity hardware. It's a choice that each of us will have to make...
  • Drone: @Cyk says: "Well, this is an application that I’d solve with an Android smartphone" BAD idea Cyk: Android Smartphone = Spy on Me Google!
  • Cyk: Well, this is an application that I'd solve with an Android smartphone. Used Moto G phones can be found on Ebay for ~€30, and thanks...