8255
8255
Memory interface
address
MEMORY
CPU
I/O interface
Outside world
eg. keyboard printer CRT display mass storage
I/O interface
Input-output involves the transfer to (or from) peripheral devices from (or to) the data bus of the cpu eg. data transfer to the CRT display, from the keyboard, to/from a hard disk drive, to/from a modem to another computer system. Input-output operations fall into one of the following types:
Programmed I/O - cpu polls peripherals to check if I/O is needed Interrupt I/O - peripheral sends an interrupt request to cpu for I/O Direct memory access (DMA) - peripheral writes directly to memory
8088 uses Isolated I/O (I/O addresses are not part of memory address) as distinct from Memory mapped I/O (peripherals are mapped to locations in the memory address space).
Q: pros and cons of isolated I/O and memory mapped I/O?
The Memory and I/O maps for the 8086/8088 microprocessor. (a) Isolated I/O. (b) Memory mapped I/O.
FFFFF 1M 8 00000
(a)
FFFF
I/O 64K 8
0000
00000
(b)
I/O interface
cpu side data bus peripheral side Output ports
Typically, not all data, address or control lines are needed. Input and output ports maybe the same.
I/O interface
I/O interface functions can include
data storage buffer for sending and receiving data low-level communications protocol (handshaking) data format conversion (eg. parallel/serial) error detection addressing of different peripherals
I/O interface are typically implemented by LSI (large scale integration) - many different types are available from different manufacturers. Data can be transferred through I/O interface by either programmed I/O or interrupt I/O. DMA typically needs a separate controller.
IOWC
AIOWC ALE
DT/ R
DEN
Parallel data transfer is usually fast. Each data bit typically needs its own ground return line to reduce noise. A popular parallel data transfer interface standard is the CENTRONICS type interface which uses a 36-pin connector. The centronics interface is commonly used in printers.
Serial I/O
Serial I/O can be either
(1) Synchronous - data are sent in blocks, with start and end-of-block markers. Individual characters within a block do not need start and stop bits since the receiver identifies every 8 bits as one character, eg. one frame syn syn stx data field etx bcc pad
syn = sync character (ascii code 16) stx = start of text (ascii code 02) etx = end of text (ascii code 03) bcc = block check characters (error detection) pad = end of frame pad ( ascii code ff)
Serial I/O
(2) Asynchronous - no block synchronization bits. Each character is identified by the start and stop bit(s) (stop bits can be 1, 1!, 2 bits) inserted at the start and end of each character.
MSB Stop Parity bit bit data LSB Start bit
Synchronous serial data transfer is more efficient (ie. faster) since asynchronous transfer wastes about 30% of the bits for start and stop bits in sending a 7-bit ASCII code. An example of asynchronous serial data transfer is the RS232 serial port found in most computers.
data
strobe
ACK data Single Handshake
strobe
ACK Double Handshake data
Data transferred after the first STB and ACK.
8255As mode of operation is determined by the contents of its control register (see Intel data sheet for further details). Port A and Port B can be set to different mode and input/output independently.
I/O PA7-PA0
I/O PC7-PC4
CI,CO
I/O PC3-PC0
RD WR A1 A0 RESET
READ/ WRITE CONTROL LOGIC GROUP B CONTROL GROU B PORT B (8)
I/O PB7-PB0
CS
R D, W R
D7-D0 8255A
A0-A1
CS
PC3-PC0
PA7-PA0
ACK A OBF A
HANDSHAKING OUTPUT SIGNAL
PB7-PB0 INTRA STB I/O OR CONTROL PORT A CONTROL PORT B MAY BE MODE 0 OR MODE 1
A
OBF A
BIDIRECTIONAL BUS
These two formats are differentiated by the MSB of the control word. The control words can be sent to the corresponding address where 8255A is assigned to.
Ex. Assume 8255A is located at FFF8H, control register address is FFFEH and the control word is to be set to 10001110B MOV AL, 10001110B MOV DX, 0FFFEH OUT DX, AL
GROUP A PORT C (UPPER) 1 = INPUT 0 = OUTPUT PORT A 1 = INPUT 0 = OUTPUT MODE SELECTION 00 = MODE 0 01 = MODE 1 1X = MODE 2
X 0 0 0 0
BIT SELECT 1 1 0 0 2 0 1 0 3 1 1 0 4 0 0 1 5 1 0 1 6 0 1 1 7 1 B0 1 B1 1 B2
DONT CARES
D7 D6 D5 D4 D3 D2 D1 D0 1 0 0 0 1 1 1 0
ACK
OBF
3 PC3 PC4+5
Internal structure
ACK
CONTROL WORD D7 D6 D5 D4 D3 D2 D1 D0 1 1 0
OBF
6 PC0
INTR
Internal structure
ACK
INTR
INTE
an output that goes low whenever data are output (OUT) to the port A or port B latch an Acknowledge signal that cause OBF pin to return to a logic 1. This signal is a response from external device to indicate it has received data from 8255 port. a signal that often interrupts the processor when the external device receives the data and sends back the ACK signal. an internal bit programmed to enable or disable the INTR pin. INTE A is programmed as PC6 (for output mode) or PC4 (for input mode) and INTEB is PC2 (for both input/output mode).
DS
OBF
INTR
ACK
Port
data sent to port data removed from port
Timing diagram
printer
ASCII
PB7 D7
PC2 PC4
ACK
ACK
DS (Data Strobe)
D7 D6 D5 D4 D3 D2 D1 D0
2 1
IBF
1/0 PC6+7
3 PC3 PC6+7
Internal Structure
CONTROL WORD
STB
IBF
D7 D6 D5 D4 D3 D2 D1 D0 1 1 1
6 PC0
INTR
Internal Structure
STB
IBF
(buffer full)
INTR
(Interrupt requested)
RD
Port
data strobed into port data read by microprocessor
Timing diagram
IBFA INTEA
D1
D0 INTRB
OBF A
OBF B
(c) Hall Effect (100M key strokes) (b) Capacitive 20M key strokes (D. Hall Fig 9-18)
Q:
+5V
OUTPUT PORT 01 C D E F
Y X O
Y
D0
D1
Assume key 9 is pressed. For the following cases, what are the values of D3D0 at Port 2? (1). Port 1, D3-D0=0000 (2). Port 1, D3-D0=1110 (3). Port 1, D3-D0=1101
D2
O
X
high low
high
low
INPUT PORT 02 D7 D6 D5 D4 D3 D2 D1 D0
10 K
Port connections
DETECT
N
Key Pressed?
Y
Read Columns
Key Found?
Y
ENCODE
DEBOUNCE
Key Pressed?
(D. Hall)
(b) 5 by 7 dot matrix display format (c) 5 by 7 dot matrix circuit connections
+5V
BCD INPUTS
Q: Only one 7447 for all 7 digits. display the same values for all? A: multiplex method
8254 contains three 16-bit counters. The counter can be programmed to load the initial count, start and stop the count. 8254 has an 8-bit interface to data bus, and two address input A0 and A1 to address each of the three counters.
RD
INTERNAL BUS
WR
A0 A1
CS
COUNTER 1
COUNTER 2
8254
19 18 17 16 15 14 13
CONTROL LOGIC
CE
OL M
OL L
Initializing 8254
When power on, programmable peripheral devices such as 8254 are usually in undefined state. need initialization Initialization steps:
1. Determine the base address of the device from the address decode circuitry or the address decoder truth table. 2. Determine the internal address for each 8254 internal device (control register, port, counters, status register, etc.) 3. Add each of the internal address to the system base address to determine the system address of each device. 4. Look in data sheet for the device for the format of the control word(s) that you have to send to the device to initialize it. 5. Construct the control word required to initialize the device. 6. Send the control word to the device. In case of the 8254, you need to send the starting count to each of the counter registers.
8254 Addresses
A1 0 0 1 1 A0 0 1 0 1 SELECTS COUNTER 0 COUNTER 1 COUNRER 2 CONTROL WORD REGISTER
Internal
8254 PART
COUNTER 0 Register COUNTER 1 Register COUNTER 2 Register CONTROL Register
Note : This system address is circuit-dependent. In this example, 8254s A1 and A0 are connected to CPUs pin A2 and A1.
CS = 0
WR = 0
RD = 1
D4 D3 D2 D1 D0 RW0 M2 M1 M0 BCD
Select Counter 0 Select Counter 1 Select Counter 2 Read-Back Command (see Read Operations)
(4) BCD 0 1 Binary Counter 16-bits Binary Coded Decimal (BCD) Counter (4 Decades)
1 1
NOTE: Dont Care bits () should be 0 to insure compatibility with future Intel products
(Brey Fig10-35)