Professional Documents
Culture Documents
Objectives
• Operation of basic I/O operations
• Decode 8 and 16-bit addresses for enabling I/O ports
• Handshaking for I/O operations
• Interface and program the 82C55 PPI (programmable
peripheral interface)
• Using the 82C55 to connect LEDs, keyboards, etc. to
the processor
• Interface stepper and DC motors to the processor
• Interface and program the 16550 programmable
asynchronous serial interface adapter (UART)
• Interface and program the 8254 programmable
interval timer (PIT)
Dr. Imad Alzeer 0701441 ”Microprocessor Fundamentals” 2
1
4/11/22
I/O Address
• I/O devices have I/O addresses (I/O ports)
• Up to 64K I/O bytes can be addressed
• The 16-bit port address appears as A15-A0
Ø This allows I/O devices at addresses 0000H-FFFFH
• Two ways to specify an I/O port address:
- An 8-bit immediate (fixed) address:
IN AX, Port_8 ; Reads a word from port Port_8
0000H-00FFH (can only see the first 256 addresses)
- A 16-bit address located in register DX :
OUT DX, AL; outputs the byte in AL to the port whose
address is in DX
Ø 0000H-FFFFH (upto 64K addresses).
Dr. Imad Alzeer 0701441 ”Microprocessor Fundamentals” 4
2
4/11/22
e a d
DX
DX
I /O R
DX
r ite
I /O W
Dr. Imad Alzeer 0701441 ”Microprocessor Fundamentals” 5
Figure 11–1 The memory and I/O maps for the 8086/8088 microprocessors. (a)
Isolated I/O. (b) Memory-mapped I/O.
3
4/11/22
4
4/11/22
The PC I/O
Address Space
10
5
4/11/22
IN AL,23H ;immediate
IN AL,DX ;DX holds address
IN AX,44H
IN AX,DX
IN EAX,2AH
IN EAX,DX
• The OUT instruction primarily takes the following forms:
11
12
6
4/11/22
Figure 11–3 The basic input interface illustrating the connection of eight switches.
Note that the 74ALS244 is a three-state buffer that controls the application of the
switch data to the data bus.
Pull-up
Resistors
To µP
13
14
7
4/11/22
Figure 11–4 The basic output interface connected to a set of LED displays.
From µP
15
Org 100H
.DATA
Dots DB 01111111b, 01001001b, 01001001b, 01001001b, 01000001b ; E
.CODE
MOV AX,@DATA
MOV DS, AX
MAIN: MOV DX,2000h ; first DOT MATRIX digit
MOV CX, 5
MOV BX, offset Dots
NEXT MOV AL,[BX]
OUT DX,AL
INC BX
INC DX
LOOP NEXT
RET
16
8
4/11/22
Handshaking
• Some I/O devices accept or release information
slower than the microprocessor.
• A method of I/O control called handshaking or
polling è synchronizes the I/O device with the
microprocessor.
• An example is a parallel printer that prints a few
hundred characters per second (CPS).
• The processor can send data much faster.
– a way to slow the microprocessor down to match
speeds with the printer must be developed
17
Figure 11–5 The DB25 connector found on computers and the Centronics 36-pin
connector found on printers for the Centronics parallel printer interface.
18
9
4/11/22
19
BUSY is the I/O address of the input port receiving the BUSY signal from printer
BUSY = 1: printer is busy printing- do not send a new character
BUSY = 0: printer is not busy - send a new character now
;An assembly language procedure that prints the ASCII data byte in register BL.
PRINT PROC NEAR
.REPEAT ;Poll the busy line until it goes low
IN AL,BUSY ;READ the port having the BUSY input
TEST AL,BUSY_BIT_MASK ;test if the Busy bit in the data read is 0
Loop repeatedly reads ;BUSY_BIT is a mask defining the position
BUSY & checks if it is low
;of the BUSY bit in the port
.UNTIL ZERO ;End waiting loop if the ZERO flag is set
MOV AL,BL ;Yes!...move character data to AL
Here
BUSY = 0! OUT PRINTER,AL ;and output it to printer-
So output ;PRINTER is address of the printer port
data to
Printer!
;This also generates the #STB pulse
RET
PRINT ENDP
20
10
4/11/22
Input Devices
• Input devices are already TTL and compatible
• Switch-based devices are either open or connected;
These are not TTL levels.
– TTL levels are a logic 0 (0.0 V–0.8 V)
– or a logic 1 (2.0 V–5.0 V)
Figure 11–6 A single-pole, single-throw switch interfaced as a TTL device.
21
22
11
4/11/22
Figure 11–7 Debouncing switch contacts: (a) conventional debouncing and (b)
practical debouncing.
23
Output Devices
• Output devices are more diverse than input devices,
but many are interfaced in a uniform manner.
• Voltages are TTL-compatible from the
microprocessor of the interfacing element.
– logic 0 = 0.0 V to 0.4 V
– logic 1 = 2.4 V to 5.0 V
• Currents for a processor and many interfacing
components are less than for standard TTL.
– Logic 0 = 0.0 to 2.0 mA
– logic 1 = 0.0 to 400 µA
24
12
4/11/22
25
26
13
4/11/22
27
28
14
4/11/22
29
30
15
4/11/22
Figure 11–10 A port decoder that decodes 8-bit I/O ports. This decoder generates
active low outputs for ports F0H–F7H.
31
32
16
4/11/22
33
Figure 11–12 A PLD that decodes 16-bit I/O ports EFF8H through EFFFH.
34
17
4/11/22
35
36
18
4/11/22
I/O Write
This part
Is the same
For both byte ports
37
38
19
4/11/22
39
40
20
4/11/22
41
42
21
4/11/22
43
44
22
4/11/22
Figure 11–18 The pin-out of the 82C55 peripheral interface adapter (PPI).
45
46
23
4/11/22
A1 A0 Function
• Group A is Port A and
upper ½ of Port C 0 0 Port A
(PC7-PC4). 0 1 Port B
• Group B is Port B and
lower ½ of Port C (PC3- 1 0 Port C
PC0).
1 1 Command Register
47
48
24
4/11/22
Figure 11–19 The 82C55 interfaced to the low bank of the 80386SX microprocessor.
A1 A0 Inputs on 82C55
A7 A6 A5 A4 A3 A2 A1 A0
1 1 0 0 0 0 0 0 = C0H Port A
1 1 0 0 0 0 1 0 = C2H Port B
1 1 0 0 0 1 0 0 = C4H Port C
1 1 0 0 0 1 1 0 = C6H Comnd
Register
Select PPI
1 At decoded
0 001 µP address
0
1
0
0
Address from
80386SX
Dr. Imad Alzeer
microprocessor 0701441 ”Microprocessor Fundamentals” 49
49
50
25