Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
30
Fig. 11-14
Fig. 11-14
71
Mode 1 Strobed Input
Mode 1 : Fig. 11-26
port A and/or port B to function as latching input devices
port C : used for control or handshaking signal
signal definition for mode 1 strobed input :
STB’(strobe) input :
capture external data into port latch on 0-to-1 transition
activate IBF(input buffer full), INTR(interrupt request)
port latch : hold data until µ read it via IN instruction
µ : notice through software(IBF) or hardware(INTR)
IBF output : indicated that input latch contain information
INTR output : requested an interrupt
=1:when STB’ return to 1, =0:when µ read data via IN
Ch.11 Basic I/O Interface 72
Fig. 11-26
Fig. 11-26
73
Mode 1 Strobed Input
INTE(interrupt enable) signal : neither input nor output
internal bit programmed via PC4(port A), PC2(port B)
PC7, PC6 : available for any general-purpose I/O
keyboard : excellent example of strobed input device
debounced a key-switches
provided strobed signal whenever a key is depressed
data output contained the ASCII-coded key code
Fig. 11-27 : keyboard connected to strobed input port A
DAV’(data available) : connected to STB’
activated for 1.0µs each time that a key is typed
each time a key is typed : data is stored into port A
Ex. 11-16 : procedure
Ch.11 Basic I/O Interface 74
Fig. 11-27
Fig. 11-27
78
Mode 1 Strobed Output
PC5, PC4 : general-purpose I/O pins
printer interface(Fig.11-29) : strobed output
example
port B : connected to parallel printer
PC2 : ACK’ to acknowledge the receipt of ASCII ch.
DS’(data strobe) to strobe data into printer
PC4 : used with software that generate DS’ signal
Ex. 11-17 : software that send ASCII-coded character in
AH to printer
1. test OBF’, if not wait
if OBF’=1 : send AH to printer through port B and also
send DS’ signal
Ch.11 Basic I/O Interface 79
Fig. 11-29
Fig. 11-29
83
Ex. 11-18
Ex. 11-18
101
Fig. 11-35
Fig. 11-35
105
Ex. 11-23,24
Ex. 11-23,24
106
11-5 8254 Programmable Interval Timer
8254: 3 independent 16-bit programmable counters(timers)
each counter : capable of counting in binary or BCD
maximum allowable input frequency : 10MHz
useful to control real-time events
ex of usage : real-time clock, event counter, motor
speed and direction control
PC : decoded at ports 40H~43H(8253 instead of 8254)
1. generate a basic timer interrupt(≈18.2Hz): clock tick
2. cause DRAM memory to be refreshed(15µs)
3. provide timing source to internal speaker and other
devices
Table 11-7
115
Fig. mode 0
Fig. mode 0
116
Fig. mode 1
Fig. mode 1
117
Fig. mode 2
Fig. mode 2
118
Modes of operation
generate a series of continuous pulses(one clock pulse
width)
count = 10 : OUT=1 for 9 clock, =0 for one clock period
cycle : repeated until programmed counter with new
count or G = 0
G = 0 to 1 : initiate new counting
mode 3 : square wave mode
generate a continuous square-wave
typically used for Baud rate generation
count=even : high for one-half, low for one-half of count
count=odd : high for one clocking period longer than low
120
Modes of operation
mode 4 : software triggered strobe
produce a single pulse at OUT
count= 10 : OUT=1 for 10 clock, =0 for one clock period
OUT : initially high
G : no effected on OUT, =1:enable counting, =0:disable
cycle : not begin until counter loaded new count
mode 5 : hardware triggered strobe(retriggerable)
like as mode 4, except that started by trigger pulse on G
similar to mode 1 : retriggerable
GATE operation :
minimum, maximum initial count :
Ch.11 Basic I/O Interface 121
Fig. mode 4
Fig. mode 4
122
Fig. mode 5
Fig. mode 5
123
Fig. GATE operation
Fig. GATE operation
128
8254 Programmable Interval Timer
Reading a Counter
each counter : have an internal latch
latch : normally follow the count
can remember the count by programming the
counter latch control word(Fig. 11-42)
held contents of counter until it is read
read-back control word(Fig. 11-43) : read more than
one counter at same time
CNT’ = 0 : counters selected by CNT0, CNT1, CNT2
ST’ =0 : latched status register
134
Fig. 11-46
Fig. 11-46
135
DC Motor Speed and Direction Control
each counter : generate pulses at different position to vary
the duty cycle at Q = pulse width modulation
counter 0,1 : programmed to divide input clock by 30720
duty cycle of Q : by changing point at which counter 1 is
started in relationship to counter 0
260.42Hz = 8MHz/30720 : operating frequency
60Hz < operating frequency < 1000Hz
256(8 bit) different speed = 30720/256 = 120
Ex.11-27:procedure that control speed & direction of motor
speed : controlled by value of AH(00H~80H~FFH)
reverse direction max speed, stop, forward max speed
BX=30720-(AH*120)
start counter 1, start counter 0 when counter 1=BX
Ch.11 Basic I/O Interface 136
Ex. 11-27
Ex. 11-27
140
16550 Functional Description
40-pin DIP(dual in-line package) : Fig 11-48,
44 pin PLCC(plastic lead-less chip carrier)
able function in simplex, half-duplex, full-duplex mode
simplex : transmitter or receiver is used by itself such as
FM(frequency modulation) radio station
half-duplex : transmit and receive, but not both at same
time such as CB(citizens band) radio
full-duplex : allow transmit and receive in both
directions simultaneously
16550 : control a modem(modulator/demodulator)
convert TTL levels of serial data into audio tones that
can pass through telephone system
Ch.11 Basic I/O Interface 141
16550 Functional Description
six pin : devoted to modem control
DSR’(data set ready) input : indicate that modem or data
set is ready to operate
DTR’(data terminal ready) output : indicate that data
terminal(16550) is ready to function
CTS’(clear-to-send) input : indicate that modem or data
set is ready to exchange information. used in half-duplex
RTS’(request-to-send) output : indicate that UART wish
to send data
RI’(ring indicator) input : by modem to indicate that
telephone is ringing
DCD’(data carrier detect) input : used by modem to
signal the 16550 that a carrier is present
Ch.11 Basic I/O Interface 142
16550 Pin Functions
modem : data set equipment(DTE), data communication
equipment(DCE)
16550 : referred to as data terminal
A0,A1,A2(Fig.11-8) : select internal reg. and data transfer
164
ADC0804 Analog-to-Digital Converter
Analog Input Signal : Fig. 11-58
VI+, VI- : connected to internal OP amp
1st way : used single input(0V~+5.0V)
2nd : applied variable voltage to VI-, so adjusted zero
reference for VI+
165
ADC0804 Analog-to-Digital Converter
Generating the Clock Signal
permissible range of clock frequency : 100~1460KHz
as close as possible to 1460KHz : minimum conversion time
1. external clock applied to CLK IN, or
2. generated with RC circuit : Fig. 11-59
Fclk = 1/(1.1RC)=1/(1.11030.00110-6)=1/1.110-6=909KHz
167
Fig. 11-60
Fig. 11-60
170
Ex. 11-32
Ex. 11-32
Ex. 11-32