Академический Документы
Профессиональный Документы
Культура Документы
Microprocessor
Microprocessor
INPUT As OUTPUT
CPU
MEMORY
Operation Types in a Microprocessor
• All of the operations of the microprocessor
can be classified into one of three types:
- Microprocessor Initiated Operations
- Internal Operations
- Peripheral Initiated Operations
4
Microprocessor Initiated Operations
• These are operations that the microprocessor
itself starts.
• These are usually one of 4 operations:
– Memory Read
– Memory Write
– I/O Read (Get data from an input device)
– I/O write (Send data to an output device)
5
Microprocessor Initiated Operations
• It is important to note that the microprocessor treats
memory and I/O devices the same way.
– Input and output devices simply look like memory
locations to the microprocessor.
• For example, the keyboard may look like memory address A3F2H.
To get what key is being pressed, the microprocessor simply reads
the data at location A3F2H.
6
The Read Operation
– To read the contents of a memory location, the
following steps take place:
• The microprocessor places the 16-bit address of the
memory location on the address bus.
• The microprocessor activates a control signal called
“memory read” which enables the memory chip.
• The memory decodes the address and identifies the
right location.
• The memory places the contents on the data bus.
• The microprocessor reads the value of the data bus
after a certain amount of time.
7
Internal Data Operations
• The 8085 can perform a number of internal
operations. Such as: storing data, Arithmetic &
Logic operations, Testing for condition, etc.
– To perform these operations, the microprocessor
needs an internal architecture similar to the
following:
Accumulator Flags
B C
D E
H L
Program Counter
Stack Pointer
Address 16 8 Data
8
Register Set
Arithmetic and Logical group
S Z X AC X P X CY
S:Sign flag is set when result of an operation is negative.
Z:Zero flag is set when result of an operation is 0.
Ac:Auxiliary carry flag is set when there is a carry out of lower
nibble or lower four bits of the operation.
CY:Carry flag is set when there is carry generated by an
operation.
P:Parity flag is set when result contains even number of 1’s.
Rest are don’t care flip flops.
The Internal Architecture
• We have already discussed the general purpose
registers, the Accumulator, and the flags.
11
The Internal Architecture
• The Stack pointer
– The stack pointer is also a 16-bit register that is
used to point into memory.
– The memory this register points to is a special
area called the stack.
– The stack is an area of memory used to hold data
that will be retreived soon.
– The stack is usually accessed in a Last In First Out
(LIFO) fashion.
12
Externally Initiated Operations
• External devices can initiate (start) one of the 4
following operations:
– Reset
• All operations are stopped and the program counter is reset
to 0000.
– Interrupt
• The microprocessor’s operations are interrupted and the
microprocessor executes what is called a “service routine”.
• This routine “handles” the interrupt, (perform the necessary
operations). Then the microprocessor returns to its previous
operations and continues.
13
Externally Initiated Operations
– Ready
• The 8085 has a pin called RDY. This pin is used by external
devices to stop the 8085 until they catch up.
• As long as the RDY pin is low, the 8085 will be in a wait state.
– Hold
• The 8085 has a pin called HOLD. This pin is used by external
devices to gain control of the busses.
• When the HOLD signal is activated by an external device, the
8085 stops executing instructions and stops using the
busses.
• This would allow external devices to control the information
on the busses. Example DMA.
14
The Design and Operation of Memory
• Memory in a microprocessor system is where
information (data and instructions) is kept. It can be
classified into two main types:
• Main memory (RAM and ROM)
• Storage memory (Disks , CD ROMs, etc.)
15
Accessing Information in Memory
• 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).
16
Tri-State Buffers
• An important circuit element that is used
extensively in memory.
• This buffer is a logic circuit that has three
states:
– Logic 0, logic1, and high impedance.
– When this circuit is in high impedance mode it
looks as if it is disconnected from the output
completely.
17
The Tri-State Buffer
• This circuit has two inputs and one output.
– The first input behaves like the normal input for
the circuit.
– The second input is an “enable”.
• If it is set high, the output follows the proper circuit
behavior.
• If it is set low, the output looks like a wire connected to
nothing.
Input Output OR Input Output
Enabe Enable
18
The Basic Memory Element
• 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.
Data Input Data Output
D Q
Enable
EN
19
The Basic Memory Element
• However, this is not safe.
– Data is always present on the input and the
output is always set to the contents of the latch.
– To avoid this, tri-state buffers are added at the
input and output of the latch.
Data Input Data Output
D Q
WR RD
Enable
EN
20
The Basic Memory Element
• The WR signal controls the input buffer.
– The bar over WR means that this is an active low
signal.
– So, if WR is 0 the input data reaches the latch
input.
– If WR is 1 the input of the latch looks like a wire
connected to nothing.
• The RD signal controls the output in a similar
manner.
21
A Memory “Register”
• If we take four of these latches and connect
them together, we would have a 4-bit memory
register
I0 I1 I2 I3
WR
D D D D
Q Q Q Q
EN EN EN EN
EN
RD O0 O1 O2 O3
22
A group of Memory Registers
– If we represent each memory location (Register)
as a block we get the following
I I I I
0 1 2 3
WR Input Buffers
RD Output Buffers
O O1 O2 O3
0
23
8085 INTRODUCTION
26
Signals and I/O Pins
27
8085 PIN DESCRIPTION
31
Generation of control signal
Interrupt Signals
• 8085 μp has several interrupt signals as shown in the following
table.
33
Interrupt signals
34
Interrupt signals
36
The 8085 and Its Buses
• The 8085 is an 8-bit general purpose microprocessor that can address 64K
Byte of memory.
• It has 40 pins and uses +5V for power. It can run at a maximum frequency
of 3 MHz.
– The pins on the chip can be grouped into 6 groups:
• Address Bus.
• Data Bus.
• Control and Status Signals.
• Power supply and frequency.
• Externally Initiated Signals.
• Serial I/O ports.
The Address and Data Bus Systems
• The address bus has 8 signal lines A8 – A15 which are unidirectional.
• The other 8 address bits are multiplexed (time shared) with the 8 data
bits.
– So, the bits AD0 – AD7 are bi-directional and serve as A0 – A7 and D0 –
D7 at the same time.
• During the execution of the instruction, these lines carry the
address bits during the early part, then during the late parts of the
execution, they carry the 8 data bits.
– In order to separate the address from the data, we can use a latch to
save the value before the function of the bits changes.
The Control and Status Signals
• There are 4 main control and status signals. These are:
• ALE: Address Latch Enable. This signal is a pulse that become 1
when the AD0 – AD7 lines have an address on them. It becomes 0
after that. This signal can be used to enable a latch to save the
address bits from the AD lines.
• RD: Read. Active low.
• WR: Write. Active low.
• IO/M: This signal specifies whether the operation is a memory
operation (IO/M=0) or an I/O operation (IO/M=1).
• S1 and S0 : Status signals to specify the kind of operation being
performed. Usually not used in small systems.
Frequency Control Signals
• There are 3 important pins in the frequency control group.
– X0 and X1 are the inputs from the crystal or clock generating circuit.
• The frequency is internally divided by 2.
– So, to run the microprocessor at 3 MHz, a clock running at 6
MHz should be connected to the X0 and X1 pins.
– CLK (OUT): An output clock pin to drive the clock of the rest of the
system.
• MVI A, 32 32
2001H
55
Arithmetic and Logical group
SERIAL IO CONTROL
GROUP
• It is used to accept the serial 1 bit data by
using SID and SOD signals and it can be
performed by using SIM & RIM
instructions.
TIMING AND STATE DIAGRAM
CLX
A15
20H High-Order Memory Address Unspecified 20H High- Order Memory Addresss
A8
Low-Order
AD7
00H 3EH Opcode 01H 32H Data
AD0
Memory Address Memory Address
ALE
IO/M
Status IO/M = 0, S0 = 1, S1 = 1 Opcode Fetch IO/M = 0, S1 = 1, S0 = 0 Status
S1, S0
RD
8085 Memory Interfacing
• Generally µP 8085 can address 64 kB of memory .
• Generally EPROMS are used as program memory and RAM as
data memory.
• We can interface Multiple RAMs and EPROMS to single µP .
• Memory interfacing includes 3 steps :
1. Select the chip.
2. Identify register.
3. Enable appropriate buffer.
8085 Memory Interfacing
•In this example we saw that some address lines are used for
interfacing while others are for decoding.
•It is called absolute decoding.
•We sometimes don’t requires that many address lines.So
we ignore them.But this may lead to shadowing or multiple
address.
•This type of decoding is called linear decoding or partial
decoding.
•In partial decoding wastage of address takes place but it
requires less hardware and cost is also less as compared with
absolute one.
Memory structure & its requirements
ROM
Data Lines
RAM
Input Buffer WR
Address CS
Lines
Address CS
Lines
Output Buffer RD
Output Buffer RD
Date
Lines
Data Lines
A15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 ADD
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 8000H
1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 87FFH
8085 Memory Interfacing
• Address lines A0-A10 are used to interface memory while
A11,A12,A13,A14,A15 are given to 3:8 Decoder to provide an
output signal used to select the memory chip CS¯or Chip
select input.
• MEMR¯ and MEMW¯are given to RD¯and WR¯pins of Memory
chip.
• Data lines D0-D7 are given to D0-D7 pins of the memory chip.
• In this way memory interfacing can be achieved.
8085 Memory Interfacing
• The diagram of 2k interfacing is shown below:
3:8DECODER
A15- A11
8085
CS
A15-A8
ALE
A10- A0 2K Byte
Latch Memory
AD7-AD0 A7- A0 Chip
WR RD IO/M D7- D0
RD WR
8085 interfacing with I/O Devices
Microprocessor need to Identify I/O devices with binary number.
*
Memory Mapping Vs Peripheral
I/O
*
Peripheral I/O Instructions
Instruction IN (code DB) inputs data from an input device into accumulator.
Instruction OUT (code D3) sends the content of the accumulator to output
device such as LED display.
Opcode Operand Description
OUT 8-bit Port address 2-byte instruction with hexadecimal
instruction D3 and Second byte is port
number of output device.
Memory Machine Code Mneumonics
Address
2050 D3 OUT 01
2051 01
*
OUT Instruction
*
•
OUT Instruction
In First Machine cycle M1(Opcode Fetch), microprocessor places the 16-bit memory
address from the program counter (PC) on the address bus. At T1 20H is placed on A15-
A8 and 50H is placed on AD7-AD0. ALE goes high, IO/M’ goes low indicates memory
related operations. ALE indicates the availability of the address on AD7-AD0. At T2
microprocessor sends RD’ control signal which is combined with IO/M’ to generate
MEMR’ signal and processor fetches the instruction code D3 using data bus.
• M2 (memory Read), 8085 places next address 2051H on address bus and get device
address 01H.
• M3 (I/O write), 8085 place device address 01H on low and high address bus
both.IO/M’ goes high to indicate I/O operation. At T2 AC contents are placed on data bus
followed by control signal WR’. If we connect data bus to latch we can catch the
information and display on LEDs and Printer. By ANDing IO/M’ and WR’ signals IOW’
signal enable output device.
*
IN Instruction
• In First Machine cycle M1 (Opcode Fetch), microprocessor places the 16-bit
memory address from the program counter (PC) on the address bus. At T1 20H is
placed on A15-A8 and 65H is placed on AD7-AD0. ALE goes high, IO/M’ goes
low indicates memory related operations. ALE indicates the availability of the
address on AD7-AD0. At T2 microprocessor sends RD’ control signal which is
combined with IO/M’ to generate MEMR’ signal and processor fetches the
instruction code DB using data bus.
• M2 (Memory Read), 8085 places next address 2066H on address bus and get
device address 84H.
• M3 (Memory Read), 8085 place device address 84H on low and high address
bus both and asserts RD’ signal. IO/M’ goes high to indicate IO operation. At T2
data from input port are paced on data bus and transferred to AC. By ANDing
IO/M’ and WR’ signals IOR’ signal to enable input port.
*
Data Transfer
For data transfer from input device to processor the following operations
are performed.
•The input device will load the data to the port.
•When the port receives a data, it sends message to the processor to read the
data.
•The processor will read the data from the port.
•After a data have been read by the processor the input device will load the
next data into the port.
For data transfer from processor to output device the following operations
are performed.
•The processor will load the data to the port.
•The port will send a message to the output device to read the data.
•The output device will read the data from the port.
•After the data have been read by the output device the processor can load the
next data to the port.
*
Device Selection and Data
Transfer
Steps are summarized as:
•Decode the address bus to generate unique pulse corresponding to device address on
the bus called device address bus or I/O address pulse.
•Combine the device address pulse with the control signal to generate a device select
pulse(I/O select) that is generated only when both signals are asserted.
•Use the I/O select pulse to activate interfacing device(I/O port).
Figure: Practical decoding circuit for the output device with address 01H
• Address lines A7-A0 are connected to 8-input NAND gate that functions as
decoder (A0-Directly connected; A7-A1 with inverters).
• When Address bus is carries 01H, gate G1 generated a low pulse otherwise
output remain high.
• G1 and G2 are combined to generate I/O select pulse which clocks data (AC
content on data bus available for few microsecond) into latch for display by
LEDs.
*
Absolute Vs Partial Decoding
• All eight lines are decoded to generate one unique pulse called absolute
decoding like device will be selected only with the address 01H(good design
practice).
• To minimize the cost, the output port can be selected by decoding some
address lines called partial decoding (device has multiple addresses).
• A1 and A0 are at don’t care logic level so output port can access by address
00, 01, 02 and 03(commonly used techniques in small systems).
• Address lines are high(FFH), output of NAND gate goes low which is
combined by control signal IOR’ which generates Device Select Pulse.
• First Step is to decode the address bus using 3x8 Decoder and 4-input NAND
gate. A0 to A2 are used as input and remaining A3 to A7 are used to enable
decoder.
• Second step is to decode address with appropriate control signal (IOR’/IOW’)
output will generate select pulse.
• Third step is to use this pulse to enable I/O port (pulse enables LED latch with
the output port address F8H similarly input buffer is enable with address FAH).
Input Interfacing
Decode logic for a Dip-Switch Input Port
Interfacing I/O Using Decoders
Seven segment LED interfacing
Interfacing DIP switches
Memory Mapped I/O
• Instead of using 8-bit address, the full 16-bits of
the address bus must be used.
• Instead of using IORD and IOWR, use MEMR
and MEMW.
• To transfer data Memory Related Instructions
such as LDA(Load AC Direct transfers data from
memory to Accumulator), STA (Store contents of
AC into Memory)are used.
• IN STA 8000H output device instead of a
memory Register is connected to the address, so
that accumulator contents will be transferred to
output device.
Memory Mapped I/O
• IN LDA 8000H accumulator receives data from input
device rather than Memory.
Execution of Memory Related data Transfer Instruction STA 8000H
Memory mapped I/O interfacing