Beruflich Dokumente
Kultur Dokumente
G DIR
L L B Data to A Bus
L H A Data to B bus
H X Isolation
• 74LS373: 8 bit latch
INPUTS OUTPUT
OC C D Q
L H H H
L H L L
L L x Q0
H x x Z
I/O port addressing
FFFFF
• Memory mapped
Memory
Memory
Space
I/O
FFFFFH 00000
Memory
• I/O mapped
FFFFH
I/O
0
Data transfer mode
• Three ways of exchanging data
between CPU and I/O
– Polling routine mode
– Interrupt mode
– Direct memory Access (DMA) mode
Chapter 7 Programmable
interface and application
Objectives
• Feature of programmable chips,
internal structure and function of pins
• To design application circuit with these
chips
• To master the interrupts and deeply
understand the I/O interface
Key terms
• Acknowledge(ACK) 接收
• Baud-rate 波特率
• CTS 清除发送
• DSR 数据装置就绪
• Edge-sensitive 边缘触发
• Handshaking 握手信号
• Parallel I/O 并行 I/O 口
• Serial I/O 串行 I/O 口
• Synchronous 同步的
• UART 通用异步收发机
7.1 The 8255 Parallel data transfer
interface
• Parallel I/O
– All data bits are sent or received at the same
time
• 8255
– Programmable parallel interface
– Three data ports A,B,C, one control unit
– Widely used in many microcomputer and PC.
Interface of 8255
A1 A0 Port
0 0 A
0 1 B
1 0 C
1 1 Control
Port A: A0H
Port B: A1H
Port C: A2H
True table
CS RD WR A1 A0 Operation
0 1 0 0 0 Write Port A
0 1 0 0 1 Write Port B
0 1 0 1 0 Write Port C
0 1 0 1 1 Write Control Unit
0 0 1 0 0 Read Port A
0 0 1 0 1 Read Port B
0 0 1 1 0 Read Port C
0 0 1 1 1 No operation
Working mode
• Three working modes
– Mode 0
– Mode 1
– Mode 2
• Decided by Mode word
– MOV AL, 98H
– OUT 0A3H, AL
Mode 0:Basic input/output
• Caused automatically by RESET with all
ports for input.
• Each port can be individually programmed
as input or output.
• Port C is divided into two 4-bit halves,
directionally independent.
• Input data is not latched, but output data is
latched.
Example
• What mode word is needed to program
port A for input, port B for output and
both halves of port C for input?
• 1 0 0 1 1 0 0 1 B=99H
Mode 1: Strobe for input/output
• Transferring I/O data to or from a specified
port in conjunction with strobe or
‘handshaking’ signals.
Configuration:
•8255 Mode 0
•Port A used for connection
•Port B used for visual
indication.
•Port C used for control
Base address: 40H
Port A: 40H
Port B: 41H
Port C:42H
Control word: 43H
8255 initialization:
MOV AL, 91H; 1001 0001B, mode 0, A in, B out, CL in, CH out
CS C/D RD WR Operation
0 0 0 1 Read data from 8251
0 1 0 1 Read status from 8251
0 0 1 0 Write data to 8251
0 1 1 0 Write command to 8251
1 X X X No active
Transmit related
• TxD: Transmitter data pin. Parallel data
received by the CPU are transmitted
serially by this pin.
• TxRDY: Logic 1 means the chip is ready to
accept a new data. After receiving a data, it
is reset.
• TxE: Logic 1 indicates that the serial buffer
in the transmitter is empty.
• TxC: Transmitter clock.
Receiver related
• Rxd: Receiver data pin. Data is received serially
on this pin and assembled into parallel characters.
• RxRDY: Logic 1 indicates that the USART has
received a data on its serial input "RxD" and is
ready to transfer it to the CPU. It is reset when the
data is read by the CPU.
• RxC: Receiver clock
• SYNDET: Two functions depending on working
mode.
Programming 8251
• Write to Control port
– Mode word
– Command instruction
7 6 5 4 3 2 1 0
EH IR RTS ER SBRK RxE DTR TxE
7 6 5 4 3 2 1 0
DSR SYNDET FE OE PE TxE RxRDY TxRDY
R SL EOI Function
0 0 1 Nonspecific EOI command
0 1 1 Specific EOI command
1 0 1 Rotate on nonspecific EOI command
1 0 0 Rotate in AEOI mode
0 0 0 Rotate in AEOI mode
1 1 1 Rotate on specific EOI command
1 1 0 Set priority command
0 1 0 No operation
Address Port
CC80H Counter 0
CC81H Counter 1
CC82H Counter 2
CC83H Control word
Programming the 8254
• Writing a Control word
– Control word register
– Specify which counter is being programmed.
• Writing an initial count
– Load in counter
– Determined by the Control word
Control word
Mode definitions
• Mode 0: Interrupt on terminal count
– Typically used for event counting
– OUT=0 unless Counter reaches zero
– OUT=1 unless a new count or a new Control word
is written
– GATE=1 enables counting
– GATE=0 disable counting
Mode 1: hardware retriggerable one-
shot
• OUT: initially high, will go low on the CLK
pulse following a trigger and will remain
low until the counter reaches zero. Will
then go high and remain high until the CLK
pulse after the next trigger.
Mode 2: Rate generator
• OUT : initially high, and go low for one CLK
pulse when initial count decrement to 1 and
then go high again. The counter reload the
initial count and the process is repeated.
• GATE=1 enables counting; GATE=0 disables
counting.
Mode 3: Square wave mode
• Use for baud rate generation.
• OUT initially high and goes low and remains
low after half initial count has expired.
• GATE=1 enables counting; GATE=0 disables
counting.
Mode 4: Software triggered
strobe
• OUT: initially high and goes low for one CLK
pulse when initial count expires and goes high
again.
• The counting sequence is “triggered” by
writing the initial count.
• GATE=1 enables counting, GATE=0 disables
counting.
Mode 5: Hardware triggered
strobe
• Counting is triggered by a rising edge of
GATE.
• OUT: initially high and goes low for one
CLK pulse when the initial count has
expired.
Summary
• Output of OUT
• Method for initiating
counting
• Function of GATE
Example