Understanding I/O Devices and Buses
Understanding I/O Devices and Buses
.Speaker
Input/output devices are usually called /0
devices. They are directly connected to an
electronic module inside the systems unit
called a device controller. For example, the
speakers of a multimedia computer system
are directly connected to a device controller
called an audio card (such as a
Soundblaster), which in turn is connected to
the rest of the system.
ilo
Sometimes secondary memory devices like
the hard disk are called 1/0 devices (because
they move data in and out of main memory.)
What counts as an 1/0 device depends on
context. To a user, an 1/0 device is
something outside of the system box. To a
programmer, everything Outside of the
processor and main memory looks like an
I/0 devices. To an engineer working on the
design of a processor, everything outside of
the processor is an 1/0 device.
A computer that is dedicated to running aa
program that controls another device is an
embedded system. An embedded system is
usually embedded inside the device it
controls. Usually they run just one program
that is permanently kept in a special kind of
main memory called ROM (for Read Only
Memory). More processor chips are sold per
year for embedded systems than for all other
purposes.
3.1 IO TYPES AND EXAMPLES
communication means that over givenline or channel
port for serial communication. Serial
A serial port is a clock. A serial port
periodic intervals generated by a
with
SCLK (serial clock) to the receiver port pin. The port synchronizes the serial data-input bits
clock bits.
The serial data input and clock pulse-input are on same input line when the clock pulses either encode or
modulate serial data input bits suitably. The recciver detects clock pulses and receives data bits after decoding
or demodulating
When a separate SCLX input is sent, the receiver detects at the middle, positive or negative edge of the
lock pulses that indicate whether data-input is I or 0 and saves the bits in 8-bit shift register. The processing
element at the port (peripheral) saves the byte at a port register from where the microprocessor reads the byte.
Synchronous serial input is also called master output slave input (MOSI) when the SCLK is sent from the
sender to the receiver and slave is forced to synchronize sent inputs from the master as per the master clock
inputs. Synchronous serial input is also called master input slave output (MISO) when the SCLK is sent to the
sender (slave) from the receiver (master) and the slave is forced to synchronize sending the inputs to master as
per the master clock's outputs
Synchronous serial input is used for interprocessor transfers, audio inputs and streaming data inputs.
Devices and Communication Buses for Devices Network
****
Slate
10 11 12 3 14 15 16 17 1
10-17 L ITM
00-DT Serial
Input Time ASAMGROU
Port L Serid in Bits
**
Clock (Optional)
.
State
00010203040506 O7
Serial 00-07
Output Time
Port
Serial Output
O0-0 Bits
Cloct (Optional)
8
[Link] Stairea wuT tamota
5. Clock bits Mostly not optional Either on a sepaurate clock line or on a single
line such that the clock information is also
embedded with the data bits by an appropriate
encoding or modulation
Reciprocal of AT is the transfer rale in dit per second (bps).
m may be a large number. t depends on the protocol.
Figure 3.2 gives ten methods by which synchronous signals, with the clocking information, are sent.
) There aretwo separate lines for the data bits and clock. The parallel-in serial-out (PISO) and serial-in
paralle-out (SPO) are used for transmiting and recciving the signals for data, respectively. (Gn There is a
common line and the clock information is encoded by modulating the clock with the stream of bits. (ii) Thecre
are preceding and succeeding addiional synchronizing and signaling bits. There are five comnon methods of
encoding the clock infomation into a serial stream of the bits: (a) Frequency Modulation (FM (6) Mid Frequency
Modulation (MFM) (c) Manchester coding (d) Quadrature amplitude modulation (QAM) (e) Bi-phase coding.
The synchronous receiver separates serial bits of the message as well as synchronizing clock.
Synchronization Ways
PISO SIPO
(Transmit) (Receive) Synchronization Bi-Sync
Code Bits
Preceding a
Coding
Data Bit-Frame
FM MFM QAM Bi-Phase Manchester (sync Code)
In-between frames
Signaling Bits
Fig. 3.2 Ten ways by which the synchronous signals with the clocking information transmit from a
master device to slave device
136 .Embedded Systems
Example 3.1
An IBM personal computer has two COM ports (communication ports), COMI and COM2. These have
8 bytes at 10 addresses Ox3F8 and Ox2F8.
Figure 3.1(b) showed COM port handshaking signals besides TxD and RxD. When a modem connects,
it detects a carrier signal on the telephone line. A modem sends data carrier detect DCD signal at time o
A modem then communicatcs data set reaidy (DSR) signal at time t, when it receives the bytes on the line.
The receiving end responds at time h by data tcminal ready (DTR) signal. After DTR, request to send
(RTS) signal is sent at time ly and the recciving end responds by clear to send (CTS) signal at time ty
After the response CTS, the data bits are transmitted by modem from t, to the receiver terminal at
successive intervals [Figure 3.1(c)]. Between two sets of bytes sent in asynchronous mode, the
handshaking signals RTS and CTS can again be exchanged. This explains why the bytes do not
remain synchronized during asynchronous transmission.
A communication system may use the following protocols for synchronous or asynchronous transmission
from a device port: R$232C, UART, HDLC, X.25, Frame Relay, ATM, DSL and ADSL. These are protocols
for networking the physical devices in tclecommunication and computer networks. Ethernet and token ring
arc protocols used in LAN networks. There are a number for protocols for serial communication. RS232C,
UART and HDLC are described in Sections 3.2.2 to 3.2.4.
The protocols in embedded network devices such as bridges, routers, embedded Intemet appliances use
bridging, routing, application and web protocols. Intemet enabled embedded systems use application protocols
-
HTTP (hyper text transfer protocol), HTTPS (hyper text transfer protocol Secure Socket Layer), SMTP
Simple Mail Transfer Protocol), POP3 (Post office Protocol version 3). ESMTP (Extended SMTP), TELNET
(Tele network), FTP (ile transfer protocol), DNS (domain network server), IMAP4 (lntemet Message Exchange
Application Protocol) and Bootp (Bootstrap protocol) and others (Section 3.11).
3.3 PARALLEL DEVICE PORTS
The parallel port of devices transfers number ofbits over the wires in parallel. Parallel wires capacitive effect
reduces the length up to which parallel communication can be done. High capacitance results in delay for the
bits at the other end undergoing transition from 0 to l orirom I to 0. High capacitance can also result in noise
and cross talk (induced signals) between the wires. Therefore, parallel port carries the bits upto short distances,
generally within a circuit board or IC.
Figure 3.4(a) shows the parallel input, output, and bi-directional device ports. Figure also shows a device-
interfacing circuit with the processor and system buses. Parailel port inputs I0 to 17. may be to a keypad
controller. Parallel port outputs 00 to 07 may be output bits to LCD display output controller.
are the input and
BR, and BRo
output data buffers at bi-directional 1O port.
A device port connects to the address bus signals, A; and A, through a port address decoder. IORD and
IOWR are additional control signals for a port device read and write, respectively, in case of an 80x86
processor, which has 1O mapped 10s. The memory read and write signals, RD and WR are used in the
processor with memory mapped IOs [Section 2.2.2].
CS-Port Select
BA-Buffer Register
for Input An Input Port
BR-Buffer Register
for Output CSBR 10-17
Keypad
IORD
Port
An Output Port
Addresses
Decoder BR
00-07
Processor LCD Display
OWR
An O Port
cs 1Strobe Request
Control ORD
Input
Signals 2
OWA Port Ready
DO-07
Data Bus
Bufer Full
2 output
Acknowledge
Interrupt
Request (b)
Fig. 3.4 (a) Parallel input port, output port, and a bi-directional port for connecting the device
(b) The handshaking signals when used by the I0 ports
CvNmanlo
A
35WIRELESSDEVICES
Wireless devices have become very common in recent years for serial transmission of bits.
Wireless devices use infrared (IR) or radio frequencies after suitable modulation of data bits. IrDA
(Section 3.13.1), Bluetooth (Section 3.13.2), WiFi, 802.11 WLAN (Section 3.13.3) and ZigBee
(Section 3.13.4) have become popular protocols for wireless communication of data bits from a source to the
receiver.
An IR source communicates over a line of sight and the receiver phototransistor is used for detecting
infrared rays. Example of applications of IR communication includes handheld TV remote controllers and
robotic systems. IR devices use IrDA protocol.
Radio frequencies communicate over short and long distances. The transmitter and receiver use antennae
to transmit and receive signals and modulator and demodulators to cay the data bits using RF frequencies.
Mobile GSM wireless devices use 890-915 MHz, 1710-1785 MHz, or 1850-1910 MHz bands.
Mobile CDMA wireless devices use 2 GHz carrier frequencies. Bluetooth and ZigBee wireless devices
(Sections 3.13.2 and 3.13.4) use 2.4 GHz or 900 MHz frequencies.
The number of frequency bands is limited, while a large number of devices may need to communicate
Therefore, tinme and frequency division multiplexing are used. An innovative method is radio frequency
hopping over a wider spectrum, as in Bluetooth devices. The transmitted carrier frequencies hop among
different channels at a given hopping rate. The transmitter modulates the data bits as per protocol specifications.
The receiver tunes to these hopped carier frequencies at a given hopping rate and in the same hopping
sequence as the ones used by the transmitter. The recciver demodulates and detects the data bits as per physical-
layer protocol used for transmitting.
Several wireless devices network use FHSS or DSSS transmitters and receivers. Popular protocols are
IrDA,Bluetooth, 802.11 and ZigBee.
3:6 TIMER AND COUNTING DEVICES
Most embedded systems need a timing device.
Blind Counting Synchronization A counting device may be free running (blind counting) device
a
with a prescaler for the clock input pulses and for comparing the counts with the ones preloaded in a compare
register. The prescalar can be [Link] p= 1,2, 4, 8, 16, 32, , by programming a prescaler register.
Tt divides the input pulses as per the programmed value of p. It has an output pin (or a status bit in the status
register)orfor output when all count bits equal 0 after reaching the maximum value, which also means after
overflows after p x 2 x8T interval. It can have an input pin (or a control
timeout on overflow. The
bit for
counter
in control register) enabling an output when all count bits equal
count preloaded in the compare
register Atthat instance, a status bit or output pin also sets in and an intermupt can occur for event of comparison
This processor interrupts at preset instances or after preset intervals
equality.
with
device is useful for the alarm
to another event from another
or
respect source.
The counting device may be the free running (blind counting) device with a prescalar for the cloek input
pulses, for comparing the counts with the ones preloaded in a compare register as well as for capluring counts
on an input event. This device functions are similar to the above, but there is an addition input pin for sensing
an event and for saving the counts at the instance of that event. At this instance, a status bit can also set in and
a processor interrupt can occur for the capture event.
The above device is usesul for alarm generation and processor intemupts at the preset times as well as for
the processor to use
noting the instances of uceumences of the events and processor interupts for requesting
the captured counts on the events. Alarm generation can be synchronized with the input capture events.
Writing counts into the compare register does this. Counts in the register are set equal to capture register
counts plus additional counts, which define the interval after which an alam is to be generated.
A blind counting free runing counter with prescaling. compare and capture registers has a number of
applications. It is useful for action or initiating a chain of actions, and processor intern1pts at the preset
instances as well as for noting the instances of accurrnces of the events amd processor interupts for
requesting the processor to use the captured counts on the events for future actions.
tining device register comros the mote as timer er cnter. The connts gives the mumber of input events or
pulses since it last read. t has
was output pin
an hit in
repister) for
t n a stats output when all count bits
status
cqual O after reaching the masimum value, which also meanv timeomt or uverflow internupts to tlhe processor
Table 3.5 lists twelve uses of a timer device. I also esplaius the meaning of each use.
Real Time Clock Ticks (functioning as systenm heart beats). Real time cleck is a clock that once the
system stats it, does noI stop and c:an't be reset. Its count value caun't be reloaded. Real time endlessly
flows and never reurns!) Real Time Clock is set for ticks using prescaling bits and rate-sct bits in
3. Initiating an cvent (or a pair of events or a chain ofevents) after a comparison betwcen the preset
ime with counted value. Preset time is loaded in a Compare Regisier. [It is similar to presetting an
alarm.]
Capturing the count-value at the timer on an event. The informalion of time (instance of thc event)
4
is thus stored at the capture register.
5. Finding the time intcrval between two cvents. Counts are captured at cach event in the capture
register and read. The intervals are thus found outL. A service routine does the counts read on interrupt.
6. Wait for a message froma queue or mailbox or semaphore for a preset time when using an RTOS.
There is a predefined waiting period before RTOS lets a task run without waiing for the message
(Section 7.4)
(Contd)
SR Conce
atuilion of processor for
9ntemupt means venl. Alhich învites the
hlare evet
Sonme actian on 1he hard nlare 6r sof1
an memupt
a device or port genardtes
oa
.
Alhen it conmpletes the assiqned
action, t qenercrtes an merrup. 7his
inlarrupt i called hard hlaie interrapt detected, etther proce
Candihon îs
3. hihen sofB run-time ecepfion
nlare
Rs called
Sor hlo sl» înstruction generates
or
an lerrapt. This tnterrypt
Softuare nterrupt or thap * excephon.
the vouthe
or proqram, htbich fs runntnq
i n responge to the"nterrupt,
and an TsR is eneculed.
at present ge+ îolerupled
seturcssR
I. An SR call cue bo interapt encutes an eve Eveot Can Orear at any
moment and event occurences are asunchronou
[Link] call s evenl -baseed chversíon rom he Qurent Squerce af insthucion
to the anoler Sequence o îmstruckons. Tht: sequencea inetructiors execetes
till the returm înstruction.
3. Event canbe a ceikte
a
port event or slw cumputatonal eceptional
Canchfion ddeted by tlo n ceiectec by poram khich Tro
the ecepton.
5
e n event ean be siqnallecd by sho inteirupt nstructioo sAn Uialin
cevice ciivung functions Creat c 1, openC ).cle.
Service mechoniem existi în a
Syetem o call the cRa
5 An Toierrpt
fom mulliple Sourtes.
cattution
to TsR may or ma not take place on mchinq the
6. Diversion
oany mshuction in the presently running ouhne.
nterryot wSourcesw
be om nternat cevîces or erernal phenphercls
*Hacdhlare Sources can
[Link] to
Which întemupt the onqoing Toutine and there by Cause
Coresponding 9sp
Softuare Soures for itcrupt are telated tob
G processor ttecting Compulational enor or an leal op-code duing
exccution 0
G7) evecution f an sa înstruction to Caute rscssor oterupt
o0 qpinq roufine.
in the
There may be Come alher Special types af &ouces provicled
Sustem are
4. Hard hlare Snterupts Retatcd to 9meunal devîces
Hlw mierrapt whíich can îmerrapl an onqing
Soutices
There are no o
micro Condroller or înternal devîces ho
program. These are
procescor or
Specidae
receîver post, Apc start oj Conversion
E:-farallel port, vART Serfal
ADC end 3 . Sunchronout
recéver byte Completdo,ete.
to E1ternal Devîces-
Hord Ware anterrupi relaBed
havd ware rterrpt souree a nterrupting an
There canbe esternal Veclon [Link]
Pproqiam prov+des ihe sR aress or
that also
on gping
or interrul -ype Infamation through the dta bua.
to Etternal Devices a
alhare nterrupti Related
-
3. C w
are
Erternal had hlare interupi nlth theîr 1sR Vector acklhess
an on qoing program
process or m+cro Contoller Specffic mtenupt of
-
*An sllegpl Cade Cinchructian m the sto) %an înstruction hlhich do4
not Correspnd to any nshuction n Hhs set. Nthenever the [Link]
classificatien eanteupt
Jotlices în a suslom.
There are three types f nderupt Pc and etror
enor în a
Multiple wSntevrupta
Mulliple
w wm w
inteuupt Callu each ewance o
Sources,
When Thre are multiple înterrupt bit
qoup) is Tdentifiable rom
a
Scurce (or Cource
Grmenupt 4ron a
Memny e l e c t
PRCESSOR RD/
RAM
h a t lable
Ao-A5
Ackrowledge
D-P
Bui hold
Requect
DEVICE
To SEND
DMA
one or et CR RECEVE
controller okhestes FROM
a DMA
(DMAC), operatiON Slo BUs RAM
From
DMA
equest pMAdge
Ackroiledge decader
prt select
cproqram.
Dek fop applicatie) devebpmen Uing
"e'
language de a partiular
oDeuktop
platfamer
cornputers Cuntain NEinq mem ery n the ronge
i
Mgb
and storage mem t h e range oergaytes.
Embedded sstemt are iited in wkich both stsrage and
lor king mernory recource.c.
38
[Link] Scanned by CamScanner