Professional Documents
Culture Documents
S
1
S
0
Opcode Fetch 0 1 1
Memory Read 0 1 0
Memory Write 0 0 1
I/O Read 1 1 0
I/O Write 1 0 1
Interrupt
Acknowledge
1 1 1
Halt Z 0 0
This fig. shows the programming model of
8085.
- It is what the available resources
programmer has.
- Which can be use to write a program.
M B Rajpara 8085 Microprocessor (A vade mecum) 6
www.vidyanuragi.wordpress.com
Architecture of 8085
A. Registers
Microprocessor use these while operation on data. To interact with the microprocessor data
should be loaded in the registers. They are typed in :
a. General purpose registers (B, C, D, E, H , L)
- They are 8 bit reg. and we can also use them in pair of 16 bit (ex. BC, DE, HL).
- HL pair is takes as M in instruction and it also called scratchpad registers (high speed internal
memory used for temporary storage of preliminary information) sometime.
b. Temporary registers
- In ALU has two inputs, one is supplied from Accumulator and another is from temp. register (It
is not accessible by programmer)
- W and Z are also temp. reg. used by ALU of microprocessor.
c. Special purpose registers
- Register A(accumulator), after the execution of the logical or arithmetic instruction the result is
rests in this register.
- Flag registers
M B Rajpara 8085 Microprocessor (A vade mecum) 7
www.vidyanuragi.wordpress.com
D
7
D
6
D
5
D
4
D
3
D
2
D
1
D
0
S Z AC P CY
.
- Instruction register
CPU fetches the opcode of the instruction and stores it to the instruction reg.
- PC Program Counter
It keeps track on how many instructions are executed. It's 16 bit reg.
- SP Stack Pointer
It is used to hold the address of the most recent stack memory. It is 16 bit reg.
B. ALU (Arithmetic Logic Unit)
It performs arithmetic and logical functions on 8 bit data.
C. Instruction decoder and Machine Cycle encoding.
It decodes the opcode from Instruction reg. and control register, data buffers, ALU and other signals with
use of timing and control signals.
D. Buffer
a. Address buffer: 8 bit unidirectional buffer, which drives higher order address bus (A
15
-A
8
)
b. Address/Data buffer: 8 bit bi-directional buffer, which drives lower order address bus (A
7
-A
0
) and
Data bus (D
7
-D
0
).
E. Address Latch
16 bit reg., used to work out with PC and SP reg.
F. Timing and Control Circuit
It helps 8085 to synchronies with other peripherals with the use of clock signal. It is main circuit which
controls the operations.
G. Interrupt Control
Whenever we want to work out with the interrupt this control circuit comes in fore to control the signals
for interrupt.
H. Serial I/O Control Circuit
It handles two line SOD(Serial Output Data) and SID (Serial Input Data).
S Sign Flag : set 1 if
the result is negative.
Z Zero Flag :
set 1 if result is
zero.
AC Auxiliary Carry /
Adjust Flag : Indicates
decimal carry. Carry out bit
3 to bit 4 of the result. Set 1
if result carry from LSB to
MSB. Only work in BCD.
P Parity : set 1 if the
result contains even
number of 1s.
CY Carry Flag: set 1 if
overflow happens (out of
bit 7)
M B Rajpara 8085 Microprocessor (A vade mecum) 8
www.vidyanuragi.wordpress.com
Cycles and Operations
- Instruction Cycle: The time required to complete the execution of an instruction.
All instructions are divided into a few basic machine cycles and these machine cycles are divided in
into some precise system clock periods /T-States.
- Machine Cycle: The time required to complete one operation of accessing memory, I/O, or
acknowledging the external request.
- T-State: One subdivision of the operation performed in one clock period.
Each T-State is equal to one clock period.
Execution of any instruction done in three steps:
a. Check the memory location by its address, with the use of address bus
b. Get the data from that memory address, with the use of data bus
c. Control a. and b. step with control and timing signals.
All of the operations of the microprocessor can be classified into one of three types:
- Microprocessor Initiated Operations
- Internal Operations
- Peripheral Initiated Operations
It is important to note that the microprocessor treats memory and I/O devices the same way.
o 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.
o The communication process between the microprocessor and peripheral devices consist of the
following three steps:
- Identify the address.
- Transfer the binary information.
- Provide the right timing signals.
Here the
1. Opcode Fetch Machine Cycle.
- In every execution of instruction, the first operation is
always Opcode Fetch Cycle. It fetches the machine
code from memory.
- This cycle takes 4 or 6 T-states in execution. The first
three T-states are used for fetching the opcode from
memory and the remaining T-states are used for
internal operations by the processor.
- It is as similar to memory read cycle; the difference is
in status signal. For opcode fetch the signal is
I0N
=0, S
1
=1, S
0
=1.
M B Rajpara 8085 Microprocessor (A vade mecum) 9
www.vidyanuragi.wordpress.com
2. Read or Write Machine Cycle.
[Memory 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 control signals are [I0N
=0, S
1
=1, S
0
=0]
- 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.
[Memory Write Operation]
- As you can see in the figure, it is same as read operation, but the difference is in signals and line of
transfer. In this signals are [ I0N
=0, S
1
=0, S
0
=1 ]. And the data will transfer from microprocessor to
memory.
- The control signal will enable the chip select logic and write will be performed.
[I/O Read Operation]
- It is executed by the MPU to read a data byte from I/O port or from the peripheral which is I/O
mapped in the system.
- It is almost similar as memory read cycle.
- It takes 3 T-state to in execution.
[I/O Write Operation]
- It is executed by the MPU to write data byte in the I/O port or a peripheral which is I/O mapped in
the system.
- It is almost similar as memory write cycle.
- It takes 3 T-state to in execution.
M B Rajpara 8085 Microprocessor (A vade mecum) 10
www.vidyanuragi.wordpress.com
Machine cycles T-States
Opcode fetch 4 / 6 T
Read or Write [Memory or I/O] 3 T
Interrupt Acknowledge 6 / 12 T
Bus Idle 2 / 3 T
M B Rajpara 8085 Microprocessor (A vade mecum) 11
www.vidyanuragi.wordpress.com
Interfacing & Data Transmission Techniques
The data transfer schemes are broadly classified into two categories:
Microprocessor Controlled Data Transfer / Programmed Data Transfer
Data transfer takes place under the control of a program which resides in the main memory of the
system. It is relatively slow and applied for cases when the number of bytes of data is small. This scheme
is suitable for relatively slow peripherals.
Programmed data transfer scheme is sub-divided into the following:
A. Synchronous mode of data transfer.
Used when peripherals timing characteristics is precisely known. In this mode the status of the
device is not checked before undertaking any data transfer (the device is assumed as always ready
for data transfer). This is simplest amongst all other methods and minimum overhead in terms of
hardware/software is needed to implement this scheme.
B. Asynchronous mode of data transfer.
The device (peripheral) status is checked by the CPU before undertaking data transfer. This
mode is used when the timing characteristics of the device is unpredictable. In this mode, the CPU
confirms the readiness of the device status before undertaking data transfer. This is why this scheme
is known by the name handshaking I/O.
Handshake singles prevent the processor from reading the same data more than once, from a
slow device, and from writing new data before the device has accepted the previous data.
C. Interrupt driven mode of data transfer.
When a peripheral is ready for data transfer, it interrupts the processor by sending an appropriate
interrupt signal to the processor. If the processor accepts the interrupt then the processor suspends its
current activity and executes an interrupt service subroutine to complete the data transfer between
the peripheral and processor. After executing the interrupt service routine the processor resumes its
current activity. This type of data transfer scheme is called Interrupt Driven Data Transfer Scheme
This mode is used for data transfer with slow peripherals and also when the occurrence of data is
unpredictable in nature.
It is further divided into two categories:
Polled Interrupt
- It is used when many devices are connected to the system.
- MPU check whether data is available from peripheral in a continuous looping. Its called
polling, because it checks the status time by time.
- Each device is tested, using either hardware / software, until the device which has
requested the interrupt, is identified. (If testing is done by Hardware then its call Hardware
polling, and if it is by written code then it calls Software polling)
- Corresponding to the device thus identified, the program is then diverted to the ISS written
for that device.
Vectored Interrupt
- In the vectored interrupt scheme the requesting device causes the program to be branched
to the ISS (Interrupt Service Subroutine) straightway.
- In general, vectored interrupt schemes are faster than polled interrupt schemes.
Note:
In the asynchronous mode of data transfer scheme it is the processor which goes on checking the device
status; in the interrupt driven mode of data transfer scheme it is the device which interrupts the system.
In polled interrupt scheme (whether hardware/software) the priority of each device is fixed (by the
programmer). It will take time before the interrupting device is identified.
M B Rajpara 8085 Microprocessor (A vade mecum) 12
www.vidyanuragi.wordpress.com
Peripheral Controlled Data Transfer / Direct Memory Access (DMA) transfer.
In DMA mode, straight data exchange takes place between memory and I/O device bypassing the
processor. This is done with the help of a DMA controller. In DMA mode, the DMA controller acts as a
Master and the processor as a Slave.
The processor must have the following features to facilitate DMA mode of data transfer:
- An input line through which the processor accepts request from DMA controller for DMA mode of
data transfer (This is the HOLD pin for 8085).
- An output line through which the processor tells the DMA controller that it (processor) has accepted
the request (This is the HLDA pin for 8085)
- The processor must tri-state its AB, DB and necessary control lines before handing over the control
to the DMA controller.
The DMA controller IC must have the following features:
- An output line through which it requests the processor for DMA mode of data transfer.
- An input line through which it accepts the granted DMA request
Interfacing
The functions needed for peripheral interfacing are:
Buffering, Address decoding, Command decoding, and timing & control
- Buffering is necessary to increase drive and also to synchronize data exchange between the
microprocessor and peripheral.
- Address decoding helps to select particular I/O.
- Command decoding is needed for some special I/Os that perform jobs other than data transferse.g.
rewinding a tape drive.
- For coordinating the above three, timing & control is needed.
Problems in interface I/O device with a processor:
- Speed Incompatibility: In many cases the I/O devices are slower than the processor so that a situation
may arise when the processor is in a position to accept data but the peripheral dont.
- Format Incompatibility: If a 12/16-bit ADC/DAC is tried to be interfaced with an 8-bit MPU.
- Electrical Characteristic Incompatibility: Due to current or voltage incomparability or both.
It is relatively easy to interface a memory with a processor because memories are usually
manufactured with the same technology as those of the CPUs and they are compatible to the CPUs with
regard to speed and electrical compatibility.
Address Space and its partitioning.
- Address space is a set of all possible addresses that a microprocessor can generate.
- 8085 MPU has a 16-bit address bus so that it can address 216 or 64 KB of address, called the address
space of 8085. This total address space can be partitioned / allocated to memory or I/O devices so that
they can be addressed properly; its calls address space partitioning.
- The address space can be partitioned in two scheme / ways:
a. Memory mapped I/O scheme
In this, there is only one address space, which is allocated to both memory and I/O devices, in
some degree.
The address for I/O devices is different from the addresses which have been assigned to
memories. An I/O device is also treated as a memory location.
Each memory location and I/O device are assigned with separate addresses.(different to all)
In this, I0N
signal is not used to distinguish between memory and I/O devices. An I/O device
is interfaced in the same manner as a memory device.
All data transfer instructions of the microprocessor can be used for transferring data from and
to either memory or I/O devices.
M B Rajpara 8085 Microprocessor (A vade mecum) 13
www.vidyanuragi.wordpress.com
This scheme is suitable for small systems.
b. I/O mapped I/O scheme
Some MPUs provide more control lines, the status of which indicates either memory or I/O
operation.
The status of I0N
indicates I/O operation or memory operation. In this case, the same address
may be assigned to both, memory or an I/O device.
Here two separate address spaces exist; one space is meant exclusively for memory operations
and the other for I/O operations. Usually, the space earmarked for I/O is much smaller than
memory space.
Memory Mapped I/O I/O Mapped I/O
1 Address length is 16-bit. Address length is 8-bit.
2
MEMR & MEMW signals are used to control
read and write I/O operations respectively.
IOR & IOW signals are used to control read and
write I/O operations respectively.
3
Each I/O device is treated like a memory
location and they are accessed using
instructions related to memory operations.
IN and OUT are the only available instructions.
4
Data transfer takes place between any register
and I/O device.
Data transfer takes place between accumulator
and I/O device.
5
Maximum number of I/O devices that can be
addressed is 65536 (theoretically).
Maximum number of I/O devices that can be
addressed is 256.
6
Execution speed Using STA, LDA it is 13 T-
state. And for MOV M, r, etc., it is 7-T states.
Execution speed is 10 T-states, for both IN and
OUT.
7
Decoding 16-bit address will require more
hardware circuitry.
Decoding 8-bit address will require less
hardware circuitry.
8 Used when memory requirement is small. Used when whole big memory is required.
Microprocessor can communicate (read or write) with only one device at any given instant. Because
the data, address and the control bus for all the devices connected to the microprocessor are common. Thus
to communicate properly with a device (memory or I/O), decoding of address is a must required. Thus
address decoding pinpoints a particular memory location or I/O.
Two kinds of address decoding techniques: a. Absolute (Full decoding) b. Linear (Partial decoding)
Absolute (Full Address Decoding) Linear (Partial Address Decoding)
1 Used in large memory systems Used in small memory systems.
2 All higher order address lines are decoded
to select the memory or I/O device.
A few high order address lines are utilized to select
individual memory or I/O chips.
3 Decoding logic requires more hardware. Hardware requirement for decoding is very small
and not required in very small dedicated systems.
4 No multiple addresses Suffers from the drawback of multiple addresses (It
calls Shadow Addresses).
5 Higher cost of decoding Lesser cost of decoding.
6 Memory expansion is easier. Memory expansion is difficult.
7 No bus contention problem May bus contention problem (occur if more than one
memory chip gets selected because of wrong address
generation.)
M B Rajpara 8085 Microprocessor (A vade mecum) 14
www.vidyanuragi.wordpress.com
Interrupts
Interrupt is a signal sends by an external device to the processor, to perform a particular task. Mainly
in the microprocessor based system the interrupts are used for data transfer between the peripheral and the
microprocessor.
EI Use this instruction to enable the interrupt.
DI Use this instruction to disable the interrupt.
INTR Microprocessor checks the status of this signal time by time
during the execution of the program. If signal goes high, it
shows that interrupt occur.
INTA
: Strobe Input, is a signal generated by input device to inform the CPU that data to be read is
already sent on the port lines of 8255. So 8255 loads the data in to input buffer of appropriate port
from its port lines.
- IBF: Input Buffer Full, is a acknowledgement signal (in response to SIB
: Output Buffer Full, is a signal generated by MPU to inform the input device that data is sent
from output latch of MPU. This signal goes high after receiving the ACK
SIAIuS
= 0
D3: 1- Select counter 2 RB
= 1
D2: 1- Select counter 1 WR
= 0
D1: 1- Select counter 0
D0: Reserved for Future Expansion; Must be 0
Fig: Read Back Command Format
READ BACK command allows the user to read the count and the status of the counter. The
command is written in the control register, and the count of specified counter can be latched if C0uNI
is
0. This command eliminates the need of writing separate latch commands for different counters.
M B Rajpara
8259A Programmable Interrupt Controller
Features / Boasts:
Can manage eight priority interrupts
equivalent to providing 8 interrupt pins on processor in place of INTR pin.
8259 can be cascaded to have 64 levels of vectored priority interrupts in a microprocessor system.
The priority modes can be changed or reconfigured dynami
It can be operated in various interrupt modes
8259 supports both edge and level triggered mode of interrupts.
The CALL address can be programmed to have a
The data bus is buffered.
8259 can be used with either 8080/8085 or 8086/8088 microprocessor.
The AEOI (Automatic End
- PIC 8259 can accept a maximum of 8 interrupts from 8 differen
regard to servicing the interrupts and issues an INT output signal, which is connected to INTR input pin.
- PIC 8259 has four different functional blocks.
1. Interrupt and Control logic block
This block consists of
(b) In Service Register (ISR)
(d) Interrupt Mask Register (IMR)
2. Data bus buffer
3. Read/Write control logic block
4. Cascade buffer/comparator section.
- 8259 can be operated through OCW (Operation Comman
In the following four categories of
1. Fully Nested Mode (FNM)
This mode is a default mode (auto
IR0 is assigned the highest priority and IR7 the lowest priority (priority 7).
When 8259 acknowledges an interrupt request via its INTR pin, it finds out the highest priority
and the corresponding bit in the ISR (Interrupt Service Register).
It is further enhanced with, Special Full Nested Mode
interrupt request. Because the FNM
8085 Microprocessor (A vade mecum)
www.vidyanuragi.wordpress.com
8259A Programmable Interrupt Controller (PIC)
Can manage eight priority interrupts according to the instruction written in it
equivalent to providing 8 interrupt pins on processor in place of INTR pin.
8259 can be cascaded to have 64 levels of vectored priority interrupts in a microprocessor system.
The priority modes can be changed or reconfigured dynamically at any time during the main program.
It can be operated in various interrupt modesfully nested, rotating priority, special mask and polled.
8259 supports both edge and level triggered mode of interrupts.
The CALL address can be programmed to have a spacing of either 4 or 8 memory locations.
8259 can be used with either 8080/8085 or 8086/8088 microprocessor.
The AEOI (Automatic End of Interrupt) can be programmed.
PIC 8259 can accept a maximum of 8 interrupts from 8 different I/O devices, resolves the priority with
regard to servicing the interrupts and issues an INT output signal, which is connected to INTR input pin.
ifferent functional blocks.
Interrupt and Control logic block
consists of: (a) Interrupt Request Register (IRR)
(b) In Service Register (ISR) (c) Priority Resolver
(d) Interrupt Mask Register (IMR) (e) Control Logic Block.
ad/Write control logic block
Cascade buffer/comparator section.
ed through OCW (Operation Command Word).
categories of Interrupt Modes:
(FNM):
This mode is a default mode (auto-set after initialization).
IR0 is assigned the highest priority and IR7 the lowest priority (priority 7).
When 8259 acknowledges an interrupt request via its INTR pin, it finds out the highest priority
and the corresponding bit in the ISR (Interrupt Service Register).
enhanced with, Special Full Nested Mode (SFNM): It supports the cascading systems
interrupt request. Because the FNM acknowledge only one interrupt at a time
32
according to the instruction written in its control register. It is
8259 can be cascaded to have 64 levels of vectored priority interrupts in a microprocessor system.
cally at any time during the main program.
fully nested, rotating priority, special mask and polled.
spacing of either 4 or 8 memory locations.
t I/O devices, resolves the priority with
regard to servicing the interrupts and issues an INT output signal, which is connected to INTR input pin.
(a) Interrupt Request Register (IRR)
(e) Control Logic Block.
IR0 is assigned the highest priority and IR7 the lowest priority (priority 7).
When 8259 acknowledges an interrupt request via its INTR pin, it finds out the highest priority
It supports the cascading systems
interrupt at a time from the same level,
M B Rajpara 8085 Microprocessor (A vade mecum) 33
www.vidyanuragi.wordpress.com
after that it disable from that line. The SFNM supports one more interrupt request from slave after
acknowledging the request of master in cascading system.
2. Rotating Priority Mode: it is categorized in two parts.
A. Automatic Rotation
When a peripheral is serviced, all other equal priority peripherals should be given a chance
to be serviced before the original peripheral is serviced a second time around.
This is accomplished by automatically assigning a peripheral the lowest priority after
being serviced. Thus a device, presently being serviced, would have to wait until all other
devices are serviced.
Automatic rotation is further categorized in two types:
(a) Rotate on non-specific EOI Command.
(b) Rotate on automatic EOI Mode.
B. Specific Rotation.
In this mode, after the service of peripheral; the user can be assigned any of the IR levels
(between 0 and 7) for the lowest priority by specifying OCW2 by user.
This mode is independent of EOI command.
3. Special Mask Mode:
This mode enables interrupts from all levels except the level presently in service. Its done
by masking the level that is in service and then issuing the special mask mode command and this
mask remains in effect until reset.
4. Polled Mode:
In this the interrupting devices seeking services from 8085 are polled one after another to
detect which device issued interrupt request.
- EOI (End of Interrupt) Command:
This command updates the ISR bit of service, after the completion of that particular interrupt service.
In the cascade mode (two ICs are Interfaces with each other), the EOI command must be issued twice
(one for master IC and one for slave IC).
It has three formats:
A. Automatic EOI: Automatically done by 8259 PIC. (Ex. In FNM mode.)
B. Non-Specific EOI Command: Resets the highest priority ISR bit.
C. Specific EOI Command: Specifies which ISR bit to reset.
- 8259 is programmed and initialized by a set of four ICW (Initialization Command Words).
ICWs (ICW1, ICW2, ICW3, and ICW4) perform the following jobs:
Specifying the vectoring addresses for the individual interrupts.
Specifying single or cascaded mode of operation.
Level or edge triggering mode of operation.
- Operation Sequence for programming 8259
1. Write ICW1.
2. Write ICW2.
3. If not in the cascade mode of operation, go to Step 5.
4. Write ICW3.
5. IF ICW4 is not needed, then go to Step 7.
6. Write ICW4.
7. Ready to accept interrupts sequence.
M B Rajpara 8085 Microprocessor (A vade mecum) 34
www.vidyanuragi.wordpress.com
8237 DMA Controller
Features / Boasts:
It is a 4-channel interface, which allows data transfer between memory and up to 4 I/O devices,
bypassing CPU.
A maximum of 16 KB of data can be transferred by DMA sequentially at a time.
Initialization of the DMAC is done under program control for each channel.
DMAC can be operated in three modes:
DMA Read (reading from memory, writing into peripheral)
DMA Write (writing into memory, reading from peripheral)
DMA verify.
Priority for each of the 4 channels can be set in (a) fixed priority, (b) rotating priority.
A Terminal Count Register exists for each of 4 channels. The number of bytes of data to be transferred
is stored in the D
13
D
0
positions of the 16-bit Terminal Count Register.
Initialization of DMA: Its done by MPU
By loading the starting address of a DMA block for an I/O device in the 16-bit address register.
By loading D
13
D
0
bits i.e., lower 14-bits of Terminal Count Register (TCR) with the number of
bytes of data to be transferred.
By loading D
15
and D
14
of TCR appropriately to set the mode of operation of 8257.
By loading the Mode Set Register appropriately.
Two classes of to data transfer in DMA:
Sequential DMA: In this, the DMA controller reads a data byte from memory and then writes the same
into I/O or vice-versa. For each of these read or write operations, 2 to 4 CLK cycles are required.
Simultaneous DMA: It is the fastest transfer process. Here Read and Write operations are performed at
the same time. Thus both HEHR
& I0w
(or I0R
& HEHw