You are on page 1of 44

Microprocessors

Indian Institute for Production Management

History
Microprocessors became possible with the advent of LSI technology. INTEL 4004 was the first 4 bit programmable device which was primarily used in calculators. This chip became known as the 4 bit microprocessor.Next chip by INTEL were 8 bit 8008, and in mid 1970 came 8080. After 8080 came Motorola 6800, Zilog Z80 and 8085. Currently we have 32 bit and 64 bit processors for PCs. However for industrial applications the 8 bit processors are still predominantly used.
Indian Institute for Production Management
2

Decimal Binary Hexadecimal

Octal

Recapitulation
Number Systems: Decimal Binary Hexadecimal Octal

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16

0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 10000

1 2 3 4 5 6 7 8 9 A B C D E F 10

1 2 3 4 5 6 7 10 11 12 13 14 15 16 17 20
3

Indian Institute for Production Management

The ASCII Code


American Standard Code for Information Interchange

This is a 7 bit code with 128 (27 ) combinations. Each combination from 0 to 127 is assigned a letter or a number or a special character.

Indian Institute for Production Management

Binary Addition
0+0=0 0+1=1 1 + 1 = 10 OR 1 + 1 = 0 and Carry 1 1 + 1 + 1 = 11 OR 1 + 1 + 1 = 1 and Carry 1 11100 + 11010 10110 (Carry 1)

Indian Institute for Production Management

Signed Binary Numbers


It is easy to write negative decimal numbers such as 1, --2, --3 etc. One common method to write binary equivalents is to convert the magnitude to binary an add a 0 for + sign and add 1 for sign. Thus ( ) 001 ( +) 001 1001 0001

Indian Institute for Production Management

2s Compliment
Decimal and Binary Number line

-3
1101

-2
1110

-1
1111

0
0000

1
0001

2
0010

3
0011

1s complement Change 1 0 and 0 1 2s complement add 1 to 1s complement Thus 1s complement of 0001 = 1110 2s complement of 0001 = 1110 + 1 = 1111 Thus for microprocessor operations the number system is : 1) Msb. 0 for positive numbers and 1 for negative numbers. 2) Negative decimal numbers are in 2s complement form.
Indian Institute for Production Management
7

Memory Addressing
In a computer system each peripheral or memory location is identified by a binary number called address. This is similar to the postal address of a house. A house can be identified by various number schemes. The 45th house on a road can be numbered 45 on two digit scheme or 0045 on a four digit scheme. Two digit scheme can only identify 100 houses from 00 to 99, but 4 digit scheme can identify 10000 houses from 0000 to 9999. Similarly 8085 has 16 address lines thus it can address 216 = 65,536 address which is rounded off to 64K. Thus 8 bit microprocessors can have maximum 64K memory. Though in practice it is often about 4k or less.8088 has 20 address lines whereas Pentium processors have 32 bit address lines.

Indian Institute for Production Management

ROM

0
1 2

R0 R1

R2
R3

+5V

3 4

R4
R5 R6 R7

5
6

7
D3
Indian Institute for Production Management

D2

D1

D0

GND 9

Microprocessor System Organization


Input/Output

ALU

Registers

System Bus

Control

Memory ROM RAM

Indian Institute for Production Management

10

The Three Bus Architecture


Memory

Address Bus
Microprocessor

Data Bus Control Bus

I/O

Indian Institute for Production Management

11

The Bus System


All communication by a microprocessor is carried out by a set of parallel wires called bus. Any operation inside the microprocessor, with microprocessor and memory or microprocessor and I/O must use these buses. The 8085 or similar microprocessors have a three bus system. The Data Bus The Address bus Control bus
Indian Institute for Production Management
12

Tri State Buffer


A digital bus is a path over which digital information is transferred from several sources o several destinations. Only one transfer can take place at any one time. When a particular transfer is taking place all other sources of data must be disabled. This is achieved by Tri state or Three state buffer devices. ENABLE IN OUT

0
IN Enable OUT

X 0 1

Open 0 1
13

1 1

Indian Institute for Production Management

Data Bus
For a 8 bit microprocessor like 8085 the data bus has 8 lines. Information can flow both ways on the data bus, i.e.it can be used for reading and writing to the memory as well as input and output. Although data can move in both direction, it can move in one direction at a time.

Indian Institute for Production Management

14

Address bus
The number of address lines determine the maximum addressable memory of the microprocessor. Example: 8 bit microprocessors have a 16 bit addressing system. Thus these can address memory from 0000 H to FFFF H Thus total number of memory locations is given by 216 = 65,536 The address bus is unidirectional.

Indian Institute for Production Management

15

Control Bus
The control bus is a set of lines from the microprocessor by which commands can be issued to and from the microprocessor. There can be the following typical use. 1. Memory Read (MEMR) 2. Memory Write (MEMW) 3. Input device read (IOR) 4. Out put device Write (IOW)

Indian Institute for Production Management

16

Example of Bus Operation Writing Data to memory


Address Bus Valid Address

Data Bus

Valid Data

Control Bus

MEM Write Time allowed by microprocessor for memory to decode the address.

Indian Institute for Production Management

17

Address & Data Bus Multiplexing


8085 does not use 16 pins for an exclusive address bus. The low order address byte A0 to A7 is time multiplexed with the data bits. Thus at a given instant of time the pins will either supply either address bits A0 to A7 or Data bits D0 to D7. The address bits A8 to A15 will be carried by address bus.

Indian Institute for Production Management

18

Address & Data Bus Multiplexing

Address bus

High Address

Address/Data

Low Address

Data

Control
ALE

ALE

Latch address

Address latch enable

Indian Institute for Production Management

19

Parts of a Microprocessor based system


Clock Arithmetic logic unit (ALU) The Register array The Control Unit Memory Input/ Output System Bus
20

Indian Institute for Production Management

Clock
Every microprocessor based system uses a clock oscillator from which all timing signals are derived. The clock of 8085 is contained within the microprocessor and requires only the addition of a crystal between the pins 1 and 2. The crystal frequency is twice the system clock frequency.

Indian Institute for Production Management

21

Registers
Functions:
Store data Perform arithmetic & logical operation. Test for condition

Registers are primarily used to store data temporarily during execution of a program. 8085 Registers
Accumulator A Flag Register

B D H

C E L

Sequence the execution of instruction

Stack Pointer Program Counter

Indian Institute for Production Management

22

Register Pairs
All general purpose registers (A,B,C,D,E,H,L) in 8 bit microprocessors like 8085 are 8 bit long. The range of numbers which can be stored in any register is 127 to + 127. Thus the registers can be used to store only small integers, two Hex numbers, one ASCII character etc. For calculation involving larger numbers some registers can be used in pairs to provide 16 bit operation. In 8085 this pairs of registers are BC, DE & HL.

Indian Institute for Production Management

23

Program Counter
This is a 16 bit register as it deals with memory addresses which are 16 bit long. The function of the program counter is to point to the memory address from which the next byte of instruction is to be fetched. When a byte is being fetched the program counter is incremented by one to point to the next memory location.

Indian Institute for Production Management

24

ALU & Flags


This is the area of the microprocessor where various computing functions are performed on data. ALU can can do addition, subtraction, and logic operation like AND, OR, and Exclusive OR. In 8085 the Accumulator sends and receives data from the ALU during calculations. The result of a calculation is stored back in accumulator. Flags are flip flops which are set or reset according to the result of an operation.Example: Carry flag is set(1) if the sum of two numbers is more than 8 bits. Zero flag is set if a result is zero. Sign flag is set if the result becomes negative during operation.
Indian Institute for Production Management
25

Flag Flip Flops


D7 S Z CY S P AC D6 Z Zero Carry Sign Parity Auxiliary Carry D5 D4 AC D3 D2 P D1 D0 CY

Indian Institute for Production Management

26

Memory
Memory stores instructions and data and provides them to the processor whenever necessary. ROM (Read Only Memory) Programs stored in the ROM are those which do not need alterations.Example EPROM, EEPROM, Flash Memory etc. RAM ( Random Access Memory) This is user memory.Normally RAM stores intermediate user programs and data. Microprocessor can both read data from and write data to RAM e.g.Static RAM, Dynamic RAM.
Indian Institute for Production Management
27

How does the microprocessor work?

Fetch Instruction

Decode Instruction

Execute Instruction

The microprocessor fetches binary instructions or data from the memory. It uses registers to store data temporarily. It performs computing function in the ALU. It sends out results using the bus lines. The sequence of fetch, decode and execute is continued until there is an instruction to stop.
Indian Institute for Production Management
28

8085 Schematic

INTA
INTR RST5.5

RST6.5 RST7.5

TRAP
SID

SOD

Interrupt control

Serial I/ O

8 Bit Internal Data Bus Instruction Register

Accumulator

Temp

Flags

B D H
Program Counter

C E L

ALU

Instruction Decoder

Stack Pointer

Increment/decrement Address Latch + 5V GND X1

Timing and Control


CLK GEN CONTROL RD Ready STATUS S1 HLDA IO/M HOLD Reset Out Reset In DMA RESET Address Buffer Address/Data Buffer

X2

CLK Out

WR

ALE S0

Address Bus A15 A8

Address/Data Bus AD7 AD0

Indian Institute for Production Management

29

8085 PINOUT & Signals


Indian Institute for Production Management
30

Input/Output Ports
There can be three kinds of ports. 1. INPUT Port where CPU reads data from port.

2. OUTPUT port where CPU writes data to port.


3. INPUT/OUTPUT Port which are bi-directional ports. 8 bit processors have 16 bit addresses thus theoretically there can be 65,536 ports. However in practice this is limited as the computers memory also requires the addresses. In actual practice there can be two methods by which I/O devices can be identified : I/Os with 8 bit addresses (i.e. 256 inputs and 256 outputs) I/Os with 16 bit addresses( Memory mapped I/O)
Indian Institute for Production Management
31

8 bit addressed I/O


There can be 256 inputs and 256 outputs with addresses ranging from 00 to FF. The input and output devices are differentiated by the control signals IOR(I/O read) and IOW(I/O write). The I/O devices can not be connected directly to the buses. They are connected through tri state devices and in case of output devices a latch is also used to hold the data for more time than the few microseconds given by the microprocessor data bus.

Indian Institute for Production Management

32

Memory Mapped I/O


In this type of I/O device the microprocessor uses 16 bit address lines to identify an I/O device; an I/O device is accessed in the same way as a memory location using the same control signals for Memory Read and Memory Write. Motorola 6800 microprocessor uses this technique.

Indian Institute for Production Management

33

Control and Status signals of 8085


ALE Address Latch enable:This is a positive going pulse generated every time 8085 begins a machine cycle. It indicates that AD7 AD0 are address bits. RD Read: Read control signal. Active low. It means that selected I/O or memory to be read and data is available on the data bus. WR Write: Write control signal. Data to be written to memory or I/O location. IO/M : The status signal to differentiate between I/O and memory operation. High status = I/O operation Low status = Memory operation
Indian Institute for Production Management
34

Control and Status signals of 8085


RESET IN: When the the signal to this pin goes low the program counter is set to zero, the buses are tri stated, and the microprocessor is reset. RESET OUT: This signal indicates that the MPUis being reset and can be used to reset other devices. READY (Input): This signal is used to delay the MPU READ or WRITE cycles until a slow responding peripheral is ready to send or receive data. When this signal goes low the MPU waits for an integral number of clock cycles until it goes high.
Indian Institute for Production Management
35

Direct Memory Access(DMA)


Direct Memory Access is the data transfer between MPU memory and external peripheral device without control of the CPU. HOLD: This is an active high input signal to the 8085 from another device requesting the use of the address and the data buses.After receiving the hold request the microprocessor gives up the control of the buses for the following machine cycles.And sends out the HLDA:(Hold acknowledge) signal. Generally an external peripheral DMA controller sends the HOLD signal, On getting the HLDA signal it gets control of the buses. After the data transfer is over the HOLD pin gets a low signal and MPU gets back control.
Indian Institute for Production Management
36

Interrupts
8085 has five interrupt signals that can be used to interrupt a program execution. INTR (Input) : Interrupt Request: This is a general purpose interrupt which can be enabled or disabled by software. INTA (Output): Used to acknowledge the interrupt. RST 7.5 Restart interrupts. These can transfer RST 6.5 (Inputs) program control to specific memory RST 5.5 locations. TRAP (Input) This has the highest priority of all interrupts. And can not be disabled. This is mainly used for emergency operations.

Indian Institute for Production Management

37

Programmable Devices with Handshake Signal


MPU and peripherals operate at different speeds, thus signals are exchanged prior to to data transfer between fast responding MPU and slow responding peripheral such as printers and data converters, keyboards etc. These signals are called Handshake signals. The exchange of handshake signals prevent the MPU from writing over the previous data before the peripheral has had a chance to accept it, or reading the same old data before the peripheral has time to send the new byte. These handshake signals are generally provided by programmable peripheral devices.
Indian Institute for Production Management
38

Interfacing device With Handshake


Data Bus
Data Lines

MPU
RD

Programmable Interfacing Device 8155 or 8255 INTR

STB
IBF

Peripheral such as key board

Indian Institute for Production Management

39

Data Input With Handshake


1. A peripheral places a data byte in the input port and informs the interface device by sending Handshake signal STB(Strobe) 2. The device informs the peripheral that its input port is full (do not send the next byte) by sending the handshake signal IBF( Input buffer full) 3. MPU keeps checking the status until a byte is available or the interfacing device sends an interrupt to MPU to read the new data. 4. MPU reads the data by sending control signal RD
Indian Institute for Production Management
40

Stack Pointer
The Stack in 8085 microprocessor system can be described as a set of memory locations in the RAM used by the program to store information temporarily during execution of the program. The beginning of the stack is defined by the statement LXI SP, which loads a 16 bit address in the stack pointer register of the microprocessor . Once the stack is defined the loading of the data bytes begins one address lower than the stack pointer register. Thus if the stack pointer register has the address 2099h then the storing of data bytes will begin at 2098h.Thus normally the highest level of memory available is given to the stack.
Indian Institute for Production Management
41

Interfacing Devices
TRI STATE DEVICES:

74LS244: Octal Buffer. Commonly Used as driver for address bus of a microprocessor system.
74LS245: Octal Bidirectional Buffer. Has 16 bus drivers , 8 for each way. Used for Data bus.

Indian Institute for Production Management

42

Interfacing Devices
DECODER:Commonly used for interfacing I/O peripherals

and memory. Decoder is a logic circuit that identifies each combination of input signals present. Thus a 2 to 4 decoder will have four combination of input signals that identifies the 4 output lines.
Examples of Decoders:

74LS138
3 TO 8 Decoder 8205

Indian Institute for Production Management

43

Interfacing Devices
LATCHES:

A latch is commonly used to interface output devices. When a microprocessor sends a signal to the output the data is available for only a few microseconds, the latch is used to hold the data for display or for transmission to slow peripheral devices.
Example: 74LS373 octal D latch. The device has 8 D latches with Tri State Buffers.

Indian Institute for Production Management

44

You might also like