Top Banner
Microprocessor System Red Sea University – Engineering Faculty Page 1 Course Title Microprocessor System By: Lecturer. Elmustafa Sayed Ali Ahmed Electrical and Electronics engineering Dept. E-mail: [email protected]
20
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: lecture 1 o 5

Microprocessor System

Red Sea University – Engineering Faculty Page 1

Course Title

Microprocessor System

By: Lecturer. Elmustafa Sayed Ali Ahmed Electrical and Electronics engineering Dept.

E-mail: [email protected]

Page 2: lecture 1 o 5

Microprocessor System

Red Sea University – Engineering Faculty Page 2

Course outlines

Lecture 1: Introduction to microprocessor, A Historical Background of

Microprocessors.

Lecture 2: Binary and Hexadecimal Number Systems.

Lecture 3: Microprocessor architecture, operations, and buses system.

Lecture 4: Memory, Input & output devices.

Lecture 5: Logic devices for interfacing.

Lecture 7: Basic interfacing concepts, and Memory interfacing.

Lecture 8: The 8085 MPU, Example of an 8085 based computer.

Lecture 9: Interfacing output displays, and Interfacing input devices.

Lecture 10: Memory mapped I/O.

Lecture 11: Data Transfer operations and Arithmetic operations.

Lecture 12: Logic Operations, Branch operation, Writing assembly

language programs, and programming techniques.

Lecture 13 and 14 : Advance Topics

Page 3: lecture 1 o 5

Microprocessor System

Red Sea University – Engineering Faculty Page 3

Lecture 1

Brief History of the Computers

- 1946 The first generation of Computer ENIAC was started to be used based

on the vacuum tube Technology.

- 1958 the first transistorized computer TRADIC was announced by IBM.

- 1959 first IC was invented.

- 1960s ICs were started to be used in CPU boards.

- 1970s entire CPU was put in a single chip. (1971 the first microprocessor of

Intel 4004 (4-bit data bus and 2300 transistors)

- Late 1970s Intel 8080/85 appeared with 8-bit data bus and 16-bit address bus

and used from traffic light Controllers to homemade computers.

- 1981 First PC was introduced by IBM with Intel 8088 microprocessor.

- Motorola emerged with 6800. Apple Macintosh computers started to use

68000 series of Microprocessors.

Microprocessor Concepts

Computer system consists of three major parts, they are; Central Processing Unit

(CPU), Memory, and Input/output (I/O) Devices. Central Processing Unit (CPU)

simply called as the microprocessor acts as the brain coordinating all activities

within a computer. Memory is the place that program instructions and data are

primarily stored. Input/output (I/O) Devices allow the computer to input information

for processing and then output the results. I/O Devices are also known as computer

peripherals.

Microprocessor is an electronic circuit that functions as the central processing unit

(CPU) of a computer, providing computational control. Microprocessors are also

used in other advanced electronic systems, such as computer printers, automobiles,

and jet airliners typical microprocessors incorporate arithmetic and logic functional

units as well as the associated control logic, instruction processing circuitry, and a

portion of the memory hierarchy.

While many microprocessors and single-chip designs, some high performance

designs rely on a few chips to provide multiple functional units and relatively large

caches. When combined with other integrated circuits that provide storage for data

and programs, often on a single semiconductor base to form a chip, the

microprocessor becomes the heart of a small computer, or microcomputer.

Page 4: lecture 1 o 5

Microprocessor System

Red Sea University – Engineering Faculty Page 4

Microprocessors are classified by the semiconductor technology of their design

(TTL, transistor-transistor logic; CMOS, complementary-metal-oxide

semiconductor; or ECL, emitter-coupled logic), by the width of the data format (4-

bit, 8-bit, 16-bit, 32-bit, or 64-bit) they process; and by their instruction set (CISC,

complex-instruction-set computer, or RISC, reduced-instruction-set computer; see

RISC processor).

A microprocessor can do any information-processing task that can be expressed,

precisely, as a plan. It is totally uncommitted as to what its plan will be. It is a truly

general-purpose information processing device. The plan, which it is to execute

which will, in other words, control its operation; is stored electronically. This is the

principle of “stored program control”. Without a program the microprocessor can do

nothing. With one, it can do anything. Furthermore, microprocessors can only

perform information-processing tasks. To take action on the outside world, or to

receive signals from it, a connection must be provided between the microprocessor’s

representation of information (as digital electronic signals) and the real world

representation.

The integrated Circuit (IC) chip containing the CPU is called the microprocessor

and the entire computer including the microprocessor, memory and I/O is called a

microcomputer. The CPU is connected to memory and I/O devices through a strip

of wires called a bus. The bus inside a computer carries information from place to

place. In every computer there are three types of busses;

- Address Bus: The address bus is used to identify the memory location or I/O

device the processor intends to communicate with.

- Data Bus: Data bus is used by the CPU to get data from / to send data to the

memory or the I/O devices.

- Control Bus. How can we tell if the address on the bus is memory address or

an I/O device address? This where the control bus comes in. Each time the

processor outputs an address it also activates one of the four control bus

signals: Memory Read, Memory Write, I/O Read and I/O Write.

Page 5: lecture 1 o 5

Microprocessor System

Red Sea University – Engineering Faculty Page 5

Historical Background

Intel 4004: the world’s first microprocessor developed by Intel Corporation in

1971.

- 4-bit cpu

- 4096 4-bit memory locations

- 45 instructions

- Speed: 50k 1ps (instructions per second)

Other Intel Microprocessors

1) 8008 (later in 1971): and extended 8-bit version of 4004, memory size: 16k

bytes, 48 instructions, 50k 1ps.

2) 8080 (1973): 8-bit cpu, 64k byte memory, 500k 1ps.

3) 8088/8086 (1977,1978): 16bit cpu, 1M byte memory, 2.5M 1ps.

4) 80186: a similar version of 8086, it has more instructions.

5) 80286 (1983): an extended 16M-byte memory of 8086, 8MHz cpu, 4M

1ps.

6) 80386 (1986): fully 32-bit cpu, up to 4G byte memory, hardware memory

management and memory assignment. Pipelined instruction execution,

33M 1ps.

7) 80486 (DX, SX) (1989): an improvement of 80386, 50M 1ps, with built-

in math processor (for floating-point and extended-precision number

operations)

8) Pentium (1993): P5 or 80586, 60-133M2, 16k cache, 4G memory, 2 integer

units.

9) Pentium with MMX

10) Pentium Pro (1995): P6, 150-166 M2, 16k cache, 156k-second level

cache, three integer units.

11) Pentium 4

Page 6: lecture 1 o 5

Microprocessor System

Red Sea University – Engineering Faculty Page 6

Lecture 2

Binary and Hexadecimal Number Systems

As human being we use base 10 (decimal) arithmetic Computers use base 2 (binary)

system. Base 16 Hexadecimal number system is a convenient way of represented

binary numbers. ASCII (binary format of the alphanumeric code) is an example of

computer numbered system used.

There is a speculation of the fact that Humans use base 10 system is because they

have 10 fingers. But there is no speculation behind the fact that the computers use

binary system. The binary system is used in computers, because 1 and zero represent

the two voltage levels of on and off. There are 10 digits in Decimal system:

0,1,2,3,4,5,6,7,8,9 and only 2 digits in Binary system: 0,1 (Binary digits are referred

as bits). For example to Converting from decimal to binary and vice versa as shown

follows;

Example: Convert 2510 to binary:

Example: Convert 1101012 to decimal:

Hexadecimal system is defined to be the base 16 number system and is used as a

convenient representation of binary numbers.

Page 7: lecture 1 o 5

Microprocessor System

Red Sea University – Engineering Faculty Page 7

- Home work:

Converting from decimal to hex (hexadecimal).

Converting from hex to decimal.

Addition and subtraction in binary numbers.

ASCII Code is an abbreviation of an American Standard Code for Information

Interchange which used to coding the keyboard numbers and symbols.

Page 8: lecture 1 o 5

Microprocessor System

Red Sea University – Engineering Faculty Page 8

- Some important terminology

Bit 0 or 1

Nibble 0000

Byte 0000 0000

Word 0000 0000 0000 0000

Double-word 0000 0000 0000 0000 0000 0000 0000 0000

Quad-word 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000

0000 0000 0000 0000

1 kilobyte is 210 bytes. (Abbreviation K is used) Some floppy disks hold 356K bytes

of data.

1 megabyte is 220 bytes. (a little over a million 1,048,576)

1 gigabyte is 230 bytes (over 1 trillion)

1 terabyte is 240 bytes

Page 9: lecture 1 o 5

Microprocessor System

Red Sea University – Engineering Faculty Page 9

Lecture 3

Microprocessor architecture

Computer system consist primary of:

1- Microprocessor.

2-Memory.

3-Input.

4-Output.

The internal logic design of the microprocessor called its “architecture", determine

how and what various operations are performed by "MICROPROCESSOR". The

microprocessor is programmable logic device designed with register, flip-flop and

timing elements. All function performed by microprocessor can by classified in three

general categories

Microprocessor initiated operations.

Internal data operations.

Peripheral (or externally) initiated operations.

To performed these operations, microprocessor needs [logic circuit and control

signals]. Primarily microprocessor performs four operations;

Memory read (Reads data from memory).

Memory writes (Write data into memory).

I/O read (Accept data to output device).

I/O writes (Sends data to output device).

These operation are part of communication process. Microprocessor performed these

functions using sets of buses [Data bus, Address bus, Control bus]. The buses

operation concept are mentioned in lecture 1.

- Data bus: is a group of 8 lines used for data flow, these lines are bidirectional

from (00 – FF) =28 =256 numbers. The largest number = 1111 1111 = FF,

thus 8085 Microprocessor is called 8bit Microprocessor.

- Address bus: is a group of 16 lines, identified as 0 – 15. This bus is

unidirectional (bit flow in one direction) from Microprocessor to peripheral.

Page 10: lecture 1 o 5

Microprocessor System

Red Sea University – Engineering Faculty Page 10

Each memory location or peripheral identified with binary number called

address. (216 =65536=64K).

- Control bus: the control is comprised of various single lines that carry

synchronization signals.

The microprocessor needs to perform the following steps; identify the peripheral

(memory location), transfer data, and provide timing or synchronization signals. A

program stored in the memory provides instructions to the CPU to perform a specific

action. This action can be a simple addition. It is function of the CPU to fetch the

program instructions from the memory and execute them.

1. The CPU contains a number of registers to store information inside the CPU

temporarily. Registers inside the CPU can be 8-bit, 16-bit, 32-bit or even 64-bit

depending on the CPU.

2. The CPU also contains Arithmetic and Logic Unit (ALU). The ALU performs

arithmetic (add, subtract, multiply, divide) and logic (AND, OR, NOT) functions.

3. The CPU contains a program counter also known as the Instruction Pointer to

point the address of the next instruction to be executed.

Page 11: lecture 1 o 5

Microprocessor System

Red Sea University – Engineering Faculty Page 11

4. Instruction Decoder is a kind of dictionary which is used to interpret the meaning

of the instruction fetched into the CPU. Appropriate control signals are generated

according to the meaning of the instruction.

Internal Data Operations

The internal architecture of the 8085/8080A microprocessor determines how and

what operation can be performed with the data. These operations are;

Store 8-bit data.

Performed arithmetic and logical operations.

Test for conditions.

Sequence the execution of instructions.

Store data temporarily during execution in the defined R/W memory locations

called the stack.

Page 12: lecture 1 o 5

Microprocessor System

Red Sea University – Engineering Faculty Page 12

Externally Initiated Operations

External devices (or signals) can initiate the following operation for which

individual pins on Microprocessor chip are assigned: Reset, Interrupt, Ready,

Hold.

Reset: when reset is activated all internal operations are suspended and the

program counter is cleared.

Interrupt: the Microprocessor can be interrupted from normal execution and

asked to execute other instructions called "service routine" (emergency),

Microprocessor resumes its operation after that.

Ready: 8085 has pin called ready, if the signal is low Microprocessor enters

into wait state, this signal used to synchronized slower peripherals with

Microprocessor.

Hold: when hold pin activated by external signal Microprocessor relinquishes

control buses and allows the external peripheral to use the. For example: Hold

signal is used in direct memory access data transfer.

Page 13: lecture 1 o 5

Microprocessor System

Red Sea University – Engineering Faculty Page 13

Lecture 4

Memory, Input & output devices

Memory is an essential component of a microprocessor system; it stores binary

information. The memory is made up of semiconductor material used to store the

programs and data. The types of memory is, Primary or main memory and

Secondary memory.

Primary memory: RAM and ROM are examples of this type of memory.

Microprocessor uses it in storing a program temporarily (commonly called

loading) and executing a program. Hence the speed of this type of memory should

be fast.

Secondary memory: These are used for bulk storage of data and information.

The main examples include Floppy, Hard Disk, CD-ROM, Magnetic Tape etc.

Slower and Sequential Access Nature. Non-volatile nature.

Memory chip

The basic memory element is similar to a D latch. This latch has an input where

the data comes in. It has an enable input and an output on which data comes out.

Address Decoding and Memory Mapping

Memory address decoding is used to assign an address for each location in the

memory chip. The data stored in the memory is accessed by specifying its

address. Memory address can be decoded in two ways;

Absolute or fully decoding

Linear Select or Partial decoding

Page 14: lecture 1 o 5

Microprocessor System

Red Sea University – Engineering Faculty Page 14

The advantages of absolute address decoding are;

Each memory location has only one address.

There is no duplication in the address Memory can be placed contiguously

in the address space of the microprocessor.

Future expansion can be made easily without disturbing the existing

circuitry

The disadvantages of absolute address decoding are;

Extra decoders are necessary

some delay will be produced by these extra decoders

The advantages of Linear Select decoding;

Its simplified decoding circuit. This reduces the hardware design cost

The disadvantages of Linear Select decoding are;

Multiple addresses are provided for the same location

Complete memory space of the microprocessor is not efficiently used

Adding or interfacing ICs with already existing circuitry is difficult.

Absolute Address Decoding

The 8085 microprocessor has 16 address lines. Therefore it can access 216

locations in the physical memory. If all these lines are connected to a single

memory device, it will decode these 16 address lines internally and produces 216

different addresses from 0000H to FFFFH so that each location in the memory

will have a unique address. If more than one chips are used then some logic must

be used to select one particular chip. This is done with the help of decoder.

74LS138 address decoder to generate the chip select signals for each memory

block. In this decoder when the address lines A13, A14 and A15 are 000, the

output lineY0 will be activated as shown in Fig below. This in turn selects the

first memory block. Similarly when these lines are 001 (C=0, B=0 and A=1) Y1

will be activated and the second memory block will be selected.

Memory block decoder

Page 15: lecture 1 o 5

Microprocessor System

Red Sea University – Engineering Faculty Page 15

In this type of memory interfacing, all the address lines (A0 to A15) have been

used. Each location in the memory will have a single address. This type of address

decoding is called as absolute or fully decoded addressing. In all memories if CS’

is ‘0’memory 1 will be selected else memory2 will be selected. And the complete

picture of the interfacing is shown below.

The complete interfacing diagram

The simple view of RAM is that it is made up of registers that are made up of

flip-flops (or memory elements). The number of flip-flops in a “memory register”

determines the size of the memory word. ROM on the other hand uses diodes

instead of the flip-flops to permanently hold the information. For the

microprocessor to access (Read or Write) information in memory (RAM or

ROM), it needs to do the following;

Select the right memory chip (using part of the address bus). Identify the memory

location (using the rest of the address bus). Access the data (using the data bus).

Page 16: lecture 1 o 5

Microprocessor System

Red Sea University – Engineering Faculty Page 16

Input /Output Devices

Input output devices are use the parallel interface , There are two ways to

interface 8085 with I/O devices in parallel data transfer mode; Memory Mapped

IO and IO mapped IO.

Memory mapped I/O: It considers them like any other memory location. They

are assigned a 16-bit address within the address range of the 8085.The exchange

of data with these devices follows the transfer of data with memory. The user

uses the same instructions used for memory.

I/O mapped I/O: It treats them separately from memory: I/O devices are assigned

a “port number” within the 8-bit address range of 00H to FFH. The user in this

case would access these devices using the IN and OUT instructions only.

- Reports and assignments:

write on types of memories (RAM, ROM)

Classify the memories (volatile and non-volatile)

functions and operation

Assignment on types of Input and Output devices.

Page 17: lecture 1 o 5

Microprocessor System

Red Sea University – Engineering Faculty Page 17

Lecture 5

Logic Devices

Several types of interfacing devices are necessary to interconnect the components

of a bus oriented system, here we will discuss the most important interface

devices. Tristate logic devices are essential to proper functioning of bus oriented

system, octal bus for Bidirectional Ports, octal 3-state buffer, and D-Latch.

Tri state Devices: A tri state (bus driver) device is a device that can be active low,

active high, or floating. The use of a tri state device is that several of them can be

connected to a single bus line and, so long as only one of them is non-floating,

the bus line can be driven by multiple senders. The data bus is most often

implemented with tri state drivers.

Tri state device

The data will be passed to the output terminal whenever the OE terminal is

activated, else the device will be in high impedance state.

Bidirectional Ports: The octal bus transceivers are designed for asynchronous

two-way communication between data buses. The control-function

implementation minimizes external timing requirements. The devices allow data

transmission from the A bus to the B bus or from the B bus to the A bus,

Depending on the logic level at the direction-control (DIR) input. The output-

enable (OE)\ input can disable the device so that the buses are effectively isolated.

Octal 3-state buffer: used to avoid the dreaded “self-destruct state” due to bus

contention. OE1 could connect to the address decoder for this input port while

OE2 could connect to an active-low READ strobe. This READ strobe

requirement is imperative so as to keep the output drivers disabled. Bus

contention is the result of more than a single driver on a shared bus line being

active at the same time and potentially driving a bus line to opposing logic levels.

Such would be the case if the READ strobe were ignored during a CPU write

operation

Page 18: lecture 1 o 5

Microprocessor System

Red Sea University – Engineering Faculty Page 18

Octal 3 state Buffer

D-Latch: Latch and flip flop are the most common logic devices that are used to

store one bit data. A simple latch has two stable logic states. The latch maintains

its states indefinitely until an input pulse called a trigger is received. If a trigger

is received, the latch outputs change states according to defined rules, and remain

in those states until another trigger is received. Latches can be interconnected to

form more sophisticated circuits that function in memory chips and

microprocessors.

Basic Interface

As mentioned earlier, the microprocessor is the CPU of the microcomputer.

Therefore, the power of the microcomputer is determined by the capabilities of

the microprocessor. Its clock frequency determines the speed of the

microcomputer. The number of data and address pins on the microprocessor chip

make up the microcomputer’s word size and maximum memory size. The

microcomputer’s I/O and interfacing capabilities are determined by the control

pins on the microprocessor chip. The logic inside the microprocessor chip can be

divided into three main areas: the register section, the control unit, and the

arithmetic-logic unit (ALU). A microprocessor chip with these three section;

Register Section, Control Section, and ALU Section.

Register Section

The number, size, and types of registers vary from one microprocessor to another.

However, the various registers in all microprocessors carry out similar operations.

The register structures of microprocessors play a major role in designing

microprocessor architectures. Also, the register structures for a specific

microprocessor determine how convenient and easy it is to program the

microprocessor. We first describe the most basic types of microprocessor registers,

their functions, and how they are used. We then consider other common types of

Page 19: lecture 1 o 5

Microprocessor System

Red Sea University – Engineering Faculty Page 19

registers. There are four basic microprocessor registers: instruction register,

program counter, memory address register, and accumulator.

Instruction register (IR). The instruction register stores instructions. The contents

of an instruction register are always decoded by the microprocessor as an instruction.

After fetching an instruction code from memory, the microprocessor stores it in the

instruction register. The instruction is decoded internally by the microprocessor,

which then performs the operation required.

Program Counter (PC). The program counter contains the address of the instruction

or operation code (op-code). The program counter normally contains the address of

the next instruction to be executed. Upon activating the microprocessor’s RESET

input, the address of the first instruction to be executed is loaded into the program

counter. To execute an instruction, the microprocessor typically places the contents

of the program counter on the address bus and reads (“fetches”) the contents of this

address (i.e., instruction) from memory. The program counter contents are

incremented automatically by the microprocessor’s internal logic. The size of the

program counter is determined by the size of the address bus.

Memory Address Register (MAR). The memory address register contains the

address of data. The microprocessor uses the address, which is stored in the memory

address register, as a direct pointer to memory. The contents of the address is the

actual data that is being transferred.

General Purpose Register (GPR). For an 8-bit microprocessor, the general-purpose

register is called the accumulator. This is typically an 8-bit register. It stores the

result after most ALU operations. These 8-bit microprocessors have instructions to

shift or rotate the accumulator one bit to the right or left through the carry flag. The

accumulator is typically used for inputting a byte into the accumulator from an

external device or for outputting a byte to an external device from the accumulator.

Control Unit section

The main purpose of the control unit is to read and decode instructions from the

program memory. To execute an instruction, the control unit steps through the

appropriate blocks of the ALU based on the op-codes contained in the instruction

register. The op-codes define the operations to be performed by the control unit to

execute an instruction. The control unit interprets the contents of the instruction

register and then responds to the instruction by generating a sequence of enable

signals. These signals activate the appropriate ALU logic blocks to perform the

Page 20: lecture 1 o 5

Microprocessor System

Red Sea University – Engineering Faculty Page 20

required operation. Control signals regarded to three operations, reset, read/write,

and ready.

RESET; this input is common to all microprocessors. When this input pin is driven

HIGH or LOW (depending on the microprocessor), the program counter is loaded

with a predefined address specified by the manufacturer.

READWRITE (W/R); this output line is common to all microprocessors. The status

of this line tells the other microcomputer elements whether the microprocessor is

performing a READ or a WRITE operation. A HIGH signal on this line indicates a

READ operation, and a LOW indicates a WRITE operation. Some microprocessors

have separate READ and WRITE pins.

READY; this is an input to a microprocessor. Slow devices (memory and I/O) use

this signal to gain extra time to transfer data to or receive data from a microprocessor.

The READY signal is usually an active low signal; that is, LOW indicates that the

microprocessor is ready. Therefore, when the microprocessor selects a slow device,

the device places a LOW on the READY pin. The microprocessor responds by

suspending all its internal operations and enters a WAIT state. When the device is

ready to send or receive data, it removes the READY signal.

Interrupt Request (INT or IRQ). The external I/O devices can interrupt the

microprocessor via this input pin on the microprocessor chip. When this signal is

activated by the external devices, the microprocessor jumps to a special program

called the interrupt service routine. This program is normally written by the user for

performing tasks that the interrupting device wants the microprocessor to carry out.

After completing this program, the microprocessor returns to the main program it

was executing when the interrupt occurred.

Arithmetic-Logic Unit

The ALU performs all the data manipulations, such as arithmetic and logic

operations, inside a microprocessor. The size of the ALU conforms to the word

length of the microcomputer. This means that a 32-bit microprocessor will have a

32-bit ALU. Some of the typical functions performed by the ALU are:

Binary addition and logic operations

Finding the one’s complement of data

Shifting or rotating the contents of a general-purpose register 1 bit to the

left or right through a carry.