0% found this document useful (0 votes)
28 views

Microcontrooller and Microprocessor-Lecture 3

The document discusses memory organization and types in microcontrollers. It describes how memory is organized into cells that store bits organized into words addressed by memory addresses. It classifies memory into volatile and non-volatile types, with volatile memory like RAM used for temporary data and non-volatile memory like ROM used for storing programs. It describes common memory types including RAM, ROM, PROM, EPROM, EEPROM, and Flash EEPROM. It also discusses the Von Neumann and Harvard architectures for connecting the CPU to memory.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Microcontrooller and Microprocessor-Lecture 3

The document discusses memory organization and types in microcontrollers. It describes how memory is organized into cells that store bits organized into words addressed by memory addresses. It classifies memory into volatile and non-volatile types, with volatile memory like RAM used for temporary data and non-volatile memory like ROM used for storing programs. It describes common memory types including RAM, ROM, PROM, EPROM, EEPROM, and Flash EEPROM. It also discusses the Von Neumann and Harvard architectures for connecting the CPU to memory.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Mechanical Engineering Dept. Microprocessor and Microcontroller Dr.

Alaa Abdulhady Jaber

Lecture Three

3.1 Memory Organization


The memory subsystem stores instructions and data. Memory consists of a large
number of hardware components which can store one bit each. These bits are
organized in n-bit words, working as a register, usually referred to as cell or
location. The contents of cells is a basic unit of information called memory word.
In addition, each memory location is identified by a unique identifier, its memory
address, which is used by the CPU to either read or write over the memory word
stored at the location. In general, a memory unit consisting of m cells of n bits
each is referred to as an m×n memory; for n = 1 and n = 8 it is customary to
indicate a number followed by b or B, respectively. Thus, we speak of 1Mb (one
Mega Bits) and 1MB (one Mega Bytes) memories
Usually, addresses are sequentially numbered as illustrated in Figure 3.1.
However, in a specific MCU model some addresses may not be present. The
example in the figure shows a memory module of 64K cells, each storing an 8-
bit word (byte), forming a 64 kilo-byte (64KB) memory. In the illustration, for
example, the cell at address 0FFFEh contains the value 27 h. The CPU uses the
address bus to select only the cell with which it will interact. The interaction with
the contents is realized through the data bus. In a write operation, the CPU
modifies the information contained in the cell, while in a read operation it
retrieves this word without changing the contents. The CPU uses control bus
signals to determine the type of operation to be realized, as well the direction in
which the data bus will operate—remember that the data bus lines are
bidirectional.
Mechanical Engineering Dept. Microprocessor and Microcontroller Dr. Alaa Abdulhady Jaber

Figure 3.1: Memory structure

3.2 Memory Types


Memory is an important part of a microcontroller system. Depending on the type
used, we can classify memories into two groups: program memory and data
memory. Program memory stores the programs written by the programmer and
this memory is usually non-volatile, i.e. data are not lost after the removal of
power. Data memory is where the temporary data used in a program are stored
and this memory is usually volatile, i.e. data are lost after the removal of power.
Traditionally, memory technology has been divided into two categories:
 Volatile: This is memory that only works as long as it is powered. It loses its
stored value when power is removed, but can be used as memory for temporary
data storage. Generally, this type of memory uses simple semiconductor
technology and is easier to write to from an electrical point of view. For
historical reasons it has commonly been called RAM (Random Access
Memory). A slightly more descriptive name is simply ‘data memory’.
 Non-volatile: This is memory that retains its stored value even when power is
removed. On a desktop computer this function is achieved primarily via the
hard disk, a huge non-volatile store of data. In an embedded system it is
achieved using non-volatile semiconductor memory. It is a greater challenge
to make non-volatile memory, and sophisticated semiconductor technology is
Mechanical Engineering Dept. Microprocessor and Microcontroller Dr. Alaa Abdulhady Jaber

applied. Generally, this type of memory has been more difficult to write to
electrically, for example in terms of time or power taken, or complexity of the
writing process. Non-volatile memory is used for holding the computer
program and for historical reasons has commonly been called ROM (Read-
Only Memory). A more descriptive name is ‘program memory’.
However, based on the above mentioned memories there are six different types of
memories as follows:
3.2.1 Random Access Memory
Random access memory (RAM) is a general-purpose memory which usually
stores the user data in a program. RAM memory is volatile in the sense that it
cannot retain data in the absence of power, i.e. data are lost after the removal of
power. Most microcontrollers have some amount of internal RAM. Several
kilobytes are a common amount, although some microcontrollers have much
more, and some less. RAM chips can be designed in two different forms which
we call static RAM (SRAM) and dynamic RAM (DRAM), as seen in Figure 3.2.
Static memory (SRAM) is faster than dynamic memory (DRAM). Also, SRAM
consumes less power than DRAM. SRAM is more expensive, since it takes more
space on silicon.

Figure 3.2: The two types of RAM


Mechanical Engineering Dept. Microprocessor and Microcontroller Dr. Alaa Abdulhady Jaber

3.2.2 Read Only Memory


Read only memory (ROM) usually holds program or fixed user data. ROM is non-
volatile. If power is removed from ROM and then reapplied, the original data will
still be there. ROM memories are programmed at factory during the
manufacturing process and their contents cannot be changed by the user. ROM
memories are only useful if we have developed a program and wish to order
several thousand copies of it, or if we wish to store some configuration data.
3.2.3 Programmable Read Only Memory
Programmable read only memory (PROM) is a type of ROM that can be
programmed in the field, often by the end user, using a device called a PROM
programmer. Once a PROM has been programmed, its contents cannot be
changed. PROMs are usually used in low-production applications where only
several such memories are required.
3.2.4 Erasable Programmable Read Only Memory
Erasable programmable read only memory (EPROM) is similar to ROM, but the
EPROM can be programmed using a suitable programming device. EPROM
memories have a small, clear glass window on the top of the chip where the data
can be erased under strong ultraviolet light. Once the memory is programmed, the
window can be covered with dark tape to prevent accidental erasure of the data.
An EPROM memory must be erased before it can be reprogrammed. Many
development versions of microcontrollers are manufactured with EPROM
memories where the user program can be stored. These memories are erased and
reprogrammed until the user is satisfied with the program. Some versions of
EPROMs, known as one-time programmable (OTP), can be programmed using a
suitable programmer device but these memories cannot be erased. OTP memories
cost much less than the EPROMs. OTP is useful after a project has been developed
completely and it is required to make many copies of the program memory.
Mechanical Engineering Dept. Microprocessor and Microcontroller Dr. Alaa Abdulhady Jaber

Figure 3.3: Erasable Programmable Read Only Memory (EPROM)

3.2.5 Electrically Erasable Programmable Read Only Memory


Electrically erasable programmable read only memory (EEPROM) is a non-
volatile memory. These memories can be erased and also be reprogrammed using
suitable programming devices. EEPROMs are used to save configuration
information, maximum and minimum values, identification data, etc.
3.2.6 Flash EEPROM
This is another version of EEPROM-type memory. This memory has become
popular in microcontroller applications and is generally used to store the user
program. Flash EEPROM is non-volatile and is usually very fast. The data can be
erased and then reprogrammed using a suitable programming device. These
memories can also be programmed without removing them from their circuits.
Some microcontrollers have only 1 KB flash EEPROM while some others have
32 KB or more.

3.3 Microcontroller Architectures


To interact with memory, there must be two types of number moved around: the
address of the memory location required and the actual data that belongs in the
location. These are connected in two sets of interconnections, called the address
bus and the data bus.
A simple way of meeting the need just described is shown in Figure 3.4. It is
called the Von Neumann structure or architecture, after its inventor. The
Mechanical Engineering Dept. Microprocessor and Microcontroller Dr. Alaa Abdulhady Jaber

computer has just one address bus and one data bus, and the same address and
data buses serve both program and data memories. The input/output may also be
interconnected in this way and made to behave like memory as far as the CPU is
concerned. The Von Neumann structure is simple and logical, and gives a certain
type of flexibility. The addressable memory area can be divided up in any way
between program memory and data memory. However, it suffers from two
disadvantages. One is that it is a ‘one size fits all’ approach. It uses the same data
bus for all areas of memory, even if one area deals with large words and another
deals with small. It also has the problem of all things that are shared. If one person
is using it, another can’t. Therefore, if the CPU is accessing program memory,
then data memory must be idle and vice versa.

Figure 3.4: Memory accessing based on Von Neumann architecture

An alternative to the Von Neumann structure is seen in Figure 3.5. Every memory
area gets its own address bus and its own data bus. Because this structure was
invented in the university of the same name, this is called a Harvard structure. In
the Harvard approach we get greater flexibility in bus size, but pay for it with a
little more complexity. With program memory and data memory each having
their own address and data buses, each can be a different size, appropriate to their
needs, and data and program can be accessed simultaneously. On the minus side,
Mechanical Engineering Dept. Microprocessor and Microcontroller Dr. Alaa Abdulhady Jaber

the Harvard structure reinforces the distinction between program and data
memory, even when this distinction is not wanted. This disadvantage may be
experienced, for example, when data is stored in program memory as a table, but
is actually needed in the data domain.

Figure 3.5: Memory accessing based on Harvard architecture

3.4 Complex Instruction Set Computer and the Reduced Instruction


Set Computer
Any CPU has a set of instructions that it recognises and responds to; all programs
are built up in one way or another from this instruction set. We want computers
to execute code as fast as possible, but how to achieve this aim is not always an
obvious matter. One approach is to build sophisticated CPUs with vast instruction
sets, with an instruction ready for every foreseeable operation. This leads to the
CISC, the Complex Instruction Set Computer. A CISC has many instructions and
considerable sophistication. Yet the complexity of the design needed to achieve
this tends to lead to slow operation. One characteristic of the CISC approach is
that instructions have different levels of complexity. Simple ones can be
expressed in a short instruction code, say one byte of data, and execute quickly.
Complex ones may need several bytes of code to define them and take a long time
Mechanical Engineering Dept. Microprocessor and Microcontroller Dr. Alaa Abdulhady Jaber

to execute. Another approach is to keep the CPU very simple and have a limited
instruction set. This leads to the RISC approach – the Reduced Instruction Set
Computer. The instruction set, and hence overall design, is kept simple. This
leads to fast operation. One characteristic of the RISC approach is that each
instruction is contained within a single binary word. That word must hold all
information necessary, including the instruction code itself, as well as any address
or data information also needed. A further characteristic, an outcome of the
simplicity of the approach, is that every instruction normally takes the same
amount of time to execute.

3.5 8, 16, or 32 Bits?


People are usually confused for making a decision between 8, 16, or 32 bits of
microcontrollers. It is important to realize that the number of bits just refers to the
width of the data handled by the processor. This number actually limits the
precision of mathematical operations carried out by the CPU.
In general, 8-bit microcontrollers have been around since the first days of the
microcontroller development. They are cheap, easy to use (only small package
size), low speed, and can be used in most general-purpose control and data
manipulation operations. For example, it is still very efficient to design low- to
medium-speed control systems (e.g. temperature control, fluid-level control, or
robotics applications) using 8-bit microcontrollers. In such applications, low cost
is more important than high speed. Many commercial and industrial applications
fall into this category and can easily be designed using standard 8-bit
microcontrollers.
Microcontrollers of 16 and 32 bit on the other hand usually cost more, but they
offer much higher speeds, and much higher precision in mathematical operations.
These microcontrollers are usually housed in larger packages (e.g. 64 or 100 pins)
and offer much more features, such as larger data and program memories, more
timer/counter modules, more and faster A/D channels, more I/O ports, and so on.
Microcontrollers of 32 bit are usually used in high-speed, real-time digital signal
Mechanical Engineering Dept. Microprocessor and Microcontroller Dr. Alaa Abdulhady Jaber

processing applications, where also high precision is a requirement, such as


digital image processing, digital audio processing, and so on. Most consumer
products, such as electronic games and mobile phones, are based on 32-bit
processors as they demand high-speed real-time operation with colour graphical
displays and with touch-screen panels. Other high-speed applications such as
video capturing, image filtering, video editing, video streaming, speech
recognition, and speech processing all require very fast 32-bit processors with
lots of data and program memories, and very high precision while implementing
the digital signal processing algorithms.

You might also like