2AA02E48 EEPROM with MAC address

From DP

Jump to: navigation , search

24aa02e48

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 order an assembled Bus Pirate at Seeed Studio for $30, including worldwide shipping.

Contents

Overview

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

Having fun with this chip demonstration?

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