Microprocessor Complete
Microprocessor Complete
MYcsvtu Notes
Introduction to Microprocessors
MYcsvtu Notes
What is a microprocessor?
A microprocessor is a programmable digital electronic
component that incorporates the functions of a central processing unit or CPU on a single semi conducting integrated circuit.
MYcsvtu Notes
What is a microprocessor?
That means your laptop at home and the PC in your
computer lab!
The advent of the microprocessor astounded many
people.
It was an entire computation engine on one tiny chip.
MYcsvtu Notes
Going from the ENIAC which filled an entire room and used over 18,000 vacuum tubes to a 1/8th by 1/6th of an inch (fingernail size) mega chip!
MYcsvtu Notes
were in the 4004, which had 2,300 transistors when it was introduced in 1971.
MYcsvtu Notes
The Intel 4004 microprocessor circuit line width was 10 microns or 10,000 nanometers. Today Intel's microprocessors have circuit line widths of .065 microns or 65 nanometers. A nanometer is one billionth of a meter. By comparison, a human hair is approximately 100 microns or 100,000 nanometers.
MYcsvtu Notes
initially and then on 3" wafers. Today's microprocessors are produced on 12" or 300mm wafers.
MYcsvtu Notes
not the smallest, it is one of the smallest microprocessor designs that ever went into commercial production.
The 4004 microprocessor is composed of 5 layers.
MYcsvtu Notes
10
Intel 4004
MYcsvtu Notes
11
are all familiar with today, is given most of the credit for inventing the first microprocessor (Intel 4004).
MYcsvtu Notes
12
Three Intel engineers named Federico Faggin, Ted Hoff and Stan Mazor are said to be the brilliant minds behind the microprocessor.
MYcsvtu Notes
13
from 32 bits to 4 bits so that the transistors of its logic circuits would fit onto a single part.
typically made of big discrete switching devices containing only a few transistors.
MYcsvtu Notes
14
MYcsvtu Notes
15
MYcsvtu Notes
16
paved the way for embedding intelligence in inanimate objects as well as the personal computer.
MYcsvtu Notes
17
Applications of microprocessors
Without this amazing invention, we would not be as
technologically advanced in computers as we have become today. Embedded intelligence brought by microprocessors
MYcsvtu Notes
18
MYcsvtu Notes
19
Automation
MYcsvtu Notes
20
Communication
MYcsvtu Notes
21
MYcsvtu Notes
22
12 bit address bus (multiplexed). Separate address space for instructions and data (Harvard architecture).
MYcsvtu Notes
23
Compatibility Intel i4004 CPU with extra features: more instructions, interrupt support.
MYcsvtu Notes
25
12 bit address bus (multiplexed). Separate address space for instructions and data (Harvard architecture).
MYcsvtu Notes
26
MYcsvtu Notes
27
MYcsvtu Notes
28
14 bit address bus (multiplexed). Separate address space for instructions and data (Harvard architecture).
Clock speed300 kHz
MYcsvtu Notes
29
MYcsvtu Notes
30
16 bit address bus. Separate address space for instructions and data (Harvard architecture). Physics Packaging: 40 pin CerDIP. Introduction date: April 1974.
MYcsvtu Notes
32
Generation Generation: 8080. Compatibility Intel i8080 CPU upward instruction compatible.
MYcsvtu Notes
33
Extra instructions: SIM (Set Interrupt Mask) RIM (Read Interrupt Mask) Extra interrupt lines, including NMI (Non-Maskable Interrupt).
MYcsvtu Notes
34
16 bit address bus. Data and address bus are multiplexed. Separate address space for instructions and data .
MYcsvtu Notes
35
3 MHz
Intel I8085a Intel iM8085A Intel i8085AH-2 Intel i8085AH-1 Intel iM8085AH
5 MHz 6 MHz
MYcsvtu Notes
36
Major designers
Intel Advanced Micro Devices (AMD) IBM Microelectronics AMCC Freescale Semiconductor ARM Holdings
MYcsvtu Notes
37
Major designers
MIPS Technologies Texas Instruments Semiconductors Renesas Technology VIA Technologies Western Design Center STMicroelectronics Sun Microsystems CPU Tech
MYcsvtu Notes
38
MYcsvtu Notes
39
CPU (central processing unit) ALU (arithmetic-logic unit) Control Logic Registers, etc Memory Input / Output interfaces
MYcsvtu Notes
40
MYcsvtu Notes
41
Basic definitions
Bus: A shared group of wires used for communicating signals among devices address bus: the device and the location within the device that is being accessed data bus: the data value being communicated control bus: describes the action on the address and data buses
MYcsvtu Notes
42
Basic definitions
Memory: Where instructions (programs) and data are stored Organized in arrays of locations (addresses), each storing one byte (8 bits) in general A read operation to a particular location always returns the last value stored in that location
MYcsvtu Notes
43
Basic definitions
MYcsvtu Notes
44
Basic definitions
Semiconductor Memories are classified according to
the type of data storage and the type of data access mechanism into the following two main groups:
Memory (ROM) which retains information when the power supply voltage is off. With respect to the data storage mechanism NVM are divided into the following groups:
MYcsvtu Notes
45
Basic definitions
Mask programmed ROM. The required contents of
is written in a permanent way by burning out internal interconnections (fuses). It is a one-off procedure.
MYcsvtu Notes
46
Basic definitions
Erasable PROM (EPROM). Data is stored as a charge
on an isolated gate capacitor (floating gate). Data is removed by exposing the PROM to the ultraviolet light. Electrically Erasable PROM (EEPROM) also known as Flash Memory. It is also based on the concept of the floating gate. The contents can be re-programmed by applying a suitable voltages to the EEPROM pins.
MYcsvtu Notes
47
Basic definitions
Read/Write (R/W) memory, also known as Random
Access Memory (RAM). From the point of view of the data storage mechanism RAM are divided into two main groups:
power supply on.
MYcsvtu Notes
48
Basic definitions
I/O devices: Enable system to interact with the world. Interface between the computer and other peripherals or human.
MYcsvtu Notes
49
Basic definitions
Can be classified by: Type of data stream: Serial or parallel Type of interaction with the processor: Programmed I/O, Interrupt Driven, or DMA Type of connection to the processor: Memory-mapped I/O or I/O-mapped I/O
MYcsvtu Notes
50
components
MYcsvtu Notes
51
8085 Microprocessor-Features
The Intel 8085 microprocessor is an NMOS 8-bit device. Sixteen address bits provide access to 65,536 bytes of
8 bits each.
MYcsvtu Notes
52
8085 Microprocessor-Features
Control is provided by a variety of lines which support
memory and I/O interfacing, and a flexible interrupt system. The 8085 provides an upward mobility in design from the 8080 by supporting all of the 8080s instruction set and interrupt capabilities. It requires only a 5 volt supply. In addition, the 8085 is available in two clock speeds.
MYcsvtu Notes
53
8085 Microprocessor-Features
The 8085 comes in two models, the 8085A and the
8085A-2. 8085A -clock frequency of 3 MHz (single phase square wave. ) 8085A-2 - clock frequency of 5 MHz. (single phase square wave. ) This single clock is generated within the 8085 itself, requiring only a crystal externally.
MYcsvtu Notes
54
8085 Microprocessor-Features
The 8085 supports the interrupt structure of the 8080.
MYcsvtu Notes
55
8085 Microprocessor-Features
The 8085 has two pins dedicated to the generation or
reception of serial data. (allow the MP to send and receive serial bits with a large software program. Hence 8085 is useful as a complete control device for remote control applications.) The 8085 supports the entire 8080 instruction set. In addition, two new instructions are added- RIM and SIM.
MYcsvtu Notes
56
8085 Microprocessor-Features
Unlike the 8080 , 8085 makes use of multiplexing of the
lower 8 bits of the address with the data bits on the same 8 pins. The 8085 has many new support devices to ease design work. These include the 8259 Programmable Interrupt controller, the 8202 Dynamic RAM controller, several new I/O devices with various amounts of RAM, ROM, parallel I/O and timer-counters.
MYcsvtu Notes Rungta College of Engg. & Technology 57
Control Unit
Generates signals within microprocessor to carry out
MYcsvtu Notes
58
operation such as add, subtract',' AND, OR, etc. Uses data from memory and from Accumulator to perform arithmetic. Always stores result of operation in Accumulator
MYcsvtu Notes
59
registers, one accumulator, and one flag register. In addition, it has two 16-bit registers: the stack pointer and the program counter.
MYcsvtu Notes
60
store 8-bit data; these are identified as B,C,D,E,H, and L. They can be combined as register pairs - BC, DE, and HL - to perform some 16-bit operations. The programmer can use these registers to store or copy data into the registers by using data copy instructions.
MYcsvtu Notes
61
arithmetic/logic unit (ALU). This register is used to store 8-bit data and to perform arithmetic and logical operations. The result of an operation is stored in the accumulator. The accumulator is also identified as register A.
MYcsvtu Notes
62
after an operation according to data conditions of the result in the accumulator and other registers. (P), and Auxiliary Carry (AC) flags.
They are called Zero (Z), Carry (CY), Sign (S), Parity
MYcsvtu Notes
63
Sign. The microprocessor uses these flags to test data conditions. For example, after an addition of two numbers, if the sum in the accumulator is larger than eight bits, called the Carry flag (CY) is set to one. When an arithmetic operation results in zero, the flipflop called the Zero (Z) flag is set to one.
MYcsvtu Notes
64
the accumulator.
out of eight are used to store the outputs of the five flipflops.
MYcsvtu Notes
65
programmer can examine these flags (data conditions) by accessing the register through an instruction
MYcsvtu Notes
66
MYcsvtu Notes
of instructions. This register is a memory pointer. Memory locations have 16-bit addresses, and that is why this is a16-bit register. The microprocessor uses this register to sequence the execution of the instructions.
Rungta College of Engg. & Technology
MYcsvtu Notes
68
MYcsvtu Notes
memory pointer. It points to a memory location in R/W memory, called the stack. The beginning of the stack is defined by loading 16-bit address in the stack pointer.
MYcsvtu Notes
70
the programmers instructions and implement them via nano code. Temporary store for the current instruction of a program. Latest instruction sent here from memory prior to execution. Decoder then takes instruction and decodes or interprets the instruction. Decoded instruction then passed to next stage.
MYcsvtu Notes Rungta College of Engg. & Technology 71
MYcsvtu Notes
72
MYcsvtu Notes
73
MYcsvtu Notes
74
address, the size of the address bus determines the size of memory, which can be used.
MYcsvtu Notes
75
sends an address on the address bus, eg 0000000000000011 (3 in decimal), to the memory. writing data.
The memory the selects box number 3 for reading or Address bus is unidirectional, ie numbers only sent from
MYcsvtu Notes
76
kilobytes (256 x 1024 x 8 bits), how many wires does the address bus need, in order to be able to specify an address in this memory?
MYcsvtu Notes
77
MYcsvtu Notes
78
MYcsvtu Notes
79
done. If only 8 bits wide then largest number is 11111111 (255 in decimal). Therefore, larger number have to be broken down into chunks of 255. This slows microprocessor.
MYcsvtu Notes
80
microprocessor.
Size of the bus therefore limits the number of possible
MYcsvtu Notes
81
MYcsvtu Notes
82
stored in memory) or read from (data taken out of memory) 1 = Read, 0 = Write.
signals.
MYcsvtu Notes
83
memory that we are either reading from a location, specified on the address bus, or writing to a location specified.
MYcsvtu Notes
84
the chip (except for the internal data bus). In case of external busses, the chip connects to the busses via buffers, which are simply an electronic connection between external bus and the internal data bus.
MYcsvtu Notes
85
MYcsvtu Notes
86
Instructions (program steps) are stored in memory. To run a program, the individual instructions must be read from the memory in sequence, and executed. Program counter puts the 16-bit memory address of the instruction on the address bus.
MYcsvtu Notes
87
Control unit sends the Memory Read Enable signal to access the memory. The 8-bit instruction stored in memory is placed on the data bus and transferred to the instruction decoder.
MYcsvtu Notes
88
MYcsvtu Notes
89
MYcsvtu Notes
90
MYcsvtu Notes
93
signal needs to be used with both memory and I/O. So, it must be combined with the IO/M signal to generate different control signals for the memory and I/O. Keeping in mind the operation of the IO/M signal we can use the following circuitry to generate the right set of signals:
MYcsvtu Notes
94
MYcsvtu Notes
95
MYcsvtu Notes
96
MYcsvtu Notes
97
which identifies one unique 8-bit byte within the MPs address space, or the 8-bit address of an I/O device. Sixteen address lines provide an address space of 65,536 locations.
MYcsvtu Notes
98
the 16-bit-wide address early in a machine cycle and 8 data bits later in the cycle.
MYcsvtu Notes
99
only; when containing data, they may be either inbound or outbound, depending upon the nature of the machine cycle.
They also will contain the 8 bits of an I/O device
MYcsvtu Notes
100
and enables the address to get latched into the on chip latch of peripherals. hold times for the address information.
MYcsvtu Notes
101
to advise the external circuitry that the AD0 - AD7 lines contain the lower 8 bits of a memory address.
MYcsvtu Notes
102
as a 74LS245 or 74LS373, so that the full address will be available to the system for the rest of the machine cycle.
on the AD lines, as well as the S0, S1, and I-O/M lines will be stable and may be taken by the external circuitry.
MYcsvtu Notes
103
status of the processor with respect to what function the MP will perform during the machine cycle. The S0 and S1 lines are made available for circuits which need advanced warning of the ensuing operation, such as very slow RAM or other specialized devices.
MYcsvtu Notes
104
lines. The I-O/M line approximates in one line what the S0 and S1 lines do in two.
MYcsvtu Notes
105
S1
S0 Operation 0 0 HALT 0 1 WRITE 1 0 READ 1 1 FETCH S1 can be used as an advanced R/W status.
MYcsvtu Notes
106
pass data between itself and the external data bus. These lines also serve to time the event, as well as identify its direction.
MYcsvtu Notes
107
device is to be read and that the Data Bus is available for the data transfer.
written into the selected memory or I/O location. Data is set up at the trailing edge of WR. 3stated during Hold and Halt modes.
MYcsvtu Notes
108
that the memory or peripheral is ready to send or receive data. If Ready is low, the CPU will wait for Ready to go high before completing the read or write cycle.
MYcsvtu Notes
109
external RAM that a wait state is needed, since the RAM is not able to provide the data or accept it in the time allowed by the MP.
MYcsvtu Notes
110
allowing another processor on the same system buses to request control of the buses. It indicates that another Master is requesting the use of the Address and Data Buses. The CPU, upon receiving the Hold request. will relinquish the use of buses as soon as the completion of the current machine cycle.
MYcsvtu Notes
111
data, and certain control lines, then generate HLDA. This signals the other processor that it may proceed. The 85 will remain off the buses until HOLD is negated.
MYcsvtu Notes
112
be inserted to jump to the interrupt service routine. The INTR is enabled and disabled by software. The processor can regain the buses only after the Hold is removed. When the Hold is acknowledged, the Address, Data, RD, WR, and IO/M lines are 3stated.
MYcsvtu Notes
113
received the Hold request and that it will relinquish the buses in the next clock cycle. HLDA goes low after the Hold request is removed. The CPU takes the buses one half clock cycle after HLDA goes low.
MYcsvtu Notes
114
8085.
instruction in process, then generate INTA as it enters the next machine cycle.
MYcsvtu Notes
115
instruction onto the data bus, which the 85 uses to locate an interrupt vector in low RAM. is used as a general purpose interrupt.
It is sampled only during the next to the last clock cycle
of the instruction.
MYcsvtu Notes
116
interrupt is accepted.
MYcsvtu Notes
117
has the same timing as) RD during the Instruction cycle after an INTR is accepted.
It can be used to activate the 8259 Interrupt chip or
MYcsvtu Notes
118
generate an automatic Restart, without jamming, to vectors in low RAM which are between those used by the normal INTR instruction.
MYcsvtu Notes
119
restart to a 4-byte vector located between 5 and 6 of the normal vectors used by INTR.
These lines have priority over the INTR line, and each
other.
MYcsvtu Notes
120
MYcsvtu Notes
121
above.
MYcsvtu Notes
122
low RAM. Trap interrupt is a non maskable restart interrupt. It is recognized at the same time as INTR. It is unaffected by any mask or Interrupt Enable. It has the highest priority of any interrupt
MYcsvtu Notes Rungta College of Engg. & Technology 123
been brought inside the MP. The RESET IN line is generated asynchronously by some sort of external circuit, such as an RC network or Reset switch.
MYcsvtu Notes
124
synchronize the Reset with the clock of the processor, then generate RESET OUT for other devices in the system. Reset sets the Program Counter to zero and resets the Interrupt Enable and HLDA flip flops.
MYcsvtu Notes
125
is applied.
MYcsvtu Notes
126
MYcsvtu Notes
127
clock generator. The input frequency is divided by 2 to give the internal operating frequency. These two pins provide connection for an external frequency determining circuit to feed the 8085s clock.
MYcsvtu Notes
128
circuits may be used. X1 alone may be used as a single input from an external oscillator.
The internal oscillator of the 85 will divide the frequency
MYcsvtu Notes
129
or R/ C network is used as an input to the CPU. The period of CLK is twice the X1, X2 input period. This line provides a system clock signal to external circuits which need to be in synchronization with the MP.
MYcsvtu Notes
130
l/O.
Tri stated during Hold and Halt modes
MYcsvtu Notes
131
MYcsvtu Notes
132
instruction.
MYcsvtu Notes
133
These lines are brought into the device as D7, and may
be tested or set by the Read Interrupt Mask (RIM) or Set Interrupt Mask (SIM) instructions.
MYcsvtu Notes
134
which controls the RST 5.5, 6.5, and 7.5, and TRAP, interrupts. The SID and SOD lines are simple single bit I/O lines; any timing required to provide external communication via them must be provided by the software.
MYcsvtu Notes
135
+5 volt supply.
Vss:
Ground Reference.
MYcsvtu Notes
136
processor.
It requires a single +5 volt supply. Its basic clock speed is 3 MHz thus improving on the
MYcsvtu Notes
137
The 8085A uses a multiplexed Data Bus. The address is split between the higher 8bit Address
MYcsvtu Notes
138
MYcsvtu Notes
139
MYcsvtu Notes
140
maskable, restart interrupts and one non-maskable trap interrupt. The 8085A provides RD, WR and IO/M signals for Bus control.
MYcsvtu Notes
141
MYcsvtu Notes
142
MYcsvtu Notes
143
8085A the 8 LSB of address are multiplexed with the data instead of status. The ALE line is used as a strobe to enter the lower half of the address into the memory or peripheral address latch. This also frees extra pins for expanded interrupt capability.
MYcsvtu Notes Rungta College of Engg. & Technology 144
RST6.5, RST 7.5, and TRAP. INTR is identical in function to the 8080 INT. Each of the three RESTART inputs, 5.5, 6.5,7.5 has a programmable mask. TRAP is also a RESTART interrupt except it is non maskable.
MYcsvtu Notes
145
execution of RST (saving the program counter in the stack and branching to the RESTART address) if the interrupts are enabled and if the interrupt mask is not set. of a RST independent of the state of the interrupt enable or masks.
MYcsvtu Notes
146
determines which interrupt is to be recognized if more than one is pending as follows: lowest priority.
TRAP highest priority, RST 7.5,RST 6.5, RST 5.5, INTR This priority scheme does not take into account the
MYcsvtu Notes
147
such as power failure or bus error. The TRAP input is recognized just as any other interrupt but has the highest priority. It is not affected by any flag or mask. The TRAP input is both edge and level sensitive.
MYcsvtu Notes Rungta College of Engg. & Technology 148
8085 Timings
Instruction Cycle The time required by the 8085 to fetch and execute one
complexities, with the result that the more complicated instructions take longer to execute.
MYcsvtu Notes
149
8085 Timings
Instruction Cycle
MP is more organized, however, and so the time required to execute any instruction is more predictable and more regular.
MYcsvtu Notes
150
8085 Timings
Machine Cycle
Cycles. Each machine cycle is essentially the result of the need, by the instruction being executed, to access the RAM. The shortest instruction would require just one machine cycle, in which the instruction itself is obtained from RAM.
MYcsvtu Notes
151
8085 Timings
The longest, of five machine cycles, would consist of
five RAM accesses, the first to obtain the instruction byte itself, and the remaining four to be divided into fetching and saving other bytes.
fetch two more bytes of an address, while numbers 4 & 5 may be needed to save a 2-byte address somewhere else in RAM.
MYcsvtu Notes
152
8085 Timings
The type of machine cycle being executed is specified
by the status lines I-O/M, S0, and S1, and the control lines /RD, /WR, and /INTA.
MYcsvtu Notes
153
and /RD low. It is a read cycle from RAM to obtain an instruction byte.
MYcsvtu Notes
154
code. It is defined with S0 and S1 set to 0, 1 respectively, and I-O/M and /RD low. It is a read cycle from RAM to obtain a data or address byte.
MYcsvtu Notes
155
I-O/M and /WR low. It is a write cycle to RAM to store one byte in the specified address
MYcsvtu Notes
156
with I-O/M high and /RD low. It is a read cycle which will bring one byte into the MP from the input device specified.
MYcsvtu Notes
157
with I-O/M high and /WR low. It is a write cycle which will send one byte outbound from the MP to the specified output device.
MYcsvtu Notes
158
MP via the INTR line. It is defined with S0 and S1 set to 1, 1 respectively, IO/M set high, and both /RD and /WR also high.
MYcsvtu Notes
159
asserted level. It is neither a read nor write cycle, although the interrupting device will jam an interrupt vector onto the D0-D7 lines on the next machine cycle.
MYcsvtu Notes
160
MYcsvtu Notes
161
its own Idle cycle. It is defined with S0 and S1 set to 0, 1 respectively, IO/M set low, and neither /RD nor /WR asserted (both high). Since neither a read nor a write are specified, no bus action takes place.
MYcsvtu Notes
162
MYcsvtu Notes
163
Halt instruction. The I-O/M, /RD, and /WR lines are all tri stated, which would allow them to be controlled by other devices. INTA is held inactive, but not tri stated. The Hold line is really the proper one to use for DMA or multiple processors.
MYcsvtu Notes
164
8085 Timings-T-states T-states Each of the machine cycles defined above, during
which an access of a RAM address or an I/O device is made (except the idle cycles), is further divided into Tstates. Each T-state, for an 85 with a 3 MHz clock, will be about 333 nanoseconds in length. The first machine cycle, during which the OP code is being fetched, will be either 4 or 6 T-states in length.
MYcsvtu Notes
165
whether the instruction needs further information from RAM, or whether it can be executed to completion straight away . If multiple accesses are needed, the cycle will be 4 states long; if the execution can run to completion, 6 states are required.
MYcsvtu Notes
166
8085 Timings-T-states The actions of the major signals of the 85 during each
T1 STATE: This state is the first of any machine cycle. S0-S1 lines, I-O/M, A8-A15, and AD0-AD7 contains
MYcsvtu Notes
167
8085 Timings-T-states T1 STATE: The S0-S1 and I-O/M lines will define, at this early point
in the machine cycle, whether the MP is attempting to address a RAM location or an I/O device. to be dealt with.
MYcsvtu Notes
168
8085 Timings-T-states T1 STATE: The Address Latch Enable (ALE) line will allow some
sort of external circuitry to catch and hold the contents of the AD0-AD7 lines to be used as the low byte of the address.
The /RD, /WR, and /INTA lines are all negated at this
time.
MYcsvtu Notes
169
8085 Timings-T-states T1 STATE: Since the AD0-AD7 lines are being used to present an
address byte, it would be inappropriate to move data on the data bus; besides, its too early to do so. Its also too early for /INTA. ALE, however, is asserted, since this is the time that the AD0-AD7 contents will contain the lower address byte, which must be caught and held outside the 85 for use by the following Tstates.
MYcsvtu Notes
170
8085 Timings-T-states T2 STATE: All lines except ALE (which will be inactive for the rest
of the machine cycle) will assume the proper level for the type of instruction in progress. The address lines retain the bit pattern selecting one byte from RAM or an I/O device; The AD0-AD7 lines will now prepare to either accept or present a data byte (they are in a state of transition during T2).
MYcsvtu Notes
171
original settings of T1. Either /RD or /WR will assert during T2, to indicate the nature of the data transaction. INTA will assert at T2 if an interrupt cycle has started.
MYcsvtu Notes
172
8085 Timings-T-states WAIT STATE: If the Ready line was negated during T2, a Tw is
inserted to allow the external circuitry more time to prepare for data transmission. A specific point in T2 is defined, after which a late negation of Ready will not cause the Tw to be inserted. This corresponds to the same actions in the 8080 device. All signals set up during T2 will remain constant during Tw.
MYcsvtu Notes
173
except the AD0-AD7 lines, which will be conducting data either into or out of the 8085. At the end of T3, the /RD or /WR line will negate to indicate the end of the active function. This will cause the data byte standing on AD0-AD7 to disappear
MYcsvtu Notes
174
8085 Timings-T-states T4 - T6 STATES: These states are required for time to permit the 8085 to
No bus actions are required. The S0 & S1 lines are both asserted, while I-O/M is
MYcsvtu Notes
175
cycle of an instruction, this corresponds correctly with the Machine Cycle chart. The AD0-AD7 lines are tri stated; the A8-A15 retain their original setting; the /RD, /WR, and INTA lines are all negated.
MYcsvtu Notes
176
also various conditions during states involved in Resets, Halts, and Holds.
clocks are still running, and the 85 is alive inside; it has simply shut itself off the buses to allow external events to occur.
MYcsvtu Notes
177
These states tri state the address, AD, I-O/M, /RD, and
/WR lines to allow external devices to control them. The other lines are held at inactive levels except the S0 & S1 lines, which do indicate what type of machine cycle the system is in, i.e., whether it is a Reset, Hold, or Halt
MYcsvtu Notes
178
instruction, which causes the system to go into T-halt states. During this time, the 85 is simply waiting for something to occur. There are three ways out of a Halt: A Reset, a Hold Request, and an enabled interrupt.
MYcsvtu Notes
179
honor it by going into T-hold cycles as long as the Hold line remains asserted. It will return to the halt condition when Hold negates. If an interrupt occurs during a halt, the MP will go into an interrupt cycle if the interrupt was enabled.
MYcsvtu Notes
180
until the hold clears before being given control of the system.
MYcsvtu Notes
181
stored in memory location 2005H. Illustrate the steps and the timing of data flow when it is being fetched
MYcsvtu Notes
182
Example Mp Communication
MYcsvtu Notes
183
Timing Diagram
MYcsvtu Notes
184
Some Terminologies:
After observing timing diagram we can say,
4FH is a one byte instruction One external operation fetching 4F from 2005H Entire operation needs 4 clock periods
MYcsvtu Notes
185
MYcsvtu Notes
186
Instruction
An instruction is a binary pattern designed inside a
MYcsvtu Notes
187
Instruction
In microprocessor parlance, a byte is described as 8
0.
MYcsvtu Notes
188
Instruction
Note also that there is no parity bit, or provision for it, as
would be found in larger systems. The 8085s instructions are either one, two, or three bytes long. In all cases, the first byte contains the essential information, such as the OP code. The second and third bytes, if included, provide operand information that wont fit in the first byte.
MYcsvtu Notes
189
data transfer (copy) operations arithmetic operations, logical operations, branching operations, and machine-control operations.
MYcsvtu Notes
190
called a source to another location called a destination, without modifying the contents of the source. In technical manuals, the term data transfer is used for this copying function. The various types of data transfer (copy) are listed below together with examples of each type:
MYcsvtu Notes
191
MOV Rd, Rs
This instruction copies the contents of the source M, Rs
register into the destination register; the contents of Rd, M the source register are not altered. If one of the operands is a memory location, its location is specified by the contents of the HL registers. Example: MOV B, C or MOV B, M
MYcsvtu Notes
192
data memory. If the operand is a memory location, its location is specified by the contents of the HL registers. Example: MVI B, 57H or MVI M, 57H
MYcsvtu Notes
193
address in the operand, are copied to the accumulator. The contents of the source are not altered. Example: LDA 2034H
MYcsvtu Notes
194
memory location. This instruction copies the contents of that memory location into the accumulator. The contents of either the register pair or the memory location are not altered. Example: LDAX B
MYcsvtu Notes
195
MYcsvtu Notes
196
location pointed out by the 16-bit address into register L and copies the contents of the next memory location into register H. The contents of source memory locations are not altered. Example: LHLD 2040H
MYcsvtu Notes Rungta College of Engg. & Technology 197
memory location specified by the operand. This is a 3-byte instruction, the second byte specifies the low-order address and the third byte specifies the high-order address. Example: STA 4350H
MYcsvtu Notes
198
memory location specified by the contents of the operand (register pair). The contents of the accumulator are not altered. Example: STAX B
MYcsvtu Notes
199
memory location specified by the 16-bit address in the operand and the contents of H register are stored into the next memory location by incrementing the operand. This is a 3-byte instruction, the second byte specifies the low-order address and the third byte specifies the high-order address. Example: SHLD 2470H
MYcsvtu Notes Rungta College of Engg. & Technology 200
XCHG none
The contents of register H are exchanged with the
contents of register D, and the contents of register L are exchanged with the contents of register E. Example: XCHG
MYcsvtu Notes
201
SPHL none
The instruction loads the contents of the H and L
registers into the stack pointer register, the contents of the H register provide the high-order address and the contents of the L register provide the low-order address. The contents of the H and L registers are not altered. Example: SPHL
MYcsvtu Notes
202
XTHL none
The contents of the L register are exchanged with the
stack location pointed out by the contents of the stack pointer register. The contents of the H register are exchanged with the next stack location (SP+1); however, the contents of the stack pointer register are not altered. Example: XTHL
MYcsvtu Notes Rungta College of Engg. & Technology 203
address OUT 8-bit port address The contents of the accumulator are copied into the I/O port specified by the operand. Example: OUT F8H
MYcsvtu Notes
204
address IN 8-bit port address The contents of the input port designated in the operand are read and loaded into the accumulator. Example: IN 8CH
MYcsvtu Notes
205
Arithmetic instructions
Add register or memory to accumulator ADD R The contents of the operand (register or memory) are M
added to the contents of the accumulator and the result is stored in the accumulator. If the operand is a memory location, its location is specified by the contents of the HL registers. All flags are modified to reflect the result of the addition. Example: ADD B or ADD M
MYcsvtu Notes Rungta College of Engg. & Technology
206
Arithmetic instructions
Add register to accumulator with carry ADC R The contents of the operand (register or memory) and
M the Carry flag are added to the contents of the accumulator and the result is stored in the accumulator. If the operand is a memory location, its location is specified by the contents of the HL registers. All flags are modified to reflect the result of the addition. Example: ADC B or ADC M
MYcsvtu Notes Rungta College of Engg. & Technology 207
Arithmetic instructions
Add immediate to accumulator
accumulator and the result is stored in the accumulator. All flags are modified to reflect the result of the addition. Example: ADI 45H
MYcsvtu Notes
208
Arithmetic instructions
Add immediate to accumulator with carry
to the contents of the accumulator and the result is stored in the accumulator. All flags are modified to reflect the result of the addition. Example: ACI 45H
MYcsvtu Notes
209
Arithmetic instructions
Add register pair to H and L registers
added to the contents of the HL register and the sum is stored in the HL register. The contents of the source register pair are not altered. If the result is larger than 16 bits, the CY flag is set. No other flags are affected. Example: DAD H
MYcsvtu Notes Rungta College of Engg. & Technology 210
Arithmetic instructions
Subtract register or memory from accumulator
SUB R
The contents of the operand (register or memory ) are
M subtracted from the contents of the accumulator, and the result is stored in the accumulator. If the operand is a memory location, its location is specified by the contents of the HL registers. All flags are modified to reflect the result of the subtraction. Example: SUB B or SUB M
MYcsvtu Notes Rungta College of Engg. & Technology 211
Arithmetic instructions
Subtract source and borrow from accumulator
SBB R
The contents of the operand (register or memory ) and
M the Borrow flag are subtracted from the contents of the accumulator and the result is placed in the accumulator. If the operand is a memory location, its location is specified by the contents of the HL registers. All flags are modified to reflect the result of the subtraction. Example: SBB B or SBB M
MYcsvtu Notes Rungta College of Engg. & Technology 212
Arithmetic instructions
Subtract immediate from accumulator
of the accumulator and the result is stored in the accumulator. All flags are modified to reflect the result of the subtraction. Example: SUI 45H
MYcsvtu Notes
213
Arithmetic instructions
Subtract immediate from accumulator with borrow
subtracted from the contents of the accumulator and the result is stored in the accumulator. All flags are modified to reflect the result of the subtraction. Example: SBI 45H
MYcsvtu Notes
214
Arithmetic instructions
Increment register or memory by 1
memory) are M incremented by 1 and the result is stored in the same place. If the operand is a memory location, its location is specified by the contents of the HL registers. Example: INR B or INR M
MYcsvtu Notes
215
Arithmetic instructions
Increment register pair by 1
INX R
The contents of the designated register pair are
incremented by 1 and the result is stored in the same place. Example: INX H
MYcsvtu Notes
216
Arithmetic instructions
Decrement register or memory by 1
DCR R
The contents of the designated register or memory are
M decremented by 1 and the result is stored in the same place. If the operand is a memory location, its location is specified by the contents of the HL registers. Example: DCR B or DCR M
MYcsvtu Notes
217
Arithmetic instructions
Decrement register pair by 1 DCX R The contents of the designated register pair are
decremented by 1 and the result is stored in the same place. Example: DCX H
MYcsvtu Notes
218
Arithmetic instructions
Decimal adjust accumulator DAA none The contents of the accumulator are
changed from a binary value to two 4-bit binary coded decimal (BCD) digits. This is the only instruction that uses the auxiliary flag to perform the binary to BCD conversion, and the conversion procedure is described below. S, Z, AC, P, CY flags are altered to reflect the results of the operation.
MYcsvtu Notes
219
Arithmetic instructions
Decimal adjust accumulator If the value of the low-order 4-bits in the accumulator is
greater than 9 or if AC flag is set, the instruction adds 6 to the low-order four bits. If the value of the high-order 4-bits in the accumulator is greater than 9 or if the Carry flag is set, the instruction adds 6 to the high-order four bits. Example: DAA
MYcsvtu Notes
220
Branching operations
Jump unconditionally
transferred to the memory location specified by the 16bit address given in the operand. Example: JMP 2034H or JMP XYZ
MYcsvtu Notes
221
Branching operations
Jump conditionally
location specified by the 16-bit address given in the operand based on the specified flag of the PSW as described below. Example: JZ 2034H or JZ XYZ
MYcsvtu Notes
222
Branching operations
JC Jump on Carry CY = 1
Subroutine
Unconditional subroutine call CALL 16-bit address The program sequence is transferred to the memory
location specified by the 16-bit address given in the operand. Before the transfer, the address of the next instruction after CALL (the contents of the program counter) is pushed onto the stack. Example: CALL 2034H or CALL XYZ
MYcsvtu Notes Rungta College of Engg. & Technology 224
Subroutine
Call conditionally Operand: 16-bit address The program sequence is transferred to the memory
location specified by the 16-bit address given in the operand based on the specified flag of the PSW as described below. Before the transfer, the address of the next instruction after the call (the contents of the program counter) is pushed onto the stack.
Example: CZ 2034H or CZ XYZ
MYcsvtu Notes Rungta College of Engg. & Technology 225
Subroutine
CC Call on Carry CY = 1
CNC Call on no Carry CY = 0 CP Call on positive S = 0 CM Call on minus S = 1 CZ Call on zero Z = 1 CNZ Call on no zero Z = 0 CPE Call on parity even P = 1 CPO Call on parity odd P = 0
MYcsvtu Notes Rungta College of Engg. & Technology 226
Subroutine
Return from subroutine unconditionally RET none The program sequence is transferred from the
subroutine to the calling program. The two bytes from the top of the stack are copied into the program counter, and program execution begins at the new address. Example: RET
MYcsvtu Notes Rungta College of Engg. & Technology 227
Subroutine
Return from subroutine conditionally
Operand: none
The program sequence is transferred from the
subroutine to the calling program based on the specified flag of the PSW as described below. The two bytes from the top of the stack are copied into the program counter, and program execution begins at the new address. Example: RZ
MYcsvtu Notes Rungta College of Engg. & Technology 228
Subroutine
RC Return on Carry CY = 1
Other instructions
Load program counter with HL contents
PCHL none
The contents of registers H and L are copied into the
program counter. The contents of H are placed as the high-order byte and the contents of L as the low-order byte. Example: PCHL
MYcsvtu Notes
230
Other instructions
Restart RST 0-7 The RST instruction is equivalent to a 1-byte
call instruction to one of eight memory locations depending upon the number. The instructions are generally used in conjunction with interrupts and inserted using external hardware. However these can be used as software instructions in a program to transfer program execution to one of the eight locations. The addresses are:
MYcsvtu Notes Rungta College of Engg. & Technology 231
Restart
Instruction Restart Address RST 0 0000H RST 1 0008H RST 2 0010H RST 3 0018H RST 4 0020H RST 5 0028H RST 6 0030H RST 7 0038H
MYcsvtu Notes
232
Restart
The 8085 has four additional interrupts and these
interrupts generate RST instructions internally and thus do not require any external hardware. These instructions and their Restart addresses are: Interrupt Restart Address TRAP 0024H RST 5.5 002CH RST 6.5 0034H RST 7.5 003CH
MYcsvtu Notes Rungta College of Engg. & Technology 233
Logical instructions
Compare register or memory with accumulator CMP R The contents of the operand (register or memory) are M compared with the contents of the accumulator. Both contents are preserved .
MYcsvtu Notes
234
Logical instructions
The result of the comparison is shown by setting the
flags of the PSW as follows: if (A) < (reg/mem): carry flag is set if (A) = (reg/mem): zero flag is set if (A) > (reg/mem): carry and zero flags are reset Example: CMP B or CMP M
MYcsvtu Notes
235
Logical instructions
Compare immediate with accumulator CPI 8-bit data The second byte (8-bit data) is compared with the
MYcsvtu Notes
236
Logical instructions
The result of the comparison is shown by setting the
flags of the PSW as follows: if (A) < data: carry flag is set if (A) = data: zero flag is set if (A) > data: carry and zero flags are reset Example: CPI 89H
MYcsvtu Notes
237
Logical instructions
Logical AND register or memory with accumulator ANA R The contents of the accumulator are logically ANDed
with M the contents of the operand (register or memory), and the result is placed in the accumulator. If the operand is a memory location, its address is specified by the contents of HL registers. S, Z, P are modified to reflect the result of the operation. CY is reset.AC is set. Example: ANA B or ANA M
MYcsvtu Notes Rungta College of Engg. & Technology
238
Logical instructions
Logical AND immediate with accumulator
with the 8-bit data (operand) and the result is placed in the accumulator. S, Z, P are modified to reflect the result of the operation. CY is reset. AC is set. Example: ANI 86H
MYcsvtu Notes Rungta College of Engg. & Technology 239
Logical instructions
Exclusive OR register or memory with accumulator XRA R The contents of the accumulator are Exclusive ORed
with M the contents of the operand (register or memory), and the result is placed in the accumulator. If the operand is a memory location, its address is specified by the contents of HL registers. S, Z, P are modified to reflect the result of the operation. CY and AC are reset. Example: XRA B or XRA M
MYcsvtu Notes Rungta College of Engg. & Technology 240
Logical instructions
Exclusive OR immediate with accumulator XRI 8-bit data The contents of the accumulator are Exclusive ORed
with the 8-bit data (operand) and the result is placed in the accumulator. S, Z, P are modified to reflect the result of the operation. CY and AC are reset. Example: XRI 86H
MYcsvtu Notes
241
Logical instructions
Logical OR register or memory with accumulator ORA R The contents of the accumulator are logically ORed with
M the contents of the operand (register or memory), and the result is placed in the accumulator. If the operand is a memory location, its address is specified by the contents of HL registers. S, Z, P are modified to reflect the result of the operation. CY and AC are reset. Example: ORA B or ORA M
MYcsvtu Notes Rungta College of Engg. & Technology 242
Logical instructions
Logical OR immediate with accumulator ORI 8-bit data The contents of the accumulator are logically ORed with
the 8-bit data (operand) and the result is placed in the accumulator. S, Z, P are modified to reflect the result of the operation. CY and AC are reset. Example: ORI 86H
MYcsvtu Notes
243
Logical instructions
Rotate accumulator left RLC none Each binary bit of the accumulator is rotated left by one
position. Bit D7 is placed in the position of D0 as well as in the Carry flag. CY is modified according to bit D7. S, Z, P,AC are not affected. Example: RLC
MYcsvtu Notes
244
Logical instructions
Rotate accumulator right
RRC none
Each binary bit of the accumulator is rotated right by
one position. Bit D0 is placed in the position of D7 as well as in the Carry flag. CY is modified according to bit D0. S, Z, P,AC are not affected. Example: RRC
MYcsvtu Notes Rungta College of Engg. & Technology 245
Logical instructions
Rotate accumulator left through carry
RAL none
Each binary bit of the accumulator is rotated left by one
position through the Carry flag. Bit D7 is placed in the Carry flag, and the Carry flag is placed in the least significant position D0. CY is modified according to bit D7. S, Z, P, AC are not affected. Example: RAL
MYcsvtu Notes Rungta College of Engg. & Technology 246
Logical instructions
Rotate accumulator right through carry
RAR none
Each binary bit of the accumulator is rotated right by
one position through the Carry flag. Bit D0 is placed in the Carry flag, and the Carry flag is placed in the most significant position D7. CY is modified according to bit D0. S, Z, P, AC are not affected. Example: RAR
MYcsvtu Notes Rungta College of Engg. & Technology 247
Logical instructions
Complement accumulator CMA none The contents of the accumulator are complemented. No flags are affected. Example: CMA
MYcsvtu Notes
248
Logical instructions
Complement carry
CMC none
The Carry flag is complemented. No other flags are affected. Example: CMC
MYcsvtu Notes
249
Logical instructions
Set Carry
MYcsvtu Notes
250
No operation NOP none No operation is performed. The instruction is fetched and decoded. However no operation is executed. Example: NOP
MYcsvtu Notes
251
HLT none
The CPU finishes executing the current instruction and
halts any further execution. An interrupt or reset is necessary to exit from the halt state. Example: HLT
MYcsvtu Notes
252
DI none
The interrupt enable flip-flop is reset and all the
interrupts except the TRAP are disabled. No flags are affected. Example: DI
MYcsvtu Notes
253
EI none
The interrupt enable flip-flop is set and all interrupts are
enabled. No flags are affected. After a system reset or the acknowledgement of an interrupt, the interrupt enable flip flop is reset, thus disabling the interrupts. This instruction is necessary to enable the interrupts (except TRAP). Example: EI
MYcsvtu Notes Rungta College of Engg. & Technology 254
RIM none
This is a multipurpose instruction used to read the
status of interrupts 7.5, 6.5, 5.5 and read serial data input bit. The instruction loads eight bits in the accumulator with the following interpretations. Example: RIM
MYcsvtu Notes
255
SIM none
This is a multipurpose instruction and used to
implement the 8085 interrupts 7.5, 6.5, 5.5, and serial data output. The instruction interprets the accumulator contents as follows. Example: SIM
MYcsvtu Notes
256
Stack
The Stack Pointer The stack on an 8080/8085 can be located anywhere in
MYcsvtu Notes
257
Stack
Stack operations are always performed with registers
pairs. A register pair is referenced by the name of the MSB register: B, D or H. The only exception is PSW, which in fact is the LSB register of the AF pair
MYcsvtu Notes
258
Stack
A push on the stack, whether it comes from the PUSH
Decrement SP by 1 Save most significant byte of register pair Decrement SP by 1 Save least significant byte of register pair Naturally a pop from the stack has just the opposite effect:
Rungta College of Engg. & Technology 259
MYcsvtu Notes
Stack
Load least significant byte of register pair
Increment SP by 1
Load most significant byte of register pair Increment SP by 1
MYcsvtu Notes
260
Stack
Push register pair onto stack PUSH Reg. pair The contents of the register pair designated in the
operand are copied onto the stack in the following sequence. The stack pointer register is decremented and the contents of the high order register (B, D, H, A) are copied into that location. The stack pointer register is decremented again and the contents of the low-order register (C, E, L, flags) are copied to that location. Example: PUSH B or PUSH A
MYcsvtu Notes Rungta College of Engg. & Technology 261
Stack
Pop off stack to register pair POP Reg. pair The contents of the memory location pointed out by the
stack pointer register are copied to the low-order register (C, E, L, status flags) of the operand. The stack pointer is incremented by 1 and the contents of that memory location are copied to the high-order register (B, D, H, A) of the operand. The stack pointer register is again incremented by 1. Example: POP H or POP A
MYcsvtu Notes Rungta College of Engg. & Technology
262
data from a source into a destination. In these instructions the source can be a register, an input port, or an 8-bit number (00H to FFH). Similarly, a destination can be a register or an output port. The sources and destination are operands. The various formats for specifying operands are called the ADDRESSING MODES.
MYcsvtu Notes Rungta College of Engg. & Technology 263
Immediate addressing.
Register addressing. Direct addressing. Indirect addressing. Implicit addressing
MYcsvtu Notes
264
accumulator or send the data stored in the accumulator to the outside device. Accept the data from the port 00H and store them into the accumulator or Send the data from the accumulator to the port 01H. Example: IN 00H or OUT 01H
MYcsvtu Notes
266
the processor and the contents of the address (and the one following) is used to form a second address. The second address is where the data is stored. Note that this requires several memory accesses; two accesses to retrieve the 16-bit address and a further access (or accesses) to retrieve the data which is to be loaded into the register.
MYcsvtu Notes Rungta College of Engg. & Technology 267
concerning the program being assembled. They are not translated into machine code or assigned any memory locations in the object file.
ORG (origin) org 20 The next block of instructions or data should be stored
in memory locations starting at 2010. Either hex or decimal numbers are acceptable.
MYcsvtu Notes Rungta College of Engg. & Technology
268
end
start end of assembly. A HLT instruction may suggest the end of a program,
but does not necessarily mean it is the end of assembly. "start" is the label at the beginning of the program*.
MYcsvtu Notes
269
(equate)
lookup equ 2 The value of the term, lookup, is equal to 2. lookup's value may be referred by name in the program. Similar to a constant statement.
MYcsvtu Notes
270
buffer.
MYcsvtu Notes
271
(define byte)
data: db 34 or data: db 34 db A2,db 93 Initializes an area byte by byte. Assembled bytes of data are stored in successive
memory locations until all values are stored. The label is optional and may be used as the memory location of the beginning of the data.
MYcsvtu Notes Rungta College of Engg. & Technology 272
this example,10 memory locations are reserved for "table". The label may be used as the memory location of the beginning of the block of memory.
MYcsvtu Notes Rungta College of Engg. & Technology 273
Instruction Format
An instruction is a command to the microprocessor to
performed, called the operation code (opcode), and the second is the data to be operated on, called the operand. ways.It may include 8-bit (or 16-bit ) data, an internal register, a memory location, or 8-bit (or 16-bit) address.
Rungta College of Engg. & Technology 274
MYcsvtu Notes
Instruction Format
In some instructions, the operand is implicit. Instruction word size The 8085 instruction set is classified into the following
three groups according to word size: One-word or 1-byte instructions Two-word or 2-byte instructions Three-word or 3-byte instructions
MYcsvtu Notes
275
Instruction Format
One-Byte Instructions A 1-byte instruction includes the op code and operand
in the same byte. Operand (s) are internal register and are coded into the instruction. For example: Copy the contents of the accumulator in the register C. MOV C,A 0100 1111 4FH
MYcsvtu Notes
276
Instruction Format
Add the contents of register B to the contents of the
Invert (compliment) each bit in the accumulator. CMA 0010 1111 2FH
MYcsvtu Notes
277
Instruction Format
MOV rd, rs
rd <-- rs copies contents of rs into rd. Coded as 01 ddd sss where ddd is a code for one of the
7 general registers which is the destination of the data, sss is the code of the source register.
MYcsvtu Notes
278
Instruction Format
Two-Byte Instructions In a two-byte instruction, the first byte specifies the
operation code and the second byte specifies the operand. Source operand is a data byte immediately following the op code. For example: Load an 8-bit data byte in the accumulator. MVI A, Data 3E
MYcsvtu Notes Rungta College of Engg. & Technology 279
Instruction Format
Assume that the data byte is 32H. The assembly
language instruction is written as Mnemonics Hex code MVI A, 32H - 3E 32H The instruction would require two memory locations to store in memory.
MVI r, data r <-- data Example: MVI A,30H coded as 3EH 30H as two
contiguous bytes.
MYcsvtu Notes
280
Instruction Format
ADI data A <-- A + data OUT port
where port is an 8-bit device address. (Port) <-- A. Since the byte is not the data but points directly to where it is located this is called direct addressing.
MYcsvtu Notes
281
Instruction Format
Three-Byte Instructions In a three-byte instruction, the first byte specifies the op
code, and the following two bytes specify the 16-bit address. Note that the second byte is the low-order address and the third byte is the high-order address. Op code + data byte + data byte
282
Instruction Format
C3 85 20 First byte Second Byte Third Byte This instruction would require three memory locations to
store in memory. Three byte instructions - opcode + data byte + data byte
LXI rp, data16 rp is one of the pairs of registers BC, DE, HL used as
16-bit registers. The two data bytes are 16-bit data in L H order of significance. rp <-- data16
MYcsvtu Notes Rungta College of Engg. & Technology
283
Instruction Format
Example:
MYcsvtu Notes
284
Delay generation
Delay are generated using subroutine
MYcsvtu Notes
285
Delay generation
Ways to generate delay-
in the subroutine To start with a counter is set up For small delays an 8 bit register is set up For large delays a 16 bit register is used as counter Nested lops are also used in which two registers are used
MYcsvtu Notes Rungta College of Engg. & Technology 286
Delay generation
Small delay generation
MYcsvtu Notes
Delay generation
The loop is executed count-1 times.
comes out the loop. Total T states in the above program =7T+(COUNT-1)(4T+10T)+(4T+7T)+10T =7T+254*14T+11T+10T =3584 T states
MYcsvtu Notes
288
Delay generation
Now if clock period=.5 micro secs
Td= 3584*.5
=1792 microseconds =1.792 mili secs
MYcsvtu Notes
289
Delay generation
Long delay generation
Delay generation
Total number of T states=
10t+(6t+4t+4t+10t)*count-1+(6t+4t+4t+7t)+10t
= 10t+(6t+4t+4t+10t)*65534+(6t+4t+4t+7t)+10t =1572857 t states If 1t=.5 micro secs Td=1572857*.5= =786.43ms
MYcsvtu Notes
291
Delay generation
Write a subroutine for 8085 to generate a delay of
MYcsvtu Notes
292
Delay generation
If the clock frequency of a 8085 system is
2MHz.Calculate the delay generated by the following set of instructions LXI B,3480 H UP DCX B MOV A,C ORA B JNZ UP FREQUENCY=2 MHz
MYcsvtu Notes
293
Delay programs
Sol1For .3333 micro secs clock cycle 10 ms=(1/.3333)*10 = 30030.03 secs = 30030 t states Its a large value hence reg pair is used as counter Program LXI D,count H- 10T DELAY DCX D- 6T MOV A,E4T ORA D4T JNZ DELAY10T/7T RET10T
Rungta College of Engg. & Technology 294
MYcsvtu Notes
Delay programs
30030*T = 10T+(6+4+4+10)* count-1
Count
MYcsvtu Notes
295
Delay programs
Sol 2 Program MVI B, count H DELAY DCR B JNZ DELAY RET
MYcsvtu Notes
296
Delay programs
100 micro secs
= (100/320 ns) = 312.5 t states 312.5 * T = 7T+(4T+10T) count-1 +(4T+7T)+ 10T Count = 21.32 =(21)d = 15H
MYcsvtu Notes
297
Delay programs
Sol 3
= (3480)H = (13440)d T = (1/2*10^6) = .5 micro secs Td= 10T+(6T+4T+4T+10T)* count-1 +(6+4+4+7)T+10T Hence substituting the values of 1 T & count we have Td = 161288.5 micro secs = 161.28 ms = .16 s
MYcsvtu Notes Rungta College of Engg. & Technology 298
MYcsvtu Notes
299
RRC
RRC RRC CALL ASCII STAX D INX D MOV A,B
MYcsvtu Notes Rungta College of Engg. & Technology 300
CALL ASCII STAX D HLT ASCII- SUBROUTINE ANI 0F H CPI 0A H JC CODE ADI 30 H CODE ADI 30 H RET
Rungta College of Engg. & Technology 301
MYcsvtu Notes
ASCII TO BINARY
SUBROUTINE
SUI 30 H
CPI 0A H RC SUI 07 H RET
MYcsvtu Notes
302
MYcsvtu Notes
304
ANI F0 H RRC RRC RRC RRC MVI E,0A H MOV D,A XRA A
MYcsvtu Notes
305
DCR D
JNZ SUM ADD B POP D POP B RET
MYcsvtu Notes
306
LXI SP, 4FFF H LXI H, 4050 H MOV A,M CALL SUB1 HLT SUB1 LXI H,4060 H MVI B, 64H
MYcsvtu Notes
307
MYcsvtu Notes
CALL CONVERSION MVI B,0A H CALL CONVERSION MOV M,A CONVERSION MVI M, FF H LOOP INR M SUB B JNC LOOP ADD B INX H RET
308
LXI SP, 4FFF H LXI H, 4050 H MVI D, 03 H CALL UNPACK HLT UNPACK LXI B, 4060 H
MYcsvtu Notes
309
AHEAD MOV A,M ANI F0 H RRC RRC RRC CALL LED CONVERSION INX B MOV A,M
MYcsvtu Notes
310
MYcsvtu Notes
311
LED CONVERSION PUSH H LXI H, CODE ADD L MOV L,A MOV A,M STAX B POP H RET
Rungta College of Engg. & Technology 312
MYcsvtu Notes
Sample Programs
Write an assembly program to add two numbers
Program
MVI D, 8BH MVI C, 6FH MOV A, C ADD D OUT PORT1 HLT
MYcsvtu Notes Rungta College of Engg. & Technology 313
Sample Programs
Write an assembly program to multiply a number by
314
Sample Programs
Write an assembly program to find greatest between
two numbers Program MVI B, 30H MVI C, 40H MOV A, B CMP C JZ EQU JC GRT OUT PORT1 HLT
MYcsvtu Notes
315
Sample Programs
EQU: MVI A, 01H
OUT PORT1
HLT GRT: MOV A, C OUT PORT1 HLT
MYcsvtu Notes
316
Sample Programs
Write a 8085 machine code program:
Read two different memory locations Add the contents Send the result to output port 02 (display) if there is no overflow Display FF if there is an overflow Stop
Sample Programs
2000 2001 2002 2003 2004 2005 2006 2007 2008 LDA 2050 MOV B,A LDA 2051
ADD B JNC 2013
3A 50 20 47 3A 51 20 80 D2
MYcsvtu Notes
318
MVI A,FF
OUT 02
HLT
13 20 3E FF D3 02 76
MYcsvtu Notes
319
Sample Programs
Multiply eight bit numbers using successive addition
MYcsvtu Notes
320
Sample Programs
MVI D, 05
LXI B, 0015
LXI H, 0000 DAD B DCR D JNZ C008 HLT
MYcsvtu Notes
321
Sample Programs
Write a program to find the positive numbers in an array
of 10 elements. Assume the array starts from C200. Store the result at C300.
MYcsvtu Notes
322
Sample Programs
MVI C , 09 LDA C001 LXI H, C002 ADD M INX H DCR C JNZ D008 STA C100 HLT
Rungta College of Engg. & Technology 323
MYcsvtu Notes
MYcsvtu Notes
324
information between main memory and the various peripheral devices attached to a computer.
special . Interface modules are used to match CPU and main memory characteristics to those of the peripheral devices
MYcsvtu Notes
325
is transferred are two critical factors of I/O devices. For example, a keyboard is a characterbased input device, and each character of a keyboard is inputted into a PC as an ASCII code. Keyboard input is very slow.
MYcsvtu Notes
326
keyboard. There is an expected input by an application program in response to a read statement of some kind that requests input of data for the program, think about dataentry into an expert system.
MYcsvtu Notes
327
the computer is doing. For example, under the Unix operating system typing Control-c will stop a program that is running, in contrast under a Windows type operating system typing Control-c is an editing command to copy data and typing Control, Alt, Delete will restart a PC. In terms of computation these are examples of unexpected inputs, since the program that is undergoing execution is not expecting such inputs or interrupts.
MYcsvtu Notes Rungta College of Engg. & Technology
328
connected to a single computer. The computer must have the capability to distinguish between the different keyboards. The computer must not lose input data even if several keyboards transmit a character input simultaneously. The computer must be able to respond quickly to each keyboard, and the physical distances of the keyboards to the computer may be long.
MYcsvtu Notes Rungta College of Engg. & Technology 329
interrupt? Disks, printers, screens and other I/O devices operate under the CPU program control. VDUs and most printers are output devices, and the output that is produced is determined by the program undergoing execution.
MYcsvtu Notes
330
discussed there can be a blur to this concept and disks can be considered to be both I/O devices as well as storage devices, where the input and the output are determined by the program undergoing execution. In these cases, it is always the program undergoing execution in the CPU that initiates I/O data transfer. Furthermore, the CPU will continue processing other tasks while waiting for a particular I/O operation to complete.
MYcsvtu Notes Rungta College of Engg. & Technology 331
addressed is busy or not ready. For example, a printer may already have a print job, or it may be stalled due to a miss feed of paper. There might not be a floppy disk in a floppy disk drive or a hard disk might be servicing a different request. In such cases, it is beneficial for the I/O device to be able to provide status information to the CPU, in order that appropriate action can be taken.
MYcsvtu Notes Rungta College of Engg. & Technology 332
different I/O devices. b) There must be mechanisms by which I/O devices can communicate with the CPU. c) Programmed I/O is suitable for slow devices and word transfers. d) Faster I/O devices must have mechanisms to transfer blocks of data. e) There must be mechanisms to handle devices with extremely different control requirements.
MYcsvtu Notes Rungta College of Engg. & Technology 333
directly to a CPU without some form of interface unit that is unique to each device.
are different. Some devices require a single portion of data, others a block of data. Some devices expect 8 bits of data, others 16, 32 or even 64.
MYcsvtu Notes
334
MYcsvtu Notes
requirements that must be met. Such control requirements would consume a vast amount of CPU time. I/O devices therefore have different requirements. Additionally, there is a necessity for the provision of addressing, synchronization, status control and external control capabilities. Consequently, each I/O device requires its own unique interface module to serve between itself and the CPU.
MYcsvtu Notes Rungta College of Engg. & Technology 336
Interface modules
Interface modules
single I/O device. Alternatively, interface modules can be complex, controlling many I/O devices and may have substantial built in intelligence
MYcsvtu Notes
337
have one important characteristic, which distinguishes whether they support parallel data transfer or serial data transfer. A parallel interface transfers multiple bits of data simultaneously using a separate data line for each bit.
MYcsvtu Notes
338
MYcsvtu Notes
339
MYcsvtu Notes
340
Interface modules
It is possible to transfer data a word[1] at a time, which
is adequate for slow operating I/O devices. However, the amount of data that is transferred between devices such as disks and tapes renders word transfer far too slow for modern high-speed computers. Consequently, blocks of data are transferred. A further problem is that a computer has many I/O devices, and many may attempt to transfer data simultaneously.
MYcsvtu Notes
341
Interface modules
Therefore, there is a requirement to distinguish and
separate I/O from these different devices. Different devices operate at different speeds to each other and the CPU. For example, a dot-matrix printer may output 40 characters/sec, whereas a disk might transfer data at millions of bytes/sec. To prevent data loss such I/O operations must be synchronized.
MYcsvtu Notes
342
Interface modules
A simple parallel I/O interface.
a control register and a status register, which can be accessed by the CPU over the system bus.
MYcsvtu Notes
343
Interface modules
The external data bus is a collection of parallel data
lines that can be configured to be either input or output by writing a suitable bit pattern into the control register.
MYcsvtu Notes
344
Interface modules
Once configured, data is transferred to or from the
external data bus by reading or writing from or to the data register or port. This data port, therefore, serves as a buffer between the system bus and the external data bus. The status register is used to flag whether a device is ready and data is available. The CPU by using the control bus can inspect the status register to determine whether data can be sent or received.
MYcsvtu Notes Rungta College of Engg. & Technology 345
a wide range of peripheral devices. The speeds of the different peripheral devices are usually known, therefore control or handshake signals are provided to synchronize the bus activities of the interface device and the I/O device, see Figure .
MYcsvtu Notes
346
transferred from an output port to a peripheral device such as a printer. A handshake protocol is used that uses two control lines: data available and data accepted. The handshake is initiated by the interface module, which puts data on the data bus and asserts the data available control line.
MYcsvtu Notes
347
detects this signal, it reads the data from the bus and broadcasts an acknowledgement by asserting the data accepted control line. When the interface module receives this acknowledgement, it negates the data available control line. After the printer has completed processing, it negates the data accepted control line and the handshake is completed.
MYcsvtu Notes
348
time. Even if a block of data is transferred between a disk and the CPU in a single instruction, a large amount of time is wasted waiting for the task to complete. For example, a CPU could execute many instructions in that time that a single character is printed. It is advantageous to enable the CPU to process other tasks while a slow I/O transfer is taking place.
MYcsvtu Notes
349
MYcsvtu Notes
350
between an I/O device and memory can be managed or scheduled: programmed I/O Interrupt-controlled I/O and Direct Memory Access (DMA).
MYcsvtu Notes
351
programmed to suit the needs of a particular peripheral device. With programmed I/O the CPU has control over all aspects of the data transfer. Each data transfer is carried out by executing a polling loop, such as the one shown in Figure.
MYcsvtu Notes
352
MYcsvtu Notes
353
to a peripheral device by first reading the port status register to see if the peripheral device is ready to transmit or receive data. In the case that the I/O device is ready because the examine flag is asserted, data is transferred and the processor loops back. In the case that the I/O device is not ready because the examine flag is negated, the processor loops back.
MYcsvtu Notes
354
polling loop, or busy waiting, can waste large amounts of CPU time, and it is therefore inefficient in terms of CPU usage. Programmed I/O is slow and is suitable for character transmission I/O devices such as printers, keyboards and monitors.
MYcsvtu Notes
355
interrupted to react to a special event. For example, typing Control, Alt, Delete on a PC interrupts the program that is running and restarts the PC. Interrupt driven I/O is more efficient than programmed I/O, because an I/O device signals the CPU when it requires a service.
MYcsvtu Notes Rungta College of Engg. & Technology
356
continue executing other tasks. Most computers have interrupt lines to detect and record the arrival of an interrupt request. It is common for a PC to have between 8 and 15 interrupt lines, which are labeled IRQ1, IRQ2 and so on, where IRQ represents Interrupt Request.
MYcsvtu Notes
357
suspends the program that is undergoing execution. When an interrupt is accepted, the CPU passes program control to an interrupt handler or service routine. Before control is passes to the interrupt handler, the PC and status register are saved by pushing them onto a Return Address Stack (RAS).
MYcsvtu Notes
358
Return from Exception (RTE) instruction is encountered at the end of the interrupt. Once the interrupt has been completed the PC and status register is popped from the RAS, and control is passed back to the interrupted program. Multiple interrupts can occur together, in which case a priority mechanism must decide the order in which the interrupts are handled.
MYcsvtu Notes Rungta College of Engg. & Technology 359
I/O. First, all data transfers involve moving data to and from the CPU registers. Second, since the PC and Status Register are pushed onto the RAS before control is passed to the interrupt handler and they are popped from the RAS when an RTE is encountered, then a significant overhead is involved which can impact on processor performance
MYcsvtu Notes
360
DMA I/O
Modes of I/O Transfer: DMA I/O An alternative mechanism that avoids the use of the
block devices such as magnetic disks use DMA, see storage device handout.
MYcsvtu Notes
361
DMA I/O
Data is directly transferred between a peripheral device
module notifies the CPU, so that the CPU is aware that the data transfer has completed and main memory access can then resume.
MYcsvtu Notes
362
DMA I/O
Data transfer is initiated using programmed I/O by the
program that is undergoing execution in the CPU. The CPU is then bypassed for the remainder of the interrupt. There are several advantages of DMA. First DMA is particularly good at fast data transfers. Second, since the CPU can be used for other tasks, then DMA is particularly useful in a multitasking system, and multi user systems.
MYcsvtu Notes
363
DMA I/O
DMA is not restricted to I/O device Memory transfers,
it can be used with other high-speed devices. For example, DMA is an effective means of transferring video data from memory to a video I/O device for rapid display.
MYcsvtu Notes
364
signify the beginning bit ASCII character would actually be transmitted using 10 bits e.g.: A "0100 0001" would become "1 0100 0001 0". The extra one (or zero depending on parity bit) at the start and end of the transmission tells the receiver first that a character is coming and secondly that the character has ended.
MYcsvtu Notes Rungta College of Engg. & Technology 365
intermittently as opposed to in a solid stream. In the previous example the start and stop bits are in bold. The start and stop bits must be of opposite polarity. This allows the receiver to recognize when the second packet of information is being sent.
MYcsvtu Notes
366
but instead synchronizes transmission speeds at both the receiving and sending end of the transmission using clock signals built into each component.
nodes.
MYcsvtu Notes
367
transfer rate is quicker although more errors will occur, as the clocks will eventually get out of sync, and the receiving device would have the wrong time that had been agreed in protocol (computing) for sending/receiving data, so some bytes could become corrupted (by losing bits). synchronization of the clocks and use of check digits to ensure the byte is correctly interpreted and received.
Rungta College of Engg. & Technology 368
MYcsvtu Notes
methods of sending data over a phone line. In synchronous data transmission, data is sent via a bitstream, which sends a group of characters in a single stream. In order to do this, modems gather groups of characters into a buffer, where they are prepared to be sent as such a stream.
MYcsvtu Notes
369
MYcsvtu Notes
370
the data stream is sent. In asynchronous transmission, data is coded into a series of pulses, including a start bit and a stop bit. A start bit is sent by the sending modem to inform the receiving modem that a character is to be sent. The character is then sent, followed by a stop bit designating that the transfer of that bit is complete
MYcsvtu Notes
371
Memory-Mapped I/O
I/O devices are treated like memory locations
addressing modes to access I/O devices I/O devices and memory locations cannot have the same address Address is 16 bits wide Memory of 64K is shared with I/O devices
MYcsvtu Notes
372
I/O-mapped I/O
Processor controls I/O by a group of dedicated control
signals Processor uses special instructions to access these I/O Each I/O (or port) is identified by a unique port number IN and OUT instructions are used. 256 combinations or 256 I/O devices can be assembled Same 8 bit address is copied to A0-A7 and A8 A15. 64 k memory and 256 I/O devices are available.
MYcsvtu Notes Rungta College of Engg. & Technology 373
ROM
WR
Input Buffer
Address Lines
CS
Address Lines
CS
Output Buffer
RD
Output Buffer
RD
Data Lines
Date Lines
Read op code
To read/write data Hence both EPROM & RAM are interfaced with it Multiple EPROM & RAM could be interfaced anywhere
MYcsvtu Notes
375
MYcsvtu Notes
376
operated. 8085 has 16 address lines It can address 64 k memory Interfacing means we have to place the available memory chip (2k,4k,8k,16k EPROM/RAM) with in the 64 k byte address range)
MYcsvtu Notes
377
Mapping Memory could be placed anywhere Mapping decides address of the memory component Its not necessary to use 64 KB of memory It depends on the application We can expand the memory in order to get the memory size we want.
MYcsvtu Notes
378
one EPROM is necessary at 0000 h Some address lines of 8085 are used to connect directly to the memory chip. Some are used for decoding the address of the memory chip. This may require the use of the decoder IC 74LS138. All these steps depend on the range of the memory chip to be connected to 8085
MYcsvtu Notes Rungta College of Engg. & Technology
379
Accessing memory can be summarized into the following three steps: Select the chip. Identify the memory register. Enable the appropriate buffer.
MYcsvtu Notes
380
Address decoding
The result of address decoding is the identification of a
register for a given address. A large part of the address bus is usually connected directly to the address inputs of the memory chip. This portion is decoded internally within the chip. What concerns us is the other part that must be decoded externally to select the chip. This can be done either using logic gates or a decoder.
MYcsvtu Notes Rungta College of Engg. & Technology 382
8085
A15-A8
ALE
CS
AD7-AD0
Latch
A9- A0 A7- A0
WR RD
IO/M
D7- D0
RD WR
MYcsvtu Notes
383
1000 H 4K RAM
1FFF H
MYcsvtu Notes
384
FFFF H
MYcsvtu Notes
385
COOO H 4K EPROM
CFFF H
FFFF H
MYcsvtu Notes
386
8000 H Sol Placing the starting address of the chip on the address lines of 8085 we have
A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 1
0 0 0 0 0 0 0 0 0 0
MYcsvtu Notes
387
= 2 ^ 11 Hence 11 address lines (A0-A10) are connected directly to the memory chip and A15 to A11 are used for selecting the chip
MYcsvtu Notes
388
Hence the range of the chip is from 8000 H to 87FF H. A15 to A11 are used to select the chip using the NAND gate. The chip is selected by providing a low signal at its chip select
pin. The A15 to A11 address lines are used as inputs to the NAND gate. Their logic is so adjusted so that the output of NAND gate is low.
MYcsvtu Notes Rungta College of Engg. & Technology 389
address lines Address lines which are not really required for selection of chip could be used for finding different address range of a single memory chip
MYcsvtu Notes
390
The address range of the given chip is obtained as follows A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0 0
MYcsvtu Notes
391
follows A15 A14 0 0 0 1 1 0 1 1 we have the different address range of the same chip as followsMYcsvtu Notes Rungta College of Engg. & Technology 392
03FF H 4000 H 43FF H 8000 H 83FF H C000 H C3FF H This results in wastage of address space.
MYcsvtu Notes
393
MYcsvtu Notes
394
Absolute decoding
In absolute decoding no address space is wasted
MYcsvtu Notes
395
UNIT- IV INTERRUPTS
MYcsvtu Notes
396
Interrupts
Interrupt is a process where an external device can get
The process starts from the I/O device The process is asynchronous.
MYcsvtu Notes
397
Interrupts
Classification of Interrupts
Rejected)
MYcsvtu Notes
398
Interrupts
Interrupts can also be classified into: Vectored (the address of the service routine is hard-
wired) Non-vectored (the address of the service routine needs to be supplied externally by the device)
An interrupt is considered to be an emergency signal
MYcsvtu Notes
Interrupts
What happens when MP is interrupted ? When the Microprocessor receives an interrupt signal, it
suspends the currently executing program and jumps to an Interrupt Service Routine (ISR) to respond to the incoming interrupt.
Each interrupt will most probably have its own ISR.
MYcsvtu Notes
400
Responding to Interrupts
Responding to an interrupt may be immediate or
delayed depending on whether the interrupt is maskable or non-maskable and whether interrupts are being masked or not.
MYcsvtu Notes
401
Responding to Interrupts
There are two ways of redirecting the execution to the
ISR depending on whether the interrupt is vectored or non-vectored. Vectored: The address of the subroutine is already known to the Microprocessor Non Vectored: The device will have to supply the address of the subroutine to the Microprocessor
MYcsvtu Notes
402
give a service which is equivalent to asking the MP to call a subroutine. This subroutine is called ISR (Interrupt Service Routine) The EI instruction is a one byte instruction and is used to Enable the non-maskable interrupts. The DI instruction is a one byte instruction and is used to Disable the non-maskable interrupts.
MYcsvtu Notes
403
The non-maskable interrupt is not affected by the value of the Interrupt Enable flip flop.
MYcsvtu Notes
404
Interrupts in 8085
Interrupt Save program counter Send out interupt acknowledge Disable interrupts
INTA
Go to service routine
EI RET
Service routine
MYcsvtu Notes
405
MYcsvtu Notes
406
Hardware Interrupts
The 8085 has 5 interrupt inputs.
The INTR input. The INTR input is the only non-vectored interrupt. INTR is maskable using the EI/DI instruction pair. RST 5.5, RST 6.5, RST 7.5 are all automatically vectored. RST 5.5, RST 6.5, and RST 7.5 are all maskable. TRAP is the only non-maskable interrupt in the 8085 TRAP is also automatically vectored
Interrupts
Interrupt name INTR RST 5.5 RST 6.5 RST 7.5 TRAP Maskable Yes Yes Yes Yes No Vectored No Yes Yes Yes Yes
MYcsvtu Notes
408
8085 Interrupts
TRAP RST7.5 RST6.5 RST 5.5 INTR INTA
8085
MYcsvtu Notes
409
stored in memory. All interrupts (vectored or otherwise) are mapped onto a memory area called the Interrupt Vector Table (IVT). The IVT is usually located in memory page 00 (0000H - 00FFH). The purpose of the IVT is to hold the vectors that redirect the microprocessor to the right place when an interrupt arrives.
MYcsvtu Notes Rungta College of Engg. & Technology 410
using the RST 7.5 interrupt line. Because the RST 7.5 interrupt is vectored, Microprocessor knows , in which memory location it has to go using a call instruction to get the ISR address. RST7.5 is knows as Call 003Ch to Microprocessor. Microprocessor goes to 003C location and will get a JMP instruction to the actual ISR address. The Microprocessor will then, jump to the ISR location
MYcsvtu Notes
411
The interrupt process should be enabled using the EI instruction. The 8085 checks for an interrupt during the execution of every instruction. If INTR is high, MP completes current instruction, disables the interrupt and sends INTA (Interrupt acknowledge) signal to the device that interrupted
MYcsvtu Notes
412
through data bus. Upon receiving the INTA signal, MP saves the memory location of the next instruction on the stack and the program is transferred to call location (ISR Call) specified by the RST instruction
MYcsvtu Notes
413
Microprocessor Performs the ISR. ISR must include the EI instruction to enable the further interrupt within the program. RET instruction at the end of the ISR allows the MP to retrieve the return address from the stack and the program is transferred back to where the program was interrupted
MYcsvtu Notes
414
Each of these would send the execution to a predetermined hard-wired memory location:
MYcsvtu Notes
415
Equivalent to CALL 0000H CALL 0008H CALL 0010H CALL 0018H CALL 0020H CALL 0028H CALL 0030H CALL 0038H
416
Restart Sequence
The restart sequence is made up of three machine
cycles In the 1st machine cycle: The microprocessor sends the INTA signal. While INTA is active the microprocessor reads the data lines expecting to receive, from the interrupting device, the opcode for the specific RST instruction.
MYcsvtu Notes
417
Restart Sequence
In the 2nd and 3rd machine cycles: the 16-bit address of the next instruction is saved on the stack. Then the microprocessor jumps to the address associated with the specified RST instruction.
MYcsvtu Notes
418
MYcsvtu Notes
419
the appropriate RST instruction? The op code is simply a collection of bits. So, the device needs to set the bits of the data bus to the appropriate value in response to an INTA signal.
MYcsvtu Notes
420
MYcsvtu Notes
421
1st machine cycle of the RST operation): The Microprocessor activates the INTA signal. This signal will enable the Tri-state buffers, which will place the value EFH on the data bus. Therefore, sending the Microprocessor the RST 5 instruction.
0028H
MYcsvtu Notes
422
The microprocessor checks the INTR line one clock cycle before the last T-state of each instruction. The INTR must remain active long enough to allow for the longest instruction. The longest instruction for the 8085 is the conditional CALL instruction which requires 18 T-states.
MYcsvtu Notes
423
T-
states. If f= 3MHZ then T=1/f and so, INTR must remain active for [ (1/3MHZ) * 17.5 5.8 micro seconds].
MYcsvtu Notes
424
The INTR line must be deactivated before the EI is executed. Otherwise, the microprocessor will be interrupted again. Once the microprocessor starts to respond to an INTR interrupt, INTA becomes active (=0). Therefore, INTR should be turned off as soon as the INTA signal is received.
MYcsvtu Notes
425
INTR line? The microprocessor can only respond to one signal on INTR at a time. Therefore, we must allow the signal from only one of the devices to reach the microprocessor. We must assign some priority to the different devices and allow their signals to reach the microprocessor according to the priority.
MYcsvtu Notes Rungta College of Engg. & Technology 426
encoder (74LS148). This circuit has 8 inputs and 3 outputs. The inputs are assigned increasing priorities according to the increasing index of the input. Input 7 has highest priority and input 0 has the lowest. The 3 outputs carry the index of the highest priority active input.
MYcsvtu Notes Rungta College of Engg. & Technology 427
follow a set pattern. Bit D5, D4 and D3 of the op codes change in a binary sequence from RST 7 down to RST 0. The other bits are always 1. This allows the code generated by the 74366 to be used directly to choose the appropriate RST instruction. The one draw back to this scheme is that the only way to change the priority of the devices connected to the 74366 is to reconnect the hardware.
MYcsvtu Notes Rungta College of Engg. & Technology
428
MYcsvtu Notes
429
RST 5.5, RST 6.5, RST 7.5 They are all maskable. They are automatically vectored according to the following table: Interrupt Vector RST 5.5 002CH RST 6.5 0034H RST 7.5 003CH
Rungta College of Engg. & Technology 430
MYcsvtu Notes
vectors for the RST instructions. Thats why they have names like RST 5.5 (RST 5 and a half).
MYcsvtu Notes
431
Through the Interrupt Enable flip flop and the EI/DI instructions. The Interrupt Enable flip flop controls the whole maskable interrupt process. Through individual mask flip flops that control the availability of the individual interrupts. These flip flops control the interrupts individually.
MYcsvtu Notes
432
Interrupt Structure
MYcsvtu Notes
433
The interrupt process should be enabled using the EI instruction. The 8085 checks for an interrupt during the execution of every instruction. If there is an interrupt, and if the interrupt is enabled using the interrupt mask, the microprocessor will complete the executing instruction, and reset the interrupt flip flop.
MYcsvtu Notes
434
The microprocessor then executes a call instruction that sends the execution to the appropriate location in the interrupt vector table. When the microprocessor executes the call instruction, it saves the address of the next instruction on the stack. The microprocessor jumps to the specific service routine. The service routine must include the instruction EI to re-enable the interrupt process.
Rungta College of Engg. & Technology 435
MYcsvtu Notes
The Interrupt Enable flip flop is manipulated using the EI/DI instructions.
MYcsvtu Notes
436
MYcsvtu Notes
437
RST5.5 Mask 0 - Available RST6.5 Mask 1 - Masked RST7.5 Mask Mask Set Enable 0 - Ignore bits 0-2 1 - Set the masks according to bits 0-2
Not Used
MYcsvtu Notes
438
If the mask bit is 0, the interrupt is available. If the mask bit is 1, the interrupt is masked.
MYcsvtu Notes
439
the mask. If it is set to 0 the mask is ignored and the old settings remain. If it is set to 1, the new setting are applied. The SIM instruction is used for multiple purposes and not only for setting interrupt masks. It is also used to control functionality such as Serial Data Transmission. Therefore, bit 3 is necessary to tell the microprocessor whether or not the interrupt masks should be modified
MYcsvtu Notes Rungta College of Engg. & Technology 440
memory. If a signal on RST7.5 arrives while it is masked, a flip flop will remember the signal. When RST7.5 is unmasked, the microprocessor will be interrupted even if the device has removed the interrupt signal. This flip flop will be automatically reset when the microprocessor responds to an RST 7.5 interrupt.
MYcsvtu Notes
441
explicitly resetting the RST 7.5 memory even if the microprocessor did not respond to it.
Bit 5 is not used by the SIM instruction
MYcsvtu Notes
442
MYcsvtu Notes
443
MYcsvtu Notes
444
MYcsvtu Notes
445
Triggering Levels
RST 7.5 is positive edge sensitive.
When a positive edge appears on the RST7.5 line, a logic 1 is stored in the flip-flop as a pending interrupt. Since the value has been stored in the flip flop, the line does not have to be high when the microprocessor checks for the interrupt to be recognized. The line must go to zero and back to one before a new interrupt is recognized.
Triggering Levels
RST 6.5 and RST 5.5 are level sensitive.
The interrupting signal must remain present until the microprocessor checks for interrupts.
MYcsvtu Notes
447
Load the accumulator with an 8-bit pattern showing the status of each interrupt pin and mask.
RST7.5 Memory RST 7.5
M 7.5
5 4
RST 6.5
M 6.5
RST 5.5
M 5.5
MYcsvtu Notes Rungta College of Engg. & Technology
448
SDI P7.5 P6.5 P5.5 IE M7.5 M6.5 M5.5 RST5.5 Mask RST6.5 Mask RST7.5 Mask
Serial Data In RST7.5 Interrupt Pending RST6.5 Interrupt Pending RST5.5 Interrupt Pending
0 - Available 1 - Masked
MYcsvtu Notes
449
RST 7.5, RST 6.5 and RST 5.5 They return the contents of the three mask flip flops. They can be used by a program to read the mask settings in order to modify only the right mask.
MYcsvtu Notes
450
enabled or not. It returns the contents of the Interrupt Enable Flip Flop. It can be used by a program to determine whether or not interrupts are enabled.
MYcsvtu Notes
451
interrupts on RST 7.5, RST 6.5, and RST 5.5 Bits 4 and 5 return the current value of the RST5.5 and RST6.5 pins. Bit 6 returns the current value of the RST7.5 memory flip flop.
MYcsvtu Notes
452
The RIM instruction reads the value of the SID pin on the microprocessor and returns it in this bit.
MYcsvtu Notes
453
Pending Interrupts
Since the 8085 has five interrupt lines, interrupts may
Using the RIM instruction, it is possible to can read the status of the interrupt lines and find if there are any pending interrupts.
MYcsvtu Notes
454
TRAP
TRAP is the only non-maskable interrupt.
It does not need to be enabled because it cannot be disabled. It has the highest priority amongst interrupts. It is edge and level sensitive.
MYcsvtu Notes
455
TRAP
It needs to be high and stay high to be recognized. Once it is recognized, it wont be recognized again until it goes low, then high again.
shutoff.
MYcsvtu Notes
456
Yes
No
No
Yes
Yes
No
Yes
Yes
Yes
TRAP
MYcsvtu Notes
No
None
Yes
No
Interrupt Programs
Enable all interrupts of 8085
MYcsvtu Notes
458
Interrupt Programs
Program
EI
MVI A, 08 H SIM
MYcsvtu Notes
459
Interrupt Programs
Assume microprocessor is completing an RST 7.5
interrupt request, check to see if RST 6.5 is pending . If it is pending enable RST 6.5 without affecting any other interrupts, otherwise return to main program
MYcsvtu Notes
460
Interrupt Programs
Program RIM MOV B,A ANI 20H JNZ NEXT EI RET NEXT MOV A,B ANI 0D H ORI 08 H SIM RET
Rungta College of Engg. & Technology 461
MYcsvtu Notes
MYcsvtu Notes
462
additional support devices were introduced to enable the 85 to be adapted to a great variety of system organizations. A few are listed here.
MYcsvtu Notes
463
8251-Communication Controller
8253-Programmable Interval Timer 8254-Programmable Interval Timer 8255-Programmable Peripheral Interface 8257-DMA Controller 8259-Programmable Interrupt Controller 8279-KeyBoard/Display Controller 8755-EPROM+2 I/O Ports
MYcsvtu Notes Rungta College of Engg. & Technology 464
MYcsvtu Notes
465
Vcc=5V, Vss=0V
MYcsvtu Notes
466
8355/8755
8085ROMI/OLSI 8355 for the 8085 circuit has been
designed around ROM and parallel I / O ports are integrated in the LSI. 80858088 Address and data bus interfaces directly by the state because they can more 8085 to 8088 can also be applied. ROM8755UV EPROM 8355 mask ROM, 8755 is a builtin UV EPROM.
MYcsvtu Notes
467
8355/8755
Port and DDR
addresses
A1 A0 Port/DD R
0
0 1 1
MYcsvtu Notes
0
1 0 1
Port A
Port B DDR A DDR B
Rungta College of Engg. & Technology 468
Asynchronous Receiver Transmitter) for serial data communication. As a peripheral device of a microcomputer system, the 8251 receives parallel data from the CPU and transmits serial data after conversion. This device also receives serial data from the outside and transmits parallel data to the CPU after conversion.
MYcsvtu Notes
469
MYcsvtu Notes
470
8251 USART
The 8251 functional configuration is programmed by
software. Operation between the 8251 and a CPU is executed by program control. Table shows the operation between a CPU and the device.
MYcsvtu Notes
471
8251 USART
Control Words There are two types of control word. 1. Mode instruction (setting of function) 2. Command (setting of operation)
MYcsvtu Notes
472
8251 USART
Mode Instruction
8251. Mode instruction will be in "wait for write" at either internal reset or external reset. That is, the writing of a control word after resetting will be recognized as a "mode instruction." Items set by mode instruction are as follows: Synchronous/asynchronous mode Stop bit length (asynchronous mode) Character length
MYcsvtu Notes Rungta College of Engg. & Technology
473
8251 USART
Parity bit
mode)
MYcsvtu Notes
474
8251 USART
The bit configuration of mode instruction is shown in
Figures. In the case of synchronous mode, it is necessary to write one-or two byte sync characters. If sync characters were written, a function will be set because the writing of sync characters constitutes part of mode instruction.
MYcsvtu Notes
475
MYcsvtu Notes
476
MYcsvtu Notes
477
8251 USART
Command Command is used for setting the operation of the 8251.
It is possible to write a command whenever necessary after writing a mode instruction and sync characters.
MYcsvtu Notes
478
8251 USART
Items to be set by command are as follows: Transmit Enable/Disable Receive Enable/Disable DTR, RTS Output of data. Resetting of error flag. Sending to break characters Internal resetting Hunt mode (synchronous mode)
MYcsvtu Notes
479
MYcsvtu Notes
480
8251 USART
Status Word It is possible to see the internal status of the 8251 by
reading a status word. The bit configuration of status word is shown in Fig
MYcsvtu Notes
481
MYcsvtu Notes
482
words and transmits data from the CPU and sends status words and received data to CPU.
RESET (Input terminal) A "High" on this input forces the 8251 into "reset
status." The device waits for the writing of "mode instruction." The min. reset width is six clock inputs during the operating status of CLK.
MYcsvtu Notes Rungta College of Engg. & Technology 483
CLK signal is independent of RXC or TXC. However, the frequency of CLK must be greater than 30 times the RXC and TXC at Synchronous mode and Asynchronous "x1" mode, and must be greater than 5 times at Asynchronous "x16" and "x64" mode.
MYcsvtu Notes
484
signal for writing transmit data and control words from the CPU into the 8251.
RD (Input terminal) This is the "active low" input terminal which receives a
signal for reading receive data and status words from the 8251.
Rungta College of Engg. & Technology
MYcsvtu Notes
485
selecting data or command words and status words when the 8251 is accessed by the CPU. If C/D = low, data will be accessed. If C/D = high, command word or status word will be accessed.
MYcsvtu Notes
486
8251 at low level when the CPU accesses. Note: The device wont be in "standby status"; only setting CS = High.
MYcsvtu Notes
487
which serial-converted data is sent out. The device is in "mark status" (high level) after resetting or during a status when transmit is disabled. It is also possible to set the device in "break status" (low level) by a command.
MYcsvtu Notes
488
8251is ready to accept a transmitted data character. But the terminal is always at low level if CTS = high or the device was set in "TX disable status" by a command. Note: TXRDY status word indicates that transmit data character is receivable, regardless of CTS or command. If the CPU writes a data character, TXRDY will be reset by the leading edge or WR signal.
MYcsvtu Notes Rungta College of Engg. & Technology 489
has transmitted all the characters and had no data character. In "synchronous mode," the terminal is at high level, if transmit data characters are no longer remaining and sync characters are automatically transmitted. If the CPU writes a data character, TXEMPTY will be reset by the leading edge of WR signal.
MYcsvtu Notes
490
"High" or command, data written before disable will be sent out. Then TXD and TXEMPTY will be "High". Even if a data is written after disable, that data is not sent out and TXE will be "High". After the transmitter is enabled, it sent out.
MYcsvtu Notes
491
transfer speed of transmitted data. In "synchronous mode," the baud rate will be the same as the frequency of TXC. In "asynchronous mode", it is possible to select the baud rate factor by mode instruction. It can be 1, 1/16 or 1/64 the TXC. The falling edge of TXC sifts the serial data out of the 8251.
MYcsvtu Notes Rungta College of Engg. & Technology
492
a character that is ready to READ. If the CPU reads a data character, RXRDY will be reset by the leading edge of RD signal. Unless the CPU reads a data character before the next one is received completely, the preceding data will be lost. In such a case, an overrun error flag status word will be set.
MYcsvtu Notes Rungta College of Engg. & Technology
493
transfer speed of received data. In "synchronous mode," the baud rate is the same as the frequency of RXC. In "asynchronous mode," it is possible to select the baud rate factor by mode instruction. It can be 1, 1/16, 1/64 the RXC.
MYcsvtu Notes Rungta College of Engg. & Technology
494
mode. In "internal synchronous mode." this terminal is at high level, if sync characters are received and synchronized. If a status word is read, the terminal will be reset. In "external synchronous mode, "this is an input terminal.
MYcsvtu Notes
495
data characters. In "asynchronous mode," this is an output terminal which generates "high level output upon the detection of a "break" character if receiver data contains a "lowlevel" space between the stop bits of two continuous characters. The terminal will be reset, if RXD is at high level. After Reset is active, the terminal will be output at low level.
MYcsvtu Notes
496
used for controlling a transmit circuit. The terminal controls data transmission if the device is set in "TX Enable" status by a command. Data is transmittable if the terminal is at low level. RTS (Output terminal) This is an output port for MODEM interface. It is possible to set the status RTS by a command.
MYcsvtu Notes Rungta College of Engg. & Technology 498
Interface chip is a peripheral chip originally developed for the Intel 8085 microprocessor, and as such is a member of a large array of such chips, known as the MCS-85 Family. This chip was later also used with the Intel 8086 and its descendants. It was later made (cloned) by many other manufacturers.
MYcsvtu Notes
499
programmable parallel I/O, and is similar to other such chips like the Motorola 6520 PIA (Peripheral Interface Adapter) the MOS Technology 6522 (Versatile Interface adapter) and the MOS Technology CIA (Complex interface Adapter) all developed for the 6502 family.
the Western Design Center WDC 65C21, an enhanced 6520, and many others. all MSX, but is perhaps most well known for its use in the original IBM-PC's parallel printer port (now largely defunct and replaced by the USB standard, and considered a legacy port).
Rungta College of Engg. & Technology
MYcsvtu Notes
501
is now not implemented with the 8255 chip itself anymore, but is embedded in a larger VLSI chip as a sub function.
MYcsvtu Notes
502
MYcsvtu Notes
503
8255 PPI
Features: 3 8-bit IO ports PA, PB, PC PA can be set for Modes 0, 1, 2. PB for 0,1 and PC for
mode 0 and for BSR. Modes 1 and 2 are interrupt driven. PC has 2 4-bit parts: PC upper (PCU) and PC lower (PCL), each can be set independently for I or O. Each PC bit can be set/reset individually in BSR mode.
MYcsvtu Notes
504
8255 PPI
PA and PCU are Group A (GA) and PB and PCL are
Group B (GB) Address/data bus must be externally demux'd. TTL compatible. Improved dc driving capability
MYcsvtu Notes
505
8255 PPI
Block diagram
MYcsvtu Notes
506
8255 PPI
The 8255A is a programmable peripheral interface (PPI)
device designed for use in Intel microcomputer systems. Its function is that of a general purposes I/O component to Interface peripheral equipment to the microcomputer system bush. The functional configuration of the 8255A is programmed by the systems software so that normally no external logic is necessary to interface peripheral devices or structures.
MYcsvtu Notes
507
8255 PPI
Data Bus Buffer
interface the 8255A to the systems data bus. Data is transmitted or received by the buffer upon execution of input or output instructions by the CPU. Control words and status information are also transferred through the data bus buffer.
MYcsvtu Notes
508
8255 PPI
Read/Write and Control Logic
and External transfers of both Data and Control or Status words. It accepts inputs from the CPU Address and Control business and in turn, issues commands to both of the Control Groups.
MYcsvtu Notes
509
8255 PPI
(CS) Chip Select A low on this input pin enables the communication
(RD) Read. A low on this Input pin enables the 8255A to send the
data or status information to the CPU on the data bus. In essence, it allows the CPU to read from the 8255A.
MYcsvtu Notes
510
8255 PPI
(WR) Write. A low on the input pin enables the CPU to write data
(A0 and A1) Port Select 0 and Port Select 1. The Input signals, in conjunction with the RD and WR
Inputs, controls the selection of one of the three ports or the control word registers. They are normally connected to the least significant bits of the address bus (A0 and A1).
MYcsvtu Notes Rungta College of Engg. & Technology 511
8255 PPI
(RESET)
Reset
A high on this Input clears the control register and all
MYcsvtu Notes
512
8255 PPI
Group A and Group B Controls
by the systems software. In essence, the CPU output a control word to the 8255A. The control word contains information such as mode, bit set, bit reset, etc. that Initializes the functional configuration of the 8255A.
MYcsvtu Notes
513
8255 PPI
Each of the Control blocks (Group A and Group B)
accepts commands from the Read/Write Control Logic, receives control words from the internal data bus and issues the proper commands to its associated ports.
MYcsvtu Notes
514
8255 PPI
Control Group A
allowed.
MYcsvtu Notes
515
8255 PPI
Ports A, B, and C The 8255A contains three 8-bit ports (A , B, and C). All can be configured in a wide variety of functional
characteristics by the system software but each has its own special features or personally to further enhance the power and flexibility of the 8255A.
MYcsvtu Notes
516
8255 PPI
Port A- One 8 bit data output latch/buffer and one 8-bit
data input latch. Port B - One 8-bit data output latch/buffer and one 8-bit data input buffer. Port C-One 8-bit data output latch/buffer and one 8-bit data input buffer (no latch for input). This port can be divided into two 4-bit ports under the mode control. Each 4-bit port contains a 4-bit latch and it can be used for the controls signal outputs and status signal inputs in conjunction with ports A and B.
MYcsvtu Notes Rungta College of Engg. & Technology 517
selected by the systems software: Mode 0 Basic Input/Output Mode 1 Strobed Input/Output Mode 2 Bi-Directional Bus
MYcsvtu Notes
518
the Input mode (i.e., all 24 lines will be in the high Impedance state). After the reset is removed the 8255A can remain in the input mode with no additional Initialization required. During the execution of the systems program any of the other modes may be selected using a single output Instruction. This allows a single 8255A to service a variety of peripheral devices with a simple software maintenance routine.
MYcsvtu Notes Rungta College of Engg. & Technology
519
defined, while Port C is divided into two portions as required by the Port A and Port B definitions. All of the output registers, including the status flip-flops, will be reset whenever the mode is changed. Modes may be combined so that their functional definition can be tailored to almost any I/O stricture. For instance; Group B can be programmed in Mode 0 to monitor simple switch closing or display computational results, Group A could be programmed in Mode 1 to monitor a keyboard or tape reader on an interruptdriven basis.
MYcsvtu Notes Rungta College of Engg. & Technology
520
MYcsvtu Notes
521
MYcsvtu Notes
522
may seem confusing at first but after a cursory review of the complete device operation a simple , logical I/O approach will surface. The design of the 8255A has taken into account things such as efficient PC board layout, control signal definition vs PC layout and complete functional flexibility to support almost any peripheral device with no use of the available pints.
MYcsvtu Notes Rungta College of Engg. & Technology 523
a single OUT put Instruction. This feature reduces software requirements in Controlbased applications. When Port C is being used as status/control for Port A or B.These Bits can be set or reset by using the Bit set/reset operation just as if they were data output port.
MYcsvtu Notes
524
MYcsvtu Notes
525
or mode 2, control signals are provided that can used as interrupt request input to the CPU. The interrupt request signal generated from port C, can be inhibited or enabled by setting or resetting the associated INTE flip-flop, using the bit set/reset function of port C. This function allows the Programmer to disallow or allow a specific I/O device to interrupt the CPU without affecting any other device in the interrupt structure.
MYcsvtu Notes Rungta College of Engg. & Technology 526
MYcsvtu Notes
527
operations for each of the three ports. No handshaking is required data is simply written to or read from a specified port.
MYcsvtu Notes
528
in this Mode.
MYcsvtu Notes
529
transferring I/O data to or from a specified port in conjunction with strobes or handshaking signals. In mode 1, port A and Port B use the lines on port C to generate or accept these handshaking signals.
MYcsvtu Notes
530
control/data port The 8-bit data port can be either Inputs or output Both inputs and outputs are latched. The 4-bit port is used for control and status of the 8-bit data port.
MYcsvtu Notes
531
loaded into the input latch. In essence, an acknowledgement. IBF is set by STB input being low and is reset by the rising edge of the RD input.
MYcsvtu Notes Rungta College of Engg. & Technology
532
when an input device is requesting service, INTR is set by the STB is a one, IBF is a one and INTE is one . It is reset by the falling edge of RD. This procedure allows an input device to request service from the CPU by simply strobing its data into port. INTE A Controlled by bit set/reset of PC4 INTE B Controlled by set/reset PC2
MYcsvtu Notes Rungta College of Engg. & Technology
533
MYcsvtu Notes
534
has written data out to the specified port. The OBF F/F will be set by rising edge of the WR input being low. ACK (Acknowledge Input). A low on this input informs the 8255A that the data from port A or port B has been accepted.
MYcsvtu Notes Rungta College of Engg. & Technology 535
indicating that it has received the data output by CPU. INTR (Interrupt Request). A high on the output can be used to interrupt the CPU when an output device has accepted data transmitted by the CPU. INTR is set when ACK is a one, OBF is a one, and INTE is a one. It is reset by the falling edge of WR. INTE A - Controlled by bit set/reset of PC6. INTE B - Controlled by bit set/reset of PC2.
MYcsvtu Notes Rungta College of Engg. & Technology 536
MYcsvtu Notes
537
Individually defined as Input or output in Mode 1 to support a wide variety of strobed I/O application.
MYcsvtu Notes
538
communicating with a peripheral device or structure on a single 8-bit bus for both transmitting and receiving data (bi-directional bus I/O). Handshaking signals are provided to maintain proper bus flow discipline in a similar manner to MODE.1. Interrupt generation and enable/disable functions are also available.
MYcsvtu Notes
539
control Port (Port C). Both Inputs and Outputs are latched. The 5-bit control port (Port C) is used for control and status for the 8-bit,bi-directional bus port (Port A).
MYcsvtu Notes
540
MYcsvtu Notes
541
has written data out to port A. ACK (Acknowledge). A low on this input enables the tri-state output buffer of port A to send out the data. Otherwise, the output buffer will be in the high impedance state. INTE 1 (The INTE Flip-Flop Associated with OBF). Controlled by bit set/reset of PC6
MYcsvtu Notes Rungta College of Engg. & Technology 542
MYcsvtu Notes
543
1
MYcsvtu Notes
CONTROL REGISTER
Rungta College of Engg. & Technology 544
0(0=B X SR)
MYcsvtu Notes
GA mode select
MYcsvtu Notes
546
00 = mode0 01 = mode1 1X = mode2 D4(PA), D3(PCU): 1=input D2: GB mode select: 0=mode0 D1(PB), D0(PCL): 1=input
MYcsvtu Notes
547
MYcsvtu Notes
548
PC BITS IN OUTPUT MODE OBF-Abar INTE-A / ACK-Abar PC5 PC4 INTR-A INTE-B / ACK-Bbar OBF-Bbar INTR-B
MYcsvtu Notes
549
connected to external peripheral's strobe output (i.e. PC2, PC4 pin to external strobe).
connection.
MYcsvtu Notes
550
connected to external peripheral's acknowledge output (i.e. PC2, PC6 pin to external ack).
INTE is internal connection. ACK-bar is external
connection.
MYcsvtu Notes
551
Only for PA
Status:
D7
D6
D5
D4
D3
D2
D1
D0
OBF- INTE IBF-A INTE INTR X A-bar 1(O/P 2(I/P) -A )/ / ACKSTBAA-Bar BAR
MYcsvtu Notes Rungta College of Engg. & Technology
552
MYcsvtu Notes
553
MYcsvtu Notes
554
writes between micro and 8279. BD: Output that blanks the displays. CLK: Used internally for timing. Max is 3 MHz. CN/ST: Control/strobe, connected to the control key on the keyboard. CS: Chip select that enables programming, reading the keyboard, etc. DB7-DB0: Consists of bidirectional pins that connect to data bus on micro.
MYcsvtu Notes Rungta College of Engg. & Technology 555
pressed, data is available. OUT A3-A0/B3-B0: Outputs that sends data to the most significant/least significant nibble of display. RD(WR): Connects to micro's IORC or RD signal, reads data/status registers. RESET: Connects to system RESET.
MYcsvtu Notes
556
depression in the keyboard matrix. Shift: Shift connects to Shift key on keyboard. SL3-SL0: Scan line outputs scan both the keyboard and displays.
MYcsvtu Notes
557
MYcsvtu Notes
558
counting operation. The 74LS138 drives 0's on one line at a time. The 8279 scans RL pins synchronously with the scan. RL pins incorporate internal pull-ups, no need for external resistor pull-ups.
MYcsvtu Notes
559
Purpose Selects the number of display positions, type of key scan Programs internal clk, sets scan and debounce times. FIFO Selects type of FIFO read and address of the read.
560
001
Clock
010
Read
MYcsvtu Notes
Purpose Selects type of display read and address of the read. Selects type of write and address of the write. write inhibit Allows halfbytes to be blanked. Clears the display or FIFO Clears the IRQ signal to microprocessor
561
MYcsvtu Notes
registers (opcode). 000DDMMM Mode set: Opcode 000. DD sets displays mode. MMM sets keyboard mode. DD field selects either: 8- or 16-digit display Whether new data are entered to the rightmost or leftmost display position
MYcsvtu Notes Rungta College of Engg. & Technology
562
DD
00 01 10 11
Function 8-digit display with left entry 16-digit display with left entry 8-digit display with right entry 16-digit display with right entry
MYcsvtu Notes
563
000 001
010
011 100 110 111
MYcsvtu Notes
Encoded keyboard with 2-key lockout Decoded keyboard with 2-key lockout Encoded keyboard with N-key rollover Decoded keyboard with N-key rollover Encoded sensor matrix101Decoded sensor matrix Strobed keyboard, encoded display scan Strobed keyboard, decoded display scan
Rungta College of Engg. & Technology 564
2-key lockout/N-key rollover: Prevents 2 keys from being recognized if pressed simultaneously/Accepts all keys pressed from 1st to last.
MYcsvtu Notes
566
The clock command word programs the internal clock driver. The code PPPPP divides the clock input pin (CLK) to achieve the desired operating frequency, e.g. 100KHz requires 01010 for a 1 MHz CLK input.
010Z0AAA
The read FIFO control word selects the address (AAA) of a keystroke from the FIFO buffer (000 to 111). Z selects auto-increment for the address.
The display read control word selects the read address of one of the display RAM positions for reading through the data port.
100ZAAAA
Selects write address -- Z selects auto-increment so subsequent writes go to subsequent display positions.
Rungta College of Engg. & Technology 568
MYcsvtu Notes
The display write inhibit control word inhibits writing to either the leftmost 4 bits of the display (left W) or rightmost 4 bits. BB works similarly except that they blank (turn off) half of the output pins.
MYcsvtu Notes
569
The clear control word clears the display, FIFO or both. Bit F clears FIFO and the display RAM status, and sets address pointer to 000. If CC are 00 or 01, all display RAM locations become 00000000. If CC is 10, --> 00100000, if CC is 11, --> 11111111. 1110E000 -End of Interrupt control word is issued to clear IRQ pin in sensor matrix mode.
The previous example illustrates an encoded keyboard, external decoder used to drive matrix.
MYcsvtu Notes
571
the keyboard. To determine if a character has been typed, the FIFO status register is checked. When this control port is addressed by the IN instruction, the contents of the FIFO status word is copied into register AL:
MYcsvtu Notes
572
MYcsvtu Notes
573
be translated to ASCII:
MYcsvtu Notes
574
MYcsvtu Notes
576
(timers). Each capable in of counting in binary or BCD with a maximum frequency of 10MHz.
Used for controlling real-time events such as real-time
MYcsvtu Notes
577
following functions: Generates a basic timer interrupt that occurs at approximately 18.2Hz. Interrupts the micro at interrupt vector 8 for a clock tick. Causes DRAM memory system to be refreshed. Programmed with 15us on the PC/XT. Provides a timing source to the internal speaker and other devices
MYcsvtu Notes Rungta College of Engg. & Technology 578
MYcsvtu Notes
579
MYcsvtu Notes
580
internal counters. It is often connected to the PCLK signal from the bus controller. CS: Chip Select enables the 8254 for programming, and reading and writing. G: The gate input controls the operation of the counter in some modes.
MYcsvtu Notes
581
MYcsvtu Notes
582
8253/54 Programming
Each counter is individually programmed by writing a
counter, model of operation, binary or BCD count and type of operation (read/write
MYcsvtu Notes
583
8253/54 Programming
MYcsvtu Notes
584
8253/54 Programming
Each counter may be programmed with a count of 1 to
FFFFH. Minimum count is 1 all modes except 2 and 3 with minimum count of 2.
Each counter has a program control word used to select
the way the counter operates. If two bytes are programmed, then the first byte (LSB) stops the count, and the second byte (MSB) starts the counter with the new count.
MYcsvtu Notes Rungta College of Engg. & Technology 585
8253/54 Modes
There are 6 modes of operation for each counter:
The output becomes a logic 0 when the control word is written and remains there until N plus the number of programmed counts.
MYcsvtu Notes
586
8253/54 Modes
Mode 1: One-shot mode.
The G input triggers the counter to output a 0 pulse for `count' clocks. Counter reloaded if G is pulsed again.
MYcsvtu Notes
587
8253/54 Modes
Mode 2: Counter generates a series of pulses 1 clock
pulse wide. The separation between pulses is determined by the count. The cycle is repeated until reprogrammed or G pin set to 0.
MYcsvtu Notes
588
8253/54 Modes
Mode 3: Generates a continuous square-wave with G
set to 1. If count is even, 50% duty cycle otherwise OUT is high 1 cycle longer.
MYcsvtu Notes
589
8253/54 Modes
Mode 4: Software triggered one-shot (G must be 1).
MYcsvtu Notes
590
8253/54 Modes
Mode 5: Hardware triggered one-shot. G controls similar to Mode 1.
MYcsvtu Notes
591
8253/54 Program
Explain the 8253 control word format and set up the
8253 as a square wave generator with 1 ms period if the input frequency to the 8253 is 1 MHz
MYcsvtu Notes
592
8253/54 Program
Sol-
MYcsvtu Notes
593
8253/54 Program
Count value = Required period/Input period
= 1 ms/ 1 micro secs= (1000)d The control word format to initialize counter 0, 16 bit counter, BCD counting and square wave generator mode will be as follows
MYcsvtu Notes
594
8253/54 Program
7 6 5 4 3 2 1 0
0 0 1 1 0 1 1 1
Select counter 0
Select counter 0
MYcsvtu Notes
595
8253/54 Program
The 8253 initialization program will be as follows-
MVI A,
OUT MVI A, OUT MVI A, OUT
MYcsvtu Notes
596
8155 RAM
256* 8 BIT WORDS
organized as 256 *8 They have a maximum access time 400 ns to permit use with no wait states in 8085 CPU. 8155 has maximum access time of 300ns for use with the 8085. The I/O portion consists of three general purpose I/O ports.
MYcsvtu Notes Rungta College of Engg. & Technology 598
pins, thus allowing the other two ports to operate in handshake mode. A 14 bit programmable counter/timer is also included on chip to provide either a square wave or terminal count pulse for the CPU system depending on timer mode.
MYcsvtu Notes
599
MYcsvtu Notes
600
MYcsvtu Notes
601
the system. Input high on this line resets the chip and initializes the three I/O ports to input mode. The width of reset pin should typically be 600ns.
MYcsvtu Notes
602
the CPU lower 8 bit data/address bus. The 8 bit address is latched into the address latch on the falling edge of the ALE. The address can be either for the memory section or the I/O section depending on the polarity of IO/M(bar) signal
MYcsvtu Notes
603
the chip depending on the status of write and read input signals
CE(bar) (I)
Chip enable This pin is active low
MYcsvtu Notes
604
Input low on this line with the chip enable active enables
the AD0-7 buffers, If IO/M(bar) is low the RAM content will be read out to the AD bus. Otherwise the content of the selected I/O port will be read to the AD bus.
MYcsvtu Notes
605
Input low on this line with the chip enable active causes
the data on the AD lines to be written to the Ram or I/O ports depending on the polarity of IO/M(bar)
MYcsvtu Notes
606
lines and the state of the chip enable and IO/M(bar) into the chip at the falling edge of ALE.
MYcsvtu Notes
607
high
PA0-PA7(I/O) These 8 lines are general purpose IO lines.
MYcsvtu Notes Rungta College of Engg. & Technology 608
MYcsvtu Notes
609
port or as control signal for Pa and PB. Programming is done through the C/S register When they are used as control signals they will provide the following
MYcsvtu Notes
610
intr (port a interrupt) bf (port a buffer full) strobe (bar)-(port a strobe) intr (port b interrupt) bf (port b buffer full) strobe (bar)-(port b strobe)
MYcsvtu Notes
611
MYcsvtu Notes
612
MYcsvtu Notes
613
Programming information
The command register
C when it acts as control port. The last two bits are for timer. The C/S register contents can be altered at any time by using the I/O address xxxxx000 during a write operation
MYcsvtu Notes Rungta College of Engg. & Technology 614
Programming information
Status register
MYcsvtu Notes
615
Timer section
The timer is 14bit counter that counts the timer input
pulses. It provides a square wave or a pulse when terminal count (TC) is reached. The timer has the IO address xxxxx100 for the lower order byte of the register and the IO address xxxxx101 for the higher order byte of the register
MYcsvtu Notes
616
Timer section
Tp program the timer the count length register is loaded
first one byte at a time by selecting the timer addresses. Bits 0-13 will specify the length of the next count and bits 14-15 will specify the timer output mode. The valve loaded into the count length register can have any value from 2h through 3FFF h in bits 0-13
MYcsvtu Notes
617
Timer section
There are four modes to choose from-
automatic reload of counter upon TC being reached un till instructed to stop by a new command loaded into C/S
MYcsvtu Notes
618
Timer section
Bits 6-7 of the C/S register are used to start and stop
MYcsvtu Notes
619
Timer section
Timer format
MYcsvtu Notes
620
Timer section
M2 and M1 define the timer mode as follows M2 M1 Function 0 0 Puts out low during 0
1 1
0 1
second half of the count. Square wave ie the period of the square equals the count length programmed with automatic reload at terminal count Single pulse upon TC being reached Automatic reload ie single pulse every time TC being reached
621
MYcsvtu Notes