Professional Documents
Culture Documents
Micro Lecture 4
Micro Lecture 4
Timings
Microprocessor includes
158 different instruction types.
Each instruction has two parts:
Operation code (known as opcode) and operand.
Instruction Cycle
Machine Cycle
The time required to complete one operation of
accessing memory, accessing I/O, or acknowledging
an external request. This cycle may consist of three
to six T-states.
T-state
One subdivision of operation performed in one clock
period. These subdivisions are internal states
synchronized with the system clock and each Tstate is equal to one clock period.
01000111 (47H)
Copy A into B
LD B, A
23
50
Address
2003H
memory
Accumulator
9F
Machine Code
01110111 (77H)
Instruction
Comment
stored in HL
Memory
Interfacing
Interfacing Memory
Interfacing Memory
To read from the addressed register, the
should be asserted low to enable the
output buffer, and then the data byte
from the register will be placed on the
I/O lines.
Function of Interfacing :
To allow the microprocessor to read from
and write into a given register of a
memory chip
To perform these operations, the
microprocessor should
be able to select the chip
identify the register
enable the appropriate buffer.
Address Decoding
Identifying a register with a given address
We should be able to generate a unique pulse for that
address
goes low (active) only when the address on the
Using a gate :
address lines is F7H . No other address can
cause the output of the gate to go low. This
process is called decoding the address.
Address ranges may differ due to the do not care at A12 and A11
Assume A12 and A11 are zero
Memory Map
The entire memory
addresses can range
from 0000H to
FFFFH.
Memory map is like
a pictorial
representation in
which memory
devices are located
in the entire range
of addresses.
Interfacing logic
defines the memory
map.
Example
Reading Assignment
Please Read
Chapter 3
Chapter 4
I/O Interfacing
Interfaced through:
Peripheral mapped I/O : Each device has a 8-bit
address and enabled by I/O related control signals
Memory mapped I/O : Each device has a 16-bit
address and enabled by memory related control
signals
Example 1: Interfacing
LEDs74LS373 Octal Latch
Hardware:
7475 Latch
4 D-Latches
2 enable lines
Latch followed by
tri-state buffer
Reduces loading on the
data bus at the output
8 latches instead of 4
Example 1: Interfacing
LEDs
Port address of the latch: 07H
When Q is high it can supply (source)
0.4 mA, and when it is low, it can sink
16 mA. Since LEDs require 10-15 mA
current to be illuminated, they are
connected to output of the latch.
When the input is high the LED is
turned on.
Instructions:
To display data for example, 97H at
this LED port instructions are:
LD A,97H
OUT (07H),A
Example 2: Using a
Seven-Segment LED as a
Display Device
IN Instruction - Example
IN instruction:Read (copy) data from such input
devices as switches, keyboard, and A/D data
converters.
Can read an input device and place the data into the
accumulator, Z80 registers, or memory registers.
Example:
IN Instruction - Example
First read the machine codes stored at locations
2065H and 2066H,
Read the switch positions at port 84H by enabling
the interfacing device of the port.
The data byte indicating switch positions from the
input port will be placed in the accumulator.
Execution of IN Instruction
andcycles:
Timing
The IN has three machine
Opcode Fetch,
active low
.
When it is low, input data appears on the output
lines, when it is high, the output goes to high
impedance state.
Instructions:
To read data from the input port,
the instruction
IN A,(84H)
can be used.
Solution
Instructions:
LD HL,(0100H)
LD A,L
LD (2000H),A
LD A,H
LD (2800H),A
Solution
OUTPUT
PORT
80H
INPUT
PORT
82H
Instructions:
IN A,(82H)
OUT (80H),A
Reading Assignment
Please Read
Chapter 5