How to Use Parallel EEPROM for Storing Data
2019-06-13 | By Maker.io Staff
Parallel memory chips have been around for the better part of 40 years and are still used widely in electronic designs including computers, laptops, and SoCs. In this How-To, we will learn how to use parallel EEPROM memory for storing data.
BOM
- Arduino Mega 2560 - 1050-1018-ND
- AT28C64B - AT28C64B-15PU-ND
- Wire - 1471-1232-ND
- Breadboard - BKGS-400-ND
Scheme-It
Parallel versus Serial EEPROM
When it comes to storing information separately from a microcontroller or SoC, there are many different methods available to makers. For those who feel like going entirely retro, there are magnetic tapes in the form of cassette tapes. For those who want to look at more modern solutions, there are plenty of memory chips on the market with different protocols. However, no matter how information is stored, memory storage will always fall into one of two categories: serial or parallel.
Serial memory involves storing digital information one bit at a time and is streamed to and from a memory device, whereas parallel memory stores an entire word of memory in one go. For example, an 8-bit parallel memory chip will store/retrieve one byte of data in one read cycle, whereas an 8-bit serial memory chip will require 8 cycles to either store or retrieve a single byte.
Parallel memory has some advantages and disadvantages when compared to serial memory, and each memory category is the polar opposite to the other.
The AT28C64B
In this tutorial, we will use the AT28C64B, which is an 8KB memory chip that stores information even when the power is turned off. One of the advantages of the AT28C64B is that the IC package uses a common industry pin layout that makes it compatible with many other memory chips, which means that if a parallel memory chip replacement is needed, then the AT28C64B can be used.
Parallel EEPROM chips like the AT28C64B have different inputs/outputs that all perform different actions.
- Ax Pins – Address pins, used to select a specific memory location
- I/Ox Pins – Data pins, used to store/retrieve information from the chip
- WE Pin – The Write Enable Pin, used to write a byte to a memory location
- OE Pin – The Output Enable Pin, used to read a byte from a memory location
- CS Pin – The Chip Select Pin, used to select the memory chip for accessing
- NC – These are left unconnected (Not Connected)
Memory Locations
Memory chips store data in specific memory locations that can be written and read. Each memory location has a unique location, and this location has a number that can be selected by using the address pins. The table below shows how the address pins can be changed to select different memory locations:
Writing / Reading Data Prerequisites
Before data can be written or read, two things need to be done first - we must select the chip and set the address pins. While the address pins are active high, the chip select is active low; this means when the chip is not being used, the chip select needs to be set to VCC. When the chip select is pulled to ground, the chip becomes selected. Both the WE and OE pins are active low and therefore should always be held at VCC until data is to be accessed.
Reading Data from an EEPROM
Reading data from an EEPROM is very simple and only requires that the address pins are set to the desired address, the chip select is held low, and the OE pin is held low. When these conditions are met, the I/O pins output the byte stored at the address pointed to by the address pins.
Writing Data to an EEPROM
Writing data to an EEPROM is also simple and requires the following steps:
- Set the address to write to by setting the address pins
- Set the I/O pins to the data that is to be stored
- Set CS to GND
- Set WE to GND
- Wait a few seconds
- Set WE to VCC
Simple Arduino Mega Example
Parallel memory chips often have many address pins, so in our Arduino example, we will connect most of the address pins to ground and only use 2 address pins to give us 4 locations for storing information.
#define CS 2 #define OE 3 #define WE 4 #define IO PORTC #define AD0 12 #define AD1 13 void setup() { // put your setup code here, to run once: // Configure control pins pinMode(CS, OUTPUT); pinMode(WE, OUTPUT); pinMode(OE, OUTPUT); digitalWrite(OE, HIGH); digitalWrite(WE, HIGH); digitalWrite(CS, HIGH); // Configure data pins DDRC = 0x00; // Configure address pins pinMode(AD0, OUTPUT); pinMode(AD1, OUTPUT); } void loop() { // ************************************************** // Write data 0x5A to data location 1 // ************************************************** // Configure the control pins digitalWrite(OE, HIGH); digitalWrite(WE, HIGH); digitalWrite(CS, LOW); // Set our data on the IO port and configure IO as output DDRC = 0xFF; IO = 0x5A; // Set the address pins digitalWrite(AD0, HIGH); digitalWrite(AD1, LOW); // Perform the cycle digitalWrite(WE, LOW); delay(1); digitalWrite(WE, HIGH); digitalWrite(CS, HIGH); // ************************************************** // Read data from data location 1 // ************************************************** // Configure the control pins digitalWrite(OE, HIGH); digitalWrite(WE, HIGH); digitalWrite(CS, LOW); // Configure data as input DDRC = 0x00; // Set the address pins digitalWrite(AD0, HIGH); digitalWrite(AD1, LOW); // Perform the read cycle digitalWrite(OE, LOW); delay(1); unsigned char data = PORTC; digitalWrite(OE, HIGH); digitalWrite(CS, HIGH); }
Have questions or comments? Continue the conversation on TechForum, DigiKey's online community and technical resource.
Visit TechForum