Also isolated (direct I/O or mapped I/O) and memory-mapped I/O, the basic input and output interfaces, and handshaking.
Knowledge of these topics makes it easier to understand the connection and operation of the programmable interface components and I/O techniques.
2
Interfacing Configurations
2 Types
1. Memory mapped I/O 2. I/O mapped I/O (Isolated I/O)
Interfacing Configurations
Isolated I/O: uses the dedicated I/O instructions (IN, OUT and INS, OUTS) and has its own address space for I/O ports (0000H-FFFFH), isolated from the memory address space. Memory mapped I/O: uses memory reference instructions (e.g. MOV). So address space is shared between memory and I/O (used by only one of them). Both techniques can be used with Intel processors. But most Intel-based systems use isolated I/O.
Memory: MOV
I/O: IN
Memory-Mapped I/O
Memory-mapped I/O does not use the IN or OUT instructions.
It uses any instruction that transfers data between the microprocessor and memory.
treated as a memory location in memory map
Advantage is any memory transfer instruction can access the I/O device.
Disadvantage is a portion of memory system is used as the I/O map.
reduces memory available to applications
Isolated I/O
I/O devices are treated separately from memory Address 0000 to 00FF is referred to page 0.
Special instructions exist for this address range Byte wide ports
Word wide ports
8
Isolated I/O
The most common I/O transfer technique used in the Intel-based system is isolated I/O.
Isolated describes how I/O locations are isolated from memory in a separate I/O address space Addresses for isolated I/O devices, called ports, are separate from memory.
Because the ports are separate, the user can expand the memory to its full size without using any of memory space for I/O devices.
9
Memory interface
Memory is a device to store data.
Data
0000
Memory Banking
12
a) ROM and EPROM ROMS and EPROMs are the simplest memory chips to interface to the 8086.
Since ROMs and EPROMs are read-only devices, A0 and BHE are not required to be part of the chip enable/select decoding. The 8086 address lines must be connected to the ROM/EPROM chip chips starting with A1 and higher to all the address lines of the ROM/EPROM chips. The 8086 unused address lines can be used as chip enable/select decoding. To interface the ROMs/RAMs directly to the 8086-multiplexed bus, they must have output enable signals. The figure 2 shows the 8086 interfaced to two 2716s. Byte accesses are obtained by reading the full 16-bit word onto the bus with the 8086 discarding the unwanted byte and accepting the desired 14 byte.
Interrupts
Definition: The meaning of interrupts is to break the
sequence of operation. While the CPU is executing a program, on interrupt breaks the normal sequence of execution of instructions, diverts its execution to some other program called Interrupt Service Routine (ISR).After
EXTERNAL
SYSTEM
USER-DEFINED
MASKABLE
NON-MASKABLE
DOS INTERRUPTS
BIOS INTERRUPTS
16
Computer Interrupt
2 General Types of Interrupts:
External - generated outside CPU by other hardware Internal - generated within CPU as a result of instruction or operation
- x86 internals: int, into, divide error, and single step - trap generally means any processor generated interrupt; in x86, usually means the single step interrupt
x86 Terminology for Interrupts:
1) Hardware Interrupt External, uses INTR and NMI control bus lines 2) Software Interrupt Internal, from int or into 3) Processor Interrupt traps, exceptions
2.
3.
PRIORITY OF INTERRUPTS
INTERRUPT TYPE
INT0,INT3-INT 255,INTO
PRIORITY
HIGHEST
NMI(INT2)
INTR
SINGLE STEP
LOWEST
IVT Format
0000:0000 0000:0001
0000:0002
0000:0003 0000:0004 0000:0005 0000:0006 0000:0007
Segment
Given a Vector, where is the ISR address stored in memory ?
Offset Type 4
0000:03fc 0000:03fd 0000:03fe 0000:03ff
Example:
int 36h
Segment
23
24
Low-priority interrupts
These registers must be saved as a part of the ISR
If they are affected
If s =1: MPU also retrieves the contents of W, BSR, and STATUS registers
Reserved INTs
Output: AL = ASCII code of the pressed key. The character is echoed to the video display
Constrain: doesnt return the control to the main program until a key is
pressed. If the key correspond to an extended ASCII code, AL returns 00. The next INT 21, function 01 returns in AL the extended ASCII code.
Control characters perform their specific action (0DH = Carriage Return, 0AH = Line Feed, 08H = Backspace, etc.).
28
29
pressed )
30
31
BIOS INT 10, function 03H: Read the Current Cursor Position Input: AH = 02 (function code), BH = page (0) Output: DH = the row (0-24), DL column (0-79)
32
Screen
Specification: write multiple times a character to screen at current cursor position. Specify the video attribute of the character: B7 = blink, (B6 = red, B5 = green, B4 = blue)=background, B3 = intensity, (B2 = red, B1 = green, B0 = blue)=foreground Input: AH = 09 (function code), AL = ASCII code, BH = page number,
33
35
8259 Features
8259 is Programmable Interrupt Controller (PIC) It is a tool for managing the interrupt requests.
8259 is a very flexible peripheral controller chip:
PIC can deal with up to 64 interrupt inputs interrupts can be masked individually. various priority schemes can also programmed.
36
37
Pin Details
38
Interfacing 8259
39
Block Diagram
40
Working of 8259
1. One or more of the INTERRUPT REQUEST lines (IR0IR7) are raised high, setting the corresponding IRR bit(s). 2. The 8259A evaluates these requests, and sends an INT to the CPU, if appropriate. 3. The CPU acknowledges the INT and responds with an INTA* pulse.
4. Upon receiving an INTA* from the CPU group, the highest priority ISR bit is set and the corresponding IRR bit is reset.
41
Working of 8259
5. Then 8086 will send one more INTA pulse to 8259.
On this second interrupt acknowledge cycle, 8259 will send an interrupt vector byte of data to the CPU, which is a pointer of the interrupt to be processed. This completes the interrupt cycle.
5.
6. The ISR bit is reset at the end of the 3rd INTA pulse.
42
43
2. Operation Command Words (OCWs): These are the command words which command the 82C59A to operate in various interrupt modes.
There are 3 OCWs in 8259
44
ICW1 Format
45
ICW2 Format
46
This word is read only when there is more than one 8259 in the system and cascading is used, in which case SNGL = 0 in ICW1.
ICW3 Format
47
ICW4 Format
48
49
OCW1 Format
50
OCW2 Format
R, SL, EOI: These three bits control the Rotate and End of Interrupt modes and combinations of the two. L2, L1, L0: These bits determine the interrupt level acted upon 51 when the SL bit is active.
OCW3 Format
52
53
1. Fully nested mode. 2. Rotating priority mode. 3. Special mask mode. 4. Polled mode.
54
Cascaded Mode
55
In this mode, a device after being serviced, receives the lowest priority.
So a device requesting an interrupt will have to wait, in the worst case until each of 7 other devices are serviced at most once .
57
Polled mode
In Polled mode the INT output functions as it normally does.
60
62
2. 8086 completes its current bus cycle and enters into a HOLD state.
3. 8086 grants the right of bus control by asserting a grant signal via the same pin as the request signal. 4. DMA operation starts. 5. Upon completion of the DMA operation, the peripheral asserts the request/grant pin again to relinquish bus control. 63
DMA controller
A DMA controller interfaces with several peripherals that may request DMA.
The controller decides the priority of simultaneous DMA requests communicates with the peripheral and the CPU, and provides memory addresses for data transfer. DMA controller commonly used with 8086 is the 8257/8237 programmable device.
The 8257/8237 is a 4-channel device. Each channel is dedicated to a specific peripheral device and capable of addressing 64 K bytes section of memory. 64
65
8237 Registers
1. Current address register 2. Current word register 3. Command register 4. Mode register
5. Request register
6. Mask register 7. Status register 8. Temporary register
67
8237 Registers
1.Current address register One 16-bit register for each channel Holds address for the current DMA transfer 2.Current word register Keeps the byte count Generates terminal count (TC) signal when the count goes from zero to FFFFH 3.Command register Used to program 8257
68
8237 Registers
4.Mode register Each channel can be programmed to Read or write Autoincrement or autodecrement the address Autoinitialize the channel 5.Request register For software-initiated DMA 6.Mask register Used to disable a specific channel
7.Status register
8.Temporary register Used for memory-to-memory transfers
69
Command Register
71
Mode Register
72
Request Register
73
Mask Register
74
Status Register
75
Thank you
76