Embedded Systems Programming Course

Memory Devices


Memory is memory is memory, right? Well, not exactly. There are many different flavors of memory available for embedded systems. Let's next examine the various types of memory and get an understanding of how they work.

Random Access Memory

This type of memory is the kind most of us probably think of when talking about how much memory is available. Random access memory (RAM) is the kind of memory used to hold programs and data when a processor is active. Specifying the correct row (RAS) and column (CAS) of the memory block you wish to access can access any block of data stored in the RAM chip. Generally programmers don't like to think about and calculate the rows and columns needed to access a bit of data, so most microprocessors have special support chips that convert a flat memory address into the correct row and columns needed to read data from RAM. That way as a programmer, you just specify an address as a number and the memory chips convert that into the proper row and column values to access the correct block of RAM.

RAM is packaged as a chip, or perhaps as a series of chips on a small board called a module. Sizes vary from 4K RAM chips, up to 128MB RAM modules, or even larger. All embedded systems need at least a small amount of RAM to operate correctly. There are actually several different types of RAM.

Dynamic RAM

This kind of RAM is the most commonly used kind of RAM due to its low cost. Basically Dynamic RAM consists of a capacitor and a transistor. The capacitor can either be charged (bit = 1) or discharged (bit = 0). The transistor is used to either read the current capacitor state, or changes the state to charged (1) or discharged (0).

Dynamic RAM has one serious drawback however. Whenever you store a bit of information in a Dynamic RAM location, that information is slowly lost. This is because a capacitor is not a perfect storage device. It tends to leak a bit over time and slowly loses its charge. This means that to keep the information current, before the information has been totally lost, the CPU must read and rewrite the information. This is known as a memory refresh. Typically this must be down every few milliseconds.

Most microprocessors on the market are built to work with Dynamic RAM and have special pins and an internal timer. The microprocessor uses those special pins to periodically stop whatever it is doing, so it can refresh the Dynamic RAM's memory. Older processors forced the programmer to create a memory refresh function, but newer processors do this for us automatically.

There is one other very important factor to understand about Dynamic RAM. That is the speed at which memory can be read, or written, to the RAM. This is called the access time. It determines just how much time must elapse between attempts to access data from the same RAM chip. Generally this is specified in nanoseconds, but some RAM may be slow enough to be specified in microseconds. When the processor is operating faster than the RAM access time, it is necessary to slow down the CPU by inserting wait states into the system. Basically this means the CPU may have to do nothing for a few nanoseconds or microseconds, until the RAM is ready to be accessed again.

There are many ways engineers have taken to reduce or eliminate these wait states, since they can have a dramatic effect on apparent processor speed. One of the most commonly used techniques is to use a bank of RAM chips. Then by arranging the chips in the proper rows and columns, as data is sequential accessed by the processor, it first read from one chip, then the next and so on. In this case, as one bit of memory is being accessed, the other RAM chips are preparing for the next access.

Access Time Example -

Assume that the CPU is operating with a clock of 20 MHz. This means that the processor itself can theoretically execute 1 step or instruction every 0.00000005 seconds, or 50 nanoseconds. In order to run at full speed with no wait states, the Dynamic RAM used must have an access time of 50 nanoseconds or less. By using two Dynamic RAM chips, arranged so first one chip, then the other is accessed, engineers can reduce cost by using slower 100 nanosecond memory.

It is still possible however that the program may need to access memory from the same chip in less than 100 nanoseconds. In this case, the processor is required to wait until the RAM chip is ready for access. Most modern processors have a WAIT pin which is used for just this purpose. Basically the RAM chip asserts the WAIT line whenever it is not ready. The WAIT line is then connected to the CPU, only when that RAM chip is being accessed. When the CPU detects that the WAIT line is active, it will pause until the WAIT line indicates it is now safe to again access the RAM.

Static RAM

With Static RAM, a flip-flop is used to create a memory cell. A flip-flop is a series of 4 transistors interconnected in such a way that circuit is either on (1) or off (0). Since this is an active circuit made up from transistors, the memory never needs to be refreshed. Unfortunately, the extra transistors needed to make Static RAM chips means it takes up more space, which in turns makes it more expensive. Therefore Static RAM is generally reserved for use only when absolutely necessary, such as for storing your computer's BIOS settings, or for acting as a local cache buffer between the CPU and the rest of Dynamic RAM.


Fast-page mode Dynamic RAM is the original type DRAM that was widely used. This kind of RAM that has to wait through the entire process of decoding an address and reading or writing the bit of data before it can move on to the next bit.


Extended Data-Out Dynamic RAM is a new type of DRAM that has become popular. The chief advantage of EDO DRAM is that it can begin decoding the next bit's address before it has completed reading the bit from the previous address. This makes it generally about 5-10% faster than normal FPM DRAM.


Synchronous Dynamic RAM is a special kind of EDO RAM. It operates in a burst mode, by assuming that most memory accesses are done sequentially. Therefore, it decodes the row address first, then steps through all the column addresses, reading bits, without recalculating the row address over and over again. This type of RAM is about 5-10% faster than EDO RAM. It is the most widely used type of RAM in modern computer systems.


Rambus Dynamic RAM departs from the traditional Dynamic RAM methods of accessing memory based on a row and column. Instead it uses a special high-speed bus to read and write to memory in parallel mode. This allows it to achieve even faster access times than SDRAM, but does cost extra. In addition, special Rambus interface chips are needed to act as a translator between the processor and the RAM. A few of the new processors on the market include Rambus support on the CPU chip itself. This kind of RAM is expected to dominate the personal computer industry over the next several years, due to its very high speeds (up to 1.6GB per second transfer rates). Currently it is generally only available on high cost servers where performance is more important than costs.

PCMCIA Memory Cards

This is a special kind of memory widely used on notebook and laptop computers. It is DRAM with extra support circuitry that allows it to plugged into a computer's PCMCIA slot to add RAM to the computer system.

Flash RAM

This is a term for a type of DRAM that has built-in memory refresh circuitry. It is used by many different computer systems, including embedded systems. This kind of RAM keeps its memory active by continuously applying a same voltage to the RAM chips, even when the power is off. This is the type of memory used to keep the time in a VCR, and stores your favorite stations on the radio in your car, and keeps your BIOS settings for you computer. If the power is ever completely lost, so is the memory held in Flash RAM. This is why VCRs tend to flash 12:00 after a power outage. This is also why your computer loses its hard drive and other BIOS settings, should the backup battery on the motherboard ever fail.


Video RAM is a special type of DRAM that allows two processors to access the same memory simultaneously. It is very useful for video cards, where the main system processor may be writing to video RAM, while at the same time the processor is reading the memory in order to update the video display. The main processor generally accesses memory randomly, while the video processor accesses the memory serially, or sequentially. Very often 3-D accelerated graphics cards use this kind of memory to achieve very high-speed operations. Basically the main processor never has to wait to access memory while the video processor is reading it.

Read-Only Memory

The next type of memory I want to discuss is known as Read-Only Memory (ROM). Basically ROM chips can be read from, but never written to. They are used to hold programs that never change on the computer. For example, a personal computer's BIOS code is almost always stored in one or more ROM chips on the motherboard. When the processor is reset, it jumps to a fixed memory location, where it begins to execute the instructions found there. Refer to the processor's programming card or other reference material to determine the memory address the CPU jumps to. Like RAM chips, ROM chips are available in a variety of sizes and bit widths.


A ROM chip is programmed when manufactured. In order to purchase ROM chips with your own code on them, you must contact a manufacturer and send them the exact information you wish them to encode onto the chip. The chips themselves are fairly cheap, but must be purchased in large quantities; since the setup needed to mass-produce the ROM chips is often times more expensive than the chip itself. These mass-produced ROM chips are usually called masked ROMs.


This is a special form of ROM that chip manufacturers use to create ROM chips. A PROM chip can have code installed exactly one time. Generally when getting a chip manufacturer to build custom ROM chips, they will use a generic PROM chip and download the information to it in a large production run. There are many PROM burners, or PROM programmers, available on the market for building ROM chips to be used for testing and design purposes. You can find several different models available at a reasonable cost from JDR Microdevices.


This special kind of ROM chip can be erased by exposing a small window on the chip to ultraviolet light, which clears the contents of the EPROM. It takes about 2 weeks of sitting in a brightly lit kitchen window to erase an EPROM. Special lights are available which can reduce the time it takes to erase the EPROM. Once the EPROM is erased, it can be reprogrammed again using a PROM burner. This was a great improvement over PROM chips, since a small mistake in the downloaded code stored on the chip does not mean you have to throw the chip away. Instead, you can erase it and try again.


This is also an erasable kind of ROM. It is sometimes called a Flash ROM chip. In this case, erasing the ROM is accomplished electronically instead of using ultraviolet light. Many newer computer systems use this kind of memory to hold the BIOS code. This way, it is possible to download a new set of BIOS instructions to the ROM chip by running a special program on the computer. Many of the PROM burners on the market today can handle a variety of PROM's, EPROM's, and EEPROM's.

Other Memory Devices

There are several other kinds of memory devices available for use with both general-purpose and embedded computer systems. They include floppy disks, hard drives, CD-ROM disks and many others. When using these types of devices however, an additional embedded controller generally handles the communication between the main processor and the hardware device. Of course, this is a kind of embedded programming, but is an area that we will only briefly discuss, since many embedded controllers already have this kind of support built-in, or included on the main board of the system.