A sketch for the Arduino Mega that allows it to read and write to some older generation SRAM chips
A sketch for the Arduino Mega that allows it to read and write to some older generation SRAM chips
The SRAM Read/Write Sketch sets up a set of control lines (WE/Write Enable, OE/Output Enable, and CE/Chip Enable) followed by
an address bus and a data bus and sends the proper signals to interface the Arduino Mega to an older generation
28-pin SRAM chip. The chip in this case is the UM61256AK-15 and the datasheet can be found here:
UM6126AK-15 Datasheet
Other 28-pin DIP SRAM chips should be compatible as well such as the N341256P-20:
N341256P-20 Datasheet
There are three parts to the actual program itself, the initializing code that sets up the necessary control lines and busses,
the functions necessary for reading and writing, and the memory testing algorithm which doesn’t actually thoroughly test the
chip itself but simply writes a byte and attempts to read it back, as a way of testing if the read/write functions work.
Their method of operation is described below:
digitalWrite()
functions needed toOE_LOW
, CE_LOW
, WE_LOW
, and WE_HIGH
Due to the fact that the data bus will have to flip between Input and Output there isn’t much to set up for it and its status
will be set up and changed through the Read Write functions
There are two main functions, write_data()
and read_data()
. write_data()
relies on another function known as set_addr
which sets the proper address and data_op()
which, given the proper arguments, will send data through the data bus.read_data
also relies on the same functions but with different arguments.
set_addr()
Argument:
uint16_t address
- 16 bit unsigned integer that holds address to be outputteddata_op()
Arguments:
char rw
- Takes the character ‘r’ for “read” or ‘w’ for “write” uint8_t data
- 8 bit unsigned integer that holds data to be writtenchar rw
argument is set to ‘w’ a write operation is performeduint8_t data
are set to the L Port register, effectively setting them on the data busIf the char rw
argument is set to ‘r’ a read operation is performed
write_data()
Arguments:
uint16_t address
- 16 bit unsigned integer that takes in the address of the memory location to be writtenuint8_t data
- 8 bit unsigned integer that holds the data to be writtenset_addr()
function with the uint16_t address
argument of this function inputted asdata_op()
function is called with the arguments ‘w’ to signal a write operation and the data from this functionsThe timing diagram better illustrates the reasons for setting all these signals high or low and can be seen below
read_data()
Arguments:
uint16_t address
- 16 bit unsigned integer that takes in the address of the memory location to be readset_addr()
function is called with its argument the address being the argument of this functionreturn()
in conjunction with the data_op()
function and the arguments ‘r’ indicatingThe timing diagram better illustrates the reasons for setting all these signals high or low and can be seen below
As mentioned before, this is by no means a thorough testing algorithm and is just something to show how all the functions
presented would work in a real program
uint16_t address
is declared and unitializeduint8_t random_data
is declared and unitializeduint16_t address
variable up to 0x7FF random_data
variable is set to some random number between 0x00 and 0xFF.write_data()
function is called with the arguments address
and random_data
read_data()
with address
as an argument and tests for equality with random_data
exit()
function These are a couple of improvements I’d like to make to the program itself or just some things that I’ve been running
through my head.