Home Getting Started My Stamp Projects Electric Eng. Projects My Robots My PIC Projects PIC Mircontrollers Downloads Links Email

Interfacing the Basic Stamp II with Mircochip's 64K SPI bus serial EEPROM.


This project will show you how to interface a 64K SPI(Serial Peripheral Interface) Bus Serial EEPROM to the Stamp. The EEPROM i use is manufactured by Microchip and its part number is 25LC640. The EEPROM requires 3 wires to communicate with a device, and they are SCK(clock input), CS(chip select), and SO(serial data out) & SI(serial data in). Note that is 4 pins, and i prevouisly said it only takes 3 pins to interface this EEPROM to a device. That is te beauty of the shiftin/out command, you can do the work of two pins with one. Just connect SI and SO together and connect it to one I/O pin on the Stamp. The 25LC640 consist of 8192 registers each capable of storing 8 bits(1 byte) of data, so the total amount of data that can be stored is 8192*8 or 65,536 bits(64 Kbits).



Low power consumtion.
- Write current 3mA
- Read current 500uA
- Standby current 500nA
Block write protection
- Protect none
- 1/4 of the EEPROM
- 1/2 of the EEPROM
- all.
Built-in Write protection
- write enable latch
- write protect pin
32 byte page write

Pin Descriptions

Chip Select(/CS) - This pin is active low, so a low on this pin will select the EEPROM. A high on the pin deselects it, forcing it to go into stanby mode. If CS is brought high in the during the programming cycle the EEPROM will go in stanby mode after the cycle is complete. CS has to be brought low every time a programming cycle can occur.

Serial Input(SI) - The SI is used to transfer data, address, and intructions into the EEPROM.

Serial Output(SO) - The SO pin is used to transfer data on the registers of the EEPROM.

Serial Clock(SCK)- The SCK is used synchronize the communication between the EEPROM and the mirco.

Write Protect(/WP) - This pin is used for write protecting the EEPROM. If WP is high all functions of the EEPROM operation norally. When WP is brought low the EEPROM is in write protected mode.

Hold(/Hold) - The Hold pin is used to suspend the EEPROM in its current state. To active a hold, the Hold pin must be brought low. If hold is activated in the middle of a programming cycle, the cycle will be stop and will contiune where it left off when hold if brought high again. The Hold pin must be held high any time it is not being used.

Instruction Set

The purpose of the instruction set is to tell the EEPROM what the micro wants it to do. Each functions of the EEPROM has its own code, like 00000011, that you force the EEPROM to read the data stored in its memory. Below is a table of all the functions the 25LC640 has, and how to active them.

Instruction Name Instructions Format Description
READ %00000011 Read data from memory array beginning at selected address
WRITE %00000010 Write data to memory array beginning at selected address
WREN %00000110 Set the write enable latch
WRDI %00000100 Reset the write enable latch
RDSR %00000101 Read the status register
WRSR %00000001 Write to the status register

Status Register

The Status register is 8 bits long, each bit has its own function. The register can be wrote or read using the WRSR and RDSR instructions. The WIP bit is used to check to see if data is being written to the EEPROM. The WEL bit is used to check the status of the write enable latch. BP0 and BP1 are used for block protection. To set these two bits use the WRSR write to status register. The table below shows what BPO and BP1 must be set to, to protect different areas of the EEPROM. The last one is the WPEN bit, it is the write protect enable bit.

Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0

Memory Array Protection

BP1 BP0 Write Protected
0 0 none
0 1 upper 1/4 (1800h - 1FFFh)
1 0 upper 1/2 (1000h - 1FFFh)
1 1 all

Consult the datasheet for additional information on the 25LC640 EEPROM.


3.5 Kb BASIC Stamp II Code
16 KbSchematic for connecting the EEPROM to the Stamp
132 KbDatasheet for the 25LC640 64K EEPROM

Parts Needed

Component Manufacture Price Seller Part Number
Basic Stamp II Parallax Inc. $43 US Parallax Inc. BS2
64K SPI EEPROM Mircochip $2 US Digikey 25LC640


There are a variety of things you can use EEPROM's for, the most common is datalogging. I will be using an 25LC640 EEPROM in my final Altimeter project to store highest and lowest altitude, pressure, and to save the current altitude every minute or so. With 64K bits of storage thousands of entries could be made. Just remember each register on this EEPROM is only 8 bits long, so if you have a 12 bit ADC you will have to split the 12 bits into a 8 bit variable and a 4 bit variable and save them in two seperate locations on the EEPROM.

Home Stamp Projects EE Projects PIC projects Downloads Getting Started Links Robots

Last update: March 17/2001
Questions or comments email me at shaunwilson19@yahoo.com or

Put your comments or whatever on my message board