Академический Документы
Профессиональный Документы
Культура Документы
AD
15
) cross represents the time at which the 8086 has
put a valid address on these lines. Two lines DO NOT indicate that all 16 lines are going high or going low at this point. The
crossed lines indicate the time at which a valid address is on the bus.
T1 T2 T3 Twait T4
CLK
AD0-AD15
BHE
ALE
S2 S0 -
M/IO
RD
READY
DT/R
DEN
WR
Fig. 12 Read Timing Diagram
Since the address information is now held on the latch, the 8086 does not need to send it out any more. As shown in
fig. 12 the 8086 floats the AD0 - AD15 lines so that they can be used to input data from memory or from a port. At about
the same time the 8086 also remove the BHE OR A16-A19 information from the upper lines OR sends out some status
information on these lines.
The 8086 is now ready to read data from the addressed memory locations or port. During T2-state the 8086 asserts
its RDsignal low. This signal is used to enable the addressed memory device or port device.
At the end of T3 state the microprocessor makes the RDsignal high OR reads the data available on the data bus,
provided the READY input signal is high. It is the duty of the external circuit to see that valid data is made available on the
data bus.
If the READY input pin is not high at the sampled time in a machine cycle, the 8086 will insert one or more WAIT
states between T3 OR T4 states in that machine cycle. An external hardware device is set up to pulse READY low before the
rising edge of the clock in T2 state. After the 8086 finishes T3 of the machine cycle, it enters a WAIT state.
If the READY input is still low at the end of a WAIT state, then the 8086 will insert another WAIT state. The 8086
will continue inserting WAIT states until the READY input is sampled high again. If the READY input is sampled high
again during T3 or during the WAIT state, the microprocessor comes out of the WAIT state OR will initiate T4 of the
machine cycle.
The DENsignal is used to enable bi-directional buffers on the data bus. The data enable signal, DEN, from the
8086 will enable the data buffer when it is asserted LOW. The data transmit / receive signal DT/ R from the 8086 is used to
specify the direction in which the buffers are enabled. When DT/ R is asserted high, the buffers will, if enabled byDEN,
transmit data from the 8086 to Memory or I/O ports. When DT/ R is asserted low, the buffers, if enabled by DEN, will
allow data to be received from Memory or I/O ports of the 8086. DT/ R is asserted during T1 of the machine cycle. The
DENis asserted after the 8086 finishes using the data bus to send the lower 16 address bits.
BUS Write Machine Cycle
The 8086 write operation is very similar to the read cycle. During T1 of a write machine cycle the 8086 asserts
M/ IOlow if the write is going to a port OR it asserts M/ IO high if the write is going to memory. At about the same time
the 8086 raises ALE
high to enable the address latches. The 8086 then assert BHE OR on the lines AD0 - AD19, it output the address that it will
be writing to. When writing to a port, line A16 - A19 will always be low, because the 8086 only sends out 16-bits port
addresses. The 8086 brings ALE low again to latch the address on the outputs of the latches. In addition to holding the
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
58
address, the latches also function as buffers for the address lines. After the address information is latched, the 8086 remove
the address information from AD0 - AD15 OR outputs the desired data on these lines.
Fig 13 Write Timing Diagram
If the READY input is sampled LOW by the 8086 before or during T2 of the machine cycle, the 8086 will insert a
WAIT state after T3. If the READY input is sampled high before the end of the WAIT state, the 8086 will go on with state
T4 as soon as it completes the WAIT state. The 8086 will continue to insect wait states for as long
as the READY is sampled low just before the end of each WAIT state.
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
59
INTERRUPTS:
Introduction:
Normal program flow can be interrupted because of a variety of reasons.
When the interrupt occurs OR is recognized, the values of the Flag register, CS OR IP registers are saved on the
stack OR the control is transferred from the executing program to an associated Interrupt Service Routine (ISR).
After completing the ISR control returns to the interrupted program.
Thus, this mechanism is similar to yet different from Far Call. CALL is always an instruction in the program. The
mechanism of calling & returning from ISR is some what different from normal CALL mechanism.
The concept of an interrupt vis--vis a far call is illustrated in the following figure:
DIAGRAM:
(ISR; Interrupt Service Procedure; Interrupt HORler All mean the same)
Interrupt can be because of:
An external interrupt signal at the pins NMI or INTR . These are called Hardware interrupts (studied in a
later session).
A Software interrupt instruction.
Internal causes resulting from execution of other instructions etc, like Interrupt on Divide Error.
(sometimes called exceptions)
Whatever be the source of interrupt:
An interrupt instruction has an associated numeric operOR called interrupt type code;
a number in the range of 0 to 255 (00H to FFH). (Thus we can have a total of 256 type codes)
The interrupt type code:
Is provided by external hardware like Interrupt Controller (in the case of external interrupts).
Is specified as part of instruction in the case of Software Interrupts.
Is implicit in the case exceptions like Divide Error.
Whatever be the source of interrupt & what ever be the type code:
For an ISR, both CS OR IP are specified.
To this extent, an ISR is like a far procedure.
CS OR IP of an ISR together constitute the Interrupt Vector. Thus an interrupt vector is 2 + 2 = 4 bytes
long.
One interrupt vector is required for each interrupt type code. We have 256 possible interrupt type codes OR
thus 256 possible interrupt vectors. Consequently, to specify all these interrupt vectors, we need 256 x 4 =
1024 bytes of memory.
Interrupt Vector Table: A table of 1024 bytes containing the 256 interrupt vectors. Address range is 00000H (0:0)
to 003FFH (0:03FFH). This is a memory block of 1KB starting from 00000H
Interrupt vector corresponding to interrupt type code n starts at location 4 x n.
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
60
Example: Interrupt type code = 20H Corresponding interrupt vector starts at 20H x 4 = 80H. (In locations 80H,
81H, we have IP OR in locations 82H, 83H, we have CS)
Another Example: Interrupt type code = 00H Corresponding interrupt vector starts at 00H x 4 = 00H. (00H, 01H:
IP ; 02H, 03H: CS)
Interrupt type codes:
Some have predefined meaning;
Some are reserved for future use; OR
Remaining interrupt type codes are free for user definitions.
This scheme is shown in the following Interrupt Vector Table:
Interrupt Type Number Function Address
0 Divide by Zero 00H-03H
1 Single Step 04H-07H
2 NMI 08H-0BH
3 Break Point 0CH-0FH
4 Interrupt on Overflow 10H-13H
5-1FH Reserved 14H-7FH
20H-FFH User defined 80H-3FFH
Interrupt Processing:
When an interrupt is to be processed:
Flags, CS OR IP are pushed on to the stack.
(Note that no automatic pushing of Flags occurs with far Call!)
T OR I flags are cleared (disabling Single Step OR External Interrupts)
Control is transferred to the new CS : IP specified in the Interrupt Vector. (ISR begins execution.)
Return from ISR:
To return from the ISR, the interrupt return (IRET) instruction is used.
Executing IRET pops IP, CS OR Flags from the stack.
In particular, the status of T OR I flags is restored.
Now, control returns to the interrupted program.
I Flag:
I flag is cleared disabling recognition of external interrupts. To enable them within the ISR, programmer can enable
them using STI (Set Interrupt Flag) instruction.
CLI (Clear Interrupt Flag) instruction also clears the I flag disabling recognition of interrupts from INTR pin.
The use of these instructions is studied in detail in a later session.
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
61
T Flag:
Setting the T flag enables Single Step. The, after the execution of every instruction, an interrupt of type 1 is
generated. This feature is quite useful for debugging. (The ISR can display Register values & other useful
information.)
Evidently, within the ISR, Single Step should not be in effect! So T is cleared. On return from ISR, the value of T is
restored.
This concept is illustrated in the following figure:
TRAP DIAGRAM:
Software Interrupt Instructions (INT n):
These instructions appear as regular instructions in the program code.
INT 3 is 1 Byte long. (The only special case). Rest of INT n instructions are all 2 Byte long.
These instructions are commonly used to access system procedures. Example: INT 21H to access DOS services.
A software interrupt instruction is more convenient than far call. It occupies less memory as it needs only 1 or 2
bytes as against the 5 bytes required for a far Call. Further, there is no need to remember the CS:IP values. These
values are obtained from the Interrupt Vector Table.
The software instruction format is as shown below:
INT 3 Instruction:
Only INT n instruction that is 1 Byte long! Rest are 2 Byte long.
This is often used to effect a breakpoint in the program. The breakpoint service routine can provide Register
values OR other information useful for debugging. Any INT n can be used for implement a breakpoint. However, as
INT 3 is only 1-byte long, it is comparatively easier to insert this instruction into the program.
INTO Instruction:
This instruction causes an Interrupt on Overflow. Thus if the O flag = 1, an interrupt is generated as Interrupt
Vector 4. OR if the O flag = 0 , this instruction results in no operation.
This instruction is placed in the program usually after arithmetic instructions that may lead to overflow condition.
(Recall that JO instruction also detects overflow condition.)
Interrupts in PC:
Type codes 0 to 4 are used in the stORard way.
Several interrupt type codes are dedicated to interrupts from hardware devices like key board, mouse etc. Examples:
9 for Keyboard; 17H for Parallel Port.
Software interrupt instructions commonly used in Assembly Language Programs are:
opcode type code
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
62
INT 21H : DOS Services
INT 27H : Terminate OR Stay Resident (TSR)
INT 1AH : Clock Service etc.
Symbol ASCII
Symbol ASCII
Symbol ASCII
Symbol ASCII
Symbol ASCII
Symbol ASCII
(space) 20 0 30 @ 40 P 50 ` 60 p 70
! 21 1 31 A 41 Q 51 a 61 q 71
" 22 2 32 B 42 R 52 b 62 r 72
# 23 3 33 C 43 S 53 c 63 s 73
$ 24 4 34 D 44 T 54 d 64 t 74
% 25 5 35 E 45 U 55 e 65 u 75
& 26 6 36 F 46 V 56 f 66 v 76
' 27 7 37 G 47 W 57 g 67 w 77
( 28 8 38 H 48 X 58 h 68 x 78
) 29 9 39 I 49 Y 59 i 69 y 79
* 2A : 3A J 4A Z 5A j 6A z 7A
+ 2B ; 3B K 4B [ 5B k 6B { 7B
, 2C < 3C L 4C \ 5C l 6C | 7C
- 2D = 3D M 4D ] 5D m 6D } 7D
. 2E > 3E N 4E ^ 5E n 6E ~ 7E
/ 2F ? 3F O 4F _ 5F o 6F 7F
Branch Displacement Directives: SHORT, LABEL
Blank 20H
A Z - 41H-5AH
a-z - 61H -7AH
0-9 - 30H-39H
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
63
Bus Structure of 8086:
Fig: Bus Structure of 8086
System Bus: System bus comprises of address bus, data bus OR control bus.
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
64
Demultiplexing of 8086:
There are 21-multiplexed pins in 8086.
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
65
Buffering of 8086:
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
66
Minimum Mode of Operation of 8086:
Timing Diagrams in Minimum Mode of operation of 8086:
a) Read Machine Cycle:
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
67
b) Write Machine Cycle:
Maximum Mode of Operation of 8086:
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
68
a) Read Machine Cycle:
b) Write Machine Cycle:
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
69
8255:
Modes of operation of 8255:
I.Bit Set Reset Mode (BSR Mode)
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
70
2. I/O Mode:
Interfacing an ADC with 8086 using 8255:
Interfacing DAC with 8086 using 8255:
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
71
DMA Controller (8257):
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
72
PPI(8259A):
CommOR Words of 8259A:
1. Initialization CommOR Words: ICW1, ICW2, ICW3, ICW4
2. Operation CommOR Words: OCW1, OCW2, OCW3
Initialization CommOR Words:
ICW1:
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
73
ICW2:
ICW3:
ICW4:
Operation CommOR Words:
OCW1:
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
74
OCW2:
OCW3:
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
75
Cascading of 8259As:
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
76
Stepper Motor Interfacing:
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
77
USART (8251A):
Mode word of 8251A:
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
78
CommOR Word of 8251A:
Status word of 8251A:
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
79
IEEE-488 Bus:
Fig(a): Pin Diagram of IEEE-488 Bus
Fig(b): Bus Structure of IEEE-488 Bus
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
80
Microcontrollers:
8051:
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
81
Memory Interfacing:
PRAGATI ENGINEERING COLLEGE :: SURAMPALEM
MICROPROCESSORS & MICROCONTROLLERS
82
8051 Ports: