Microcomputer Lecture Note
Microcomputer Lecture Note
Music set
Lecture 1: Elements of Digital Computer Design
Calculators
Laptops, i-pads, PDAs,
Smartphones
• Robots
Lecture 1: Elements of Digital Computer Design
BASIC BUILDING BLOCKS OF A DIGITAL COMPUTER
The digital computer is basically made up of logic gate devices and flip-flops
and their derivatives.
A divide by 60 logic
Lecture 1: Elements of Digital Computer Design
Microchip
PIC12F617 architecture
Lecture 2: Microcomputer systems
• The CPU
The CPU contains a variety of
registers that are necessary to
execute instructions and hold
status information about the
system
Lecture 2: Microcomputer systems
• Instruction Register (IR)
The instruction register holds the
current binary code of the
instruction being executed. This
code is read from program
memory as the first part of
instruction execution. The IR is
used by the control unit to decide
which states in its FSM to traverse
in order to execute the instruction.
Lecture 2: Microcomputer systems
• Program Counter
The program counter holds the
address of the current instruction
being executed in program memory.
The program counter will increment
sequentially through the program
memory reading instructions until a
dedicated instruction is used to set it
to a new location.
If an instruction is one byte
instruction, then the program
counter will be updated by one (i.e.
PC = PC + 1). Similarly, for two and
three byte instructions, the program
counter will be updated by two (i.e.
PC = PC + 2) or three (i.e. PC = PC +
3) locations respectively.
Lecture 2: Microcomputer systems
• Memory Address Register (MAR)
The memory address register is used to
hold the current address being used to
access memory. The MAR can be loaded
with addresses in order to fetch
instructions from program memory or
with addresses to access data memory
and/or I/O ports.
Lecture 2: Microcomputer systems
• Arithmetic Logic Unit (ALU)
The arithmetic logic unit is the
system that performs all
mathematical (i.e., addition,
subtraction, multiplication, and
division) and logic operations (i.e.,
and, or, not, shifts, etc.). This
system operates on data being held
in CPU registers. The ALU has a
unique symbol associated with it to
distinguish it from other functional
units in the CPU.
Lecture 2: Microcomputer systems
• A deeper look at the ALU
Lecture 2: Microcomputer systems
• Accumulator
The accumulator is an 8 bit buffer register
extensively used in arithmetic, logic, load,
store and input and output operations. All
the arithmetic and logical operations are
performed on the accumulator contents;
i.e. one of the operand is always taken
into the accumulator.
• Control Logic
The control logic acts on the decoded
instructions to generate action signals
for a specified operation.
Lecture 2: Microcomputer systems
• Program Status Word (PSW)
This is a special function register used to hold the various
operational status of the microcomputer.
Lecture 2: Microcomputer systems
Memory Organization
• Data memory (RAM)
The RAM is organized into three
basic sections as shown.
Lecture 2: Microcomputer systems
Handling just one memory block is simpler and easier Low performance compared to Harvard architecture
to achieve
It is cheaper than Harvard architecture Data bus speed - the CPU is much faster than the data
bus, meaning it often sits idle (Von Neumann
bottleneck)
Memory organization is in the hands of the Serial instruction processing does not allow parallel
programmer execution of program.
Data from memory and from devices are accessed in Fetch rate - data and instructions share the same data
the same way. bus, even though the rate at which each needs to be
fetched is often very different.
Lecture 3: Microcomputer Systems Architecture
Harvard Architecture
The Harvard architecture offers separate
storage and buses for instructions and
data. This architecture has data storage
entirely contained within the CPU, and
there is no access to the instruction
storage as data. The Harvard computer
model have separate memory areas for
program instructions and data using
internal data buses, allowing
simultaneous access to both instructions
and data.
Lecture 3: Microcomputer Systems Architecture
Comparative View
Lecture 3: Microcomputer Systems Architecture
Advantages and disadvantages of Harvard Architecture
Advantages Disadvantages
The CPU can both read and instruction and The separate buses for instruction and data
perform a data memory access at the same time, fetching lead to more design complexities.
even without cache.
Control Lines
Address Lines
Data Lines
• Fundamental tool for designing and building computer based systems
• divide the problem into independent components operating against a well defined interface
• compose the components efficiently
• Shared collection of wires
• command, address, data
• Communication path between multiple subsystems
• Inexpensive
• Limited bandwidth
• Layers of a bus specification
• mechanical, electrical, signaling, timing, transactions
Lecture 3: Microcomputer Systems Architecture
Processor
SouthBridge
Bus
Adaptor I/O Bus
• Separate sets of pins for different functions
Bus I/O Bus
• Memory bus
Adaptor
• Graphics bus (for fast frame buffer)
• I/O buses are connected to the backplane bus
• Advantage:
• Buses can run at different speeds
• Much less overall loading!
Lecture 3: Microcomputer Systems Architecture
Bunch of Wires
Electrical Specification
Asynchronous handshaking
process to transfer the data
from the microprocessor to I/O
device.
Asynchronous handshaking
process to transfer the data
from the I/O device to
microprocessor
Lecture 3: Microcomputer Systems Architecture
Bus Transaction
Class work
1. A given memory chip has 12 address pins and 4 data pins. Find: (a)
The organization, and (b) the capacity.
2. A 512K memory chip has 8 pins for data. Find: (a) The organization,
and (b) the number of address pins for this memory chip.
Lecture 4: Memory systems
Basic Memory Operation
A memory cell is an a
semiconductor device that
can hold a “0” or a “1” as a
bit. This bit can be stored
or retrieved from the cell
by applying a “Write” or
“Read” control signal while
activating it with a “Select”
signal.
Lecture 4: Memory systems
The Read/Write action can be
applied to a group of cells at a
time.
Lecture 4: Memory systems
Types of Semiconductor Memory
Lecture 4: Memory systems
Lecture 4: Memory systems
• RAM - Random Access Memory: As the names suggest,
the RAM is a form of semiconductor memory technology
that is used for reading and writing data in any order as it
is required.
• It is used for such applications as the computer or
processor memory where variables and other stored and
are required on a random basis. Data is stored and read
many times to and from this type of memory.
• Random access memory is used in huge quantities in
computer applications as current day computing and
processing technology requires large amounts of
memory to enable them to handle the memory hungry
applications used today.
Lecture 4: Memory systems
• Types of RAM
• SRAM
- Asynchronous RAM
- Synchronous Burst RAM
• DRAM
-Fast Page Mode DRAM
- Extended Data Out DRAM
- Burst EDO DRAM
- Synchronous DRAM
Lecture 4: Memory systems
Static Random Access Memory (SRAM)
• Static Random Access Memory. This form of semiconductor memory
gains its name from the fact that data stored does not need to be
refreshed dynamically.
• These semiconductor devices are able to support faster read and write
times typically 10ns, and in addition its cycle time is much shorter
because it does not need to pause between accesses.
• However SRAM chips consume more power, they are less dense and
more expensive than DRAM. As a result of this SRAM is normally used
for caches, while DRAM is used as the main semiconductor memory
technology.
Lecture 4: Memory systems
SRAM basics
• There are two key features to SRAM:
1. The data is held statically: This means that the data is held in the
semiconductor memory without the need to be refreshed as long as the
power is applied to the memory.
2. SRAM memory is a random access memory: A random access memory is
one in which the locations in the semiconductor memory can be written
to or read from in any order, regardless of the last memory location that
was accessed.
The circuit for an individual SRAM memory cell comprises typically four
transistors configured as two cross coupled inverters. In this format the
circuit has two stable states, and these equate to the logical "0" and "1"
states.
The transistors are MOSFETs because the amount of power consumed by
MOS circuit is considerably less than that
Lecture 4: Memory systems
72
Lecture 4: Memory systems
ROM - Read Only Memory:
• A ROM is a form of semiconductor memory technology
used where the data is written once and then not
changed. In view of this it is used where data needs to
be stored permanently, even when the power is
removed
• As a result, this type of semiconductor memory
technology is widely used for storing programs and data
that must survive when a computer or processor is
powered down. For example the BIOS of a computer will
be stored in a ROM.
• As the name implies, data cannot be easily written to
ROM. Depending on the technology used in the ROM,
writing the data into the ROM initially may require
special hardware. Although it is often possible to change
the data, this gain requires special hardware to erase
the data ready for new data to be written in.
Lecture 4: Memory systems
Types of ROM
Lecture 4: Memory systems
Mask ROM
Mask ROM is a type of read-only memory, or ROM, that is
masked off during production. "Mask" refers to parts of an
integrated circuit, a thin electronic circuit for processing
data, that is covered with opaque plates called photomasks.
These plates contain transparencies, or holes, to allow light
in certain areas while blocking light in others to create
distinctive patterns.
Mask work, comprising a process known as
photolithography, primarily serves as a sort of intellectual
property protection, reserving reproduction of the product
to the integrated circuit manufacturer.
Data stored in a Mask ROM cannot be altered by the user. If
it can, the process would be difficult or slow. Thus, Mask
ROM is primarily distributed as firmwire—software, or
coded instructions—permanently stored in ROM.
Lecture 4: Memory systems
Programmable Read Only Memory (PROM)
• Programmable Read Only Memory is a form of
semiconductor memory which can only have data
written to it once - the data written to it is permanent.
These memories are bought in a blank format and
they are programmed using a special PROM
programmer.
• Typically a PROM will consist of an array of fuseable
links some of which are "blown" during the
programming process to provide the required data
pattern.
Lecture 4: Memory systems
Erasable Programmable ROM (EPROM or UVPROM)
• Erasable Programmable Read Only Memory devices
can be programmed and then erased at a later time.
This is normally achieved by exposing the
semiconductor device itself to ultraviolet light.
• When the UVPROM is in use, this window is normally
covered by a label, especially when the data may
need to be preserved for an extended period. These
devices are not widely used at present as more
convenient forms of semiconductor memory are now
available.
Lecture 4: Memory systems
Electrically Erasable Programmable Read Only Memory,
EEPROM
• Electrically Erasable Programmable Read Only Memory is a
form of semiconductor memory where data can be written
to the memory device and it can be erased using an
electrical voltage. This erase voltage is typically applied to a
special erase pin on the chip.
• Like other types of PROM, EEPROM retains the contents of
the memory even when the power is turned off. Also like
other types of ROM, EEPROM is not as fast as RAM.
Lecture 4: Memory systems
Flash memory
• Flash memory is a particularly widespread form of
semiconductor memory. It is used in memory cards, and
increasingly for computer solid state hard drives and similar
applications.
• Flash memory may be considered as a development of
EEPROM technology. Data can be written to it and it can be
erased, although only in blocks, but data can be read on an
individual cell basis.
• To erase and re-programme areas of the chip, programming
voltages at levels that are available within electronic
equipment are used. It is also non-volatile, and this makes it
particularly useful. As a result Flash memory is widely used in
many applications including USB memory sticks, compact
Flash memory cards, SD memory cards and also now solid
state hard drives for computers and many other applications.
Lecture 4: Memory systems
Interfacing a RAM to a
microcontroller
• For more data space.
• Better operational speed.
• To process information faster
Lecture 4: Memory systems
Interfacing an external
ROM/EPROM to a
microcontroller
• To increase program space.
• To store more information
permanently
Lecture 4: Memory systems
Code interface
Addressing
instruction
Lecture 4: Memory systems
Lecture 5:
Machine, assembly and high-level
programming languages
Lecture 5: Machine, assembly and high-level
programming languages
Computer Program
Table 6.1 shows the 8051 Instruction Set Groups and Instructions in
each group. There are 49 Instruction Mnemonics in the 8051
Microcontroller Instruction Set and these 49 Mnemonics are divided
into five groups.
Lecture 6: Microprocessor instruction set, format
and addressing mode
DATA TRANSFER ARITHMETIC LOGICAL BOOLEAN PROGRAM
BRANCHING
MOV ADD ANL CLR LJMP
MOVC ADDC ORL SETB AJMP
MOVX SUBB XRL MOV SJMP
PUSH INC CLR JC JZ
POP DEC CPL JNC JNZ
XCH MUL RL JB CJNE
XCHD DIV RLC JNB DJNZ
DA A RR JBC NOP
RRC ANL LCALL
SWAP ORL ACALL
CPL RET
RETI
JMP
Lecture 6: Microprocessor instruction set, format
and addressing mode
Instruction Format
Let us see the structure of the 8051 Microcontroller Instruction. An 8051
Instruction consists of an Opcode (Operation – Code) followed by Operand(s) of
size Zero Byte, One Byte or Two Bytes.
The Op-Code part of the instruction contains the Mnemonic, which specifies the
type of operation to be performed. All Mnemonics or the Opcode part of the
instruction are of One Byte size.
The Operand part of the instruction defines the data being processed by the
instructions. The operand can be any of the following:
• No Operand
• Data value
• I/O Port
• Memory Location
• CPU register
Lecture 6: Microprocessor instruction set, format
and addressing mode
There can be multiple operands and the format of instruction is as
follows:
Resolution (R)
. .
= =
= 0.00502V
= 5.02mV
Therefore,
00000000 = 0V
00000001 = 5.02mV
00000010 = 10.04mV
11111111 = 1.28V
Lecture 7: Microcomputer Interfacing
• Interfacing with a DAC
Sometimes, digital data are
required to be presented in
their analogue form such as in
playing music from a memory
device.
Here, the DAC is applied to
convert the data bits to their
analogue form.
Lecture 7: Microcomputer Interfacing
• Interfacing with a DAC
Lecture 8:
System Development Tools
Lecture 8: System Development Tools
The development of microcomputer
applications requires a number of
tools. These tools are both in
hardware and software form and each
plays a role in the different stages of
the system development. The system
development span from its
abstraction level when the product is
conceived through its design layout,
prototype development, firmware
development, and testing and
validation
Lecture 8: System Development Tools
•Layout Design
Tools required at this level include:
Pen and Paper,
Spreadsheet, and
Graphic design applications such as:
Visio, Corel Draw, Autocad, and so on,
Lecture 8: System Development Tools
•Prototype development
Special digital circuit design and simulation
applications such as:
Proteus, Multisim, and so on are required.
PCB development software
Soldering and desoldering tools
Lecture 8: System Development Tools
•Firmware
Development
Code development and
Debugging IDE
Compiler or Interpreter
or Assembler
Programmer
UV Eraser
Lecture 8: System Development Tools
Programmers
This could be an outboard or onboard type
Lecture 8: System Development Tools
Logic Analyzer
This applies when you
need to visualize data
patterns in a group of
I/Os. The analyzer is a
very vital tool in digital
system testing and
analysis.
Lecture 8: System Development Tools
Oscilloscope
This tool though can be used
to check the logic behaviour
of a data line, it is most
essential for analyzing the
analogue characteristic of
the signal.
Lecture 9 to 12:
Application of
microcontrollers in embedded
systems