You are on page 1of 78

www.jdrr5.co.

cc

www.theo7.co.cc Page 1

Microprocessor & Application
UNIT I SEMICONDUCTOR DEVICES
Semiconductor is a substances which has resistivity between Conductors and Insulators.
There are two main types of semiconductor materials:
intrinsic - where the semiconducting properties of the material occur naturally i.e.
they are intrinsic to the material's nature.
extrinsic - they semiconducting properties of the material are manufactured, by
us, to make the material behave in the manner which we require.
Nearly all the semiconductors used in modern electronics are extrinsic. This means that
they have been created by altering the electronic properties of the material. The two most
common methods of modifying the electronic properties are:
Doping - the addition of 'foreign' atoms to the material.
Junction effects - the things that happen when we join differing materials
together.
Consider two separate bits of semiconductor, one n-type, the other p-type.

www.jdrr5.co.cc

www.theo7.co.cc Page 2


Bring them together and join them to make one piece of semiconductor which is doped
differently either side of the junction.

Free electrons on the n-side and free holes on the p-side can initially wander across the
junction.When a free electron meets a free hole it can 'drop into it'. So far as charge
movementsare concerned this means the hole and electron cancel each other and vanish.
www.jdrr5.co.cc

www.theo7.co.cc Page 3


As a result, the free electrons near the junction tend to eat each other, producing a region
depleted of any moving charges. This creates what is called the depletion zone.

Now, any free charge which wanders into the depletion zone finds itself in a region with
no other free charges.. These exert a force on the free charge, driving it back to its 'own
side' of the junction away from the depletion zone.
A free charge now requires some extra energy to overcome the forces from the
donor/acceptor atoms to be able to cross the zone. The junction therefore acts like a
barrier, blocking any charge flow (current) across the barrier.
www.jdrr5.co.cc

www.theo7.co.cc Page 4







Zener Diode




www.jdrr5.co.cc

www.theo7.co.cc Page 5

Unlike the rectifier diode, a Zener diode is designed to operate in reverse conduction.
Zener breakdown occurs at a precisely defined voltage, allowing the diode to be used as a
voltage reference or clipper. While Zener diodes are usually operated in reverse
conduction, they may also be operated in cutoff and forward conduction.
Zener breakdown Occurs for breakdown voltages greater than approximately 6V
when the electric field across the diode junction pulls the electrons from the atomic
valence band into the conduction band, causing a current to flow.
Impact ionization (als o called avalanche breakdown) Occurs at lower breakdown
voltages.

Zener diode ratings include:
Zener Voltage (Vz@Izt)
Power Dissipation (Pd)
Max Current (Izm)
Zener Impedance (Zzt)
Max Leakage Current (IR@VR)
Temperature Coefficient (VZ)


www.jdrr5.co.cc

www.theo7.co.cc Page 6

Tunnel Diode

The tunnel diode has a region in its voltage current
characteristic where the current decreases with
increased forward voltage, known as its negative
resistance region. This characteristic makes the
tunnel diode useful in oscillators and as a microwave
amplifier.
A tunnel diode is a semiconductor with a negative resistance region that results in very
fast switching speeds , up to 5 GHz. The operation depends upon a quantum mechanic
principle known as "tunneling" wherein the intrinsic voltage barrier (0.3 Volt for
Germanium junctions) is reduced due to doping levels which enhance tunneling. Refering
to the curves below, superimposing the tunneling characteristic upon a conventional P-N
junction,


Tunnel Diode Oscillator
www.jdrr5.co.cc

www.theo7.co.cc Page 7







The negative resistance region of the tunnel diode makes
oscillator action possible. The unijunction transistor has a
similar oscillator application.

www.jdrr5.co.cc

www.theo7.co.cc Page 8


Transistors
Symbols



A Transistor is a Current In/Current Out Device
.

It can be thought of as a device that is active in only One Direction: It can draw
more or less current through its load resistor (sometimes referred to as a pull-up
resistor).

It can either Source Current or it can Sink Current, it Cannot do Both.
-
Since the Transistor is a Current device, any signal Voltage must first be
www.jdrr5.co.cc

www.theo7.co.cc Page 9

Converted to a Current.
Voltage to Current Convertor
First, you must convert the input voltage to a
current by using a Voltage to Current Convertor--a
resistor.


Since the Transistor is a Current in/Current out device, any Current Output is
Converted to a Voltage Drop by the Current flowing thru a Load Resistor.

Current to Voltage Convertor
Next, you convert the output current into a voltage
by using a Current to Voltage Convertor in the
collector circuit--you guessed it--a resistor.

Diodes as Transistor

We can simulate a NPN transistor using two diodes and connecting both anodes together.
One cathode is tied to common (the emitter); the other cathode (the collector) goes to a
load resistor tied to the positive supply. Now connect a 1k resistor to the junction of the
two anodes (the base), and using a signal generator, apply a 0 to 2 volt P-P sine wave to
the other end. Using a dual beam oscilloscope, observe the signal at both ends of the
www.jdrr5.co.cc

www.theo7.co.cc Page 10

resistor, i.e., the generator and the "base."

The results should resemble the figure: the
diode signal starts up unimpeded until it
reaches ~ 0. 6 volts peak (1.2 volts P - P), at
which point the voltage at the "base" appears
to stop increasing, even though the signal
generator is still increasing in amplitude. No
matter how much the voltage applied from the
generator increases (within reason), the "base"
voltage appears to not increase. However, the
current into that junction (two anodes)
increases linearly: I = [E - 0.6]/R.




Now at this point, the analogy falls apart: these two diodes have no gain, as the transistor
we are trying to simulate would have. However, let us pretend that it does: the "collector"
is a high impedance current source and if a resistor (the load resistor) is connected
between the "collector" and the positive supply, a voltage is seen at the collector. This
changing voltage drop across the resistor--caused by the changing collector current--will
change correspondingly to the "base" current.
www.jdrr5.co.cc

www.theo7.co.cc Page 11

Half-Wave Rectifiers
An easy way to convert ac to pulsating dc is to simply allow half of the ac cycle to
pass, while blocking current to prevent it from flowing during the other half cycle. The
figure to the right shows the resulting output. Such circuits are known as half-wave
rectifiers because they only work on half of the incoming ac wave.


The simplest rectifier circuit is nothing more than a diode connected in series with
the ac input, as shown to the right. Since a diode passes current in only one direction,
only half of the incoming ac wave will reach the rectifier output. Thus, this is a basic
half-wave rectifier.

www.jdrr5.co.cc

www.theo7.co.cc Page 12

The orientation of the diode matters; as shown, it passes only the positive half-cycle of
the ac input, so the output voltage contains a positive dc component. If the diode were to
be reversed, the negative half-cycle would be passed instead, and the dc.

Full-Wave Rectifiers

The more common approach is to manipulate the incoming ac wave so that both
halves are used to cause output current to flow in the same direction. The resulting
waveform is shown to the right. Because these circuits operate on the entire incoming ac
wave, they are known as full-wave rectifiers.


www.jdrr5.co.cc

www.theo7.co.cc Page 13


The full-wave rectifier can still be configured for a negative output voltage, rather
than positive. In addition, as shown to the right, it is quite possible to use two full-wave
rectifiers to get outputs of both polarities at the same time.

The full-wave rectifier passes both halves of the ac cycle to either a positive or
negative output. This makes more energy available to the output, without large intervals
when no energy is provided at all. Therefore, the full-wave rectifier is more efficient than
the half-wave rectifier. At the same time, however, a full-wave rectifier providing only a
single output polarity does require a secondary winding that is twice as big as the half-
wave rectifier's secondary, because only half of the secondary winding is providing
power on any one half-cycle of the incoming ac.

Full-Wave Bridge Rectifier

The four-diode rectifier circuit shown to the right serves very nicely to provide full-
wave rectification of the ac output of a single transformer winding. The diamond
configuration of the four diodes is the same as the resistor configuration in a Wheatstone
Bridge. In fact, any set of components in this configuration is identified as some sort of
bridge, and this rectifier circuit is similarly known as a bridge rectifier.

If you compare this circuit with the dual-polarity full-wave rectifier above, you'll find
that the connections to the diodes are the same. The only change is that we have removed
the center tap on the secondary winding, and used the negative output as our ground
reference instead. This means that the transformer secondary is never directly grounded,
but one end or the other will always be close to ground, through a forward-biased diode.
This is not usually a problem in modern circuits.
www.jdrr5.co.cc

www.theo7.co.cc Page 14




R-C Coupled Amplifiers




Multistage or Cascade Amplifiers
Whenever it is necessary to increase the amplification by an amount greater than
can be accomplished with a single-stage amplifier, several stages are connected one after
another. The various methods commonly used to couple one tube to the next will now be
discussed briefly. For the time being we shall omit as many of the voltage supplies as
www.jdrr5.co.cc

www.theo7.co.cc Page 15

possible in order to focus attention upon the coupling units. Later we shall study the more
complicated complete circuits.

Fig. 13 F. A simple two-stage resistance-coupled or d.c. amplifier
The amplifier of Fig. 13 F is called a resistance-coupled or d.c. amplifier because its
coupling consists of a single resistance, R, and because the circuit can amplify not
only alternating but also direct voltages applied to the input terminals. Were it not for the
potential E
C
, the voltage on the grid of tube 2 would be the same as that on the plate of
tube 1. This amounts to the high positive value given by the battery E
B
minus the IR drop
in the coupling resistor R. If the grid of tube 2 were allowed to operate at a high positive
potential, the plate current of this tube would be extremely large, a heavy grid current
would flow and the tube would probably burn out. E
C
must be greater than (E
B
-IR) by
such an amount as to bias tube 2 to the middle of the straight portion of its characteristic
curve.

Fig. 13 G. Resistance-capacitance coupling
In the circuit of Fig. 13 G, which is called a resistance-capacitance (R-C) coupled
amplifier, the d.c. plate potential of the first tube is kept off the grid of the second tube by
means of the coupling condenser C
g
. The use of C
g
alone, however, would insulate or "

www.jdrr5.co.cc

www.theo7.co.cc Page 16

float" the grid of the second tube. Electrons which reach this grid accumulate, except for
a slight leakage over the outer surface of the tube, and build up a negative C-bias of
erratic unstable amount. To avoid this, the high resistance grid leak R
g
is added.
It will be recalled that the d.c. voltage across the plate of a tube is less than that of
the B-voltage supply by an amount equal to the d.c. voltage drop in the plate resistor. An
economy can be effected by using a low-resistance, high-inductance coil in place of the
resistor, as in the impedance-resistance-coupled amplifier of Fig. 13 H.

Fig. 13 H. Impedance coupling
The d.c. loss in the resistance of the coil will be small, yet a fluctuation in the
plate current will set up a comparatively high voltage across the coil; and this will be
impressed through C
g
and R
g
, upon the grid of the second tube. But the amount of this
voltage will be different for different frequencies of the voltage sent into the amplifier,
and frequency distortion will occur. This may be an advantage or a disadvantage,
according to the use to which the amplifier is to be put.

Fig. 13 I. Transformer coupling for audio frequencies
www.jdrr5.co.cc

www.theo7.co.cc Page 17


Fig. 13 J. Tuned transformer coupling for radio frequencies
The advantage of stepping up the voltage with an inter-tube transformer, as in
Figs. 13 I and 13 J, has made the transformer-coupled amplifier one of the most
commonly used. Here again, however, the reactive elements of the transformer cause the
step-up voltage to have different values for different input frequencies. In Fig. 13 I, the
iron core of the audio-frequency transformer is indicated by the parallel vertical lines
between its primary and secondary. In Fig. 13 J, the primary and secondaries are tuned by
means of condensers so as to amplify a given frequency (together with those in the
immediate neighborhood) to a high value, to the exclusion of all others. This type of
coupling is used in radio-frequency amplifiers.
Transformer-Coupled Amplifiers
For audio-frequency amplification, a transformer is used as the coupling unit
between two tubes only when power is to be transferred or when coupling is to be made
to a push-pull stage. Usually, triodes, such as 6C5, 6J5, and similar tubes, with a m of 20
or less, are used.


www.jdrr5.co.cc

www.theo7.co.cc Page 18


Direct coupled
Direct coupled, also known as "DC amp", refers to a type of amplifier. In this type of
amplifier, the output of one stage of the amplifier is connected to the input of the next
stage directly without using any reactive components like capacitors, inductors,
transformers, and others. As a result, the frequency response of this amplifier is quite flat
all the way down to DC (0 Hz).
Current
The common use of the term "DC Amp" does not mean "direct current amplifier",
as this type can be used for both D/C and A/C signals. The amplification of D/C (zero
frequency) is possible only by this amplifier, hence it later becomes the building block
for differential amplifier and operational amplifier. Unlike other multistage amplifiers,
amplification of low frequency (below 10 Hz) signals is only possible using direct
coupling. This is because use of coupling and bypass capacitors is not possible as they
provide very high capacitive reactance.
Advantages
There are several advantages to using this type of amplifier, including:
Simple circuit arrangement as there are minimum number of components
For above reason, also quite inexpensive
Can be used to amplify zero and low frequency signals
Provides uniform frequency response up to a high frequency. Lower cut-off
frequency is zero and upper cut-off frequency is determined by values of components
used.
Disadvantages
In addition to the advantages, there are also several known disadvantages. These include:
www.jdrr5.co.cc

www.theo7.co.cc Page 19

Unwanted change in output voltage without any change in the input is often
observed. This is caused by temperature variations, aging of components, etc and is
referred to as 'drift'. This drawback can be removed using differential amplifier.
At high frequencies gain decreases
Transistor parameters change with temperature, hence output is affected by
temperature variations
Even if input is A/C, some D/C component is present at output. This can be
removed using differential amplifier
Application
Direct coupled is used in TV receivers, computers, regulator circuits and other electronic
instruments. It also forms a building block for differential amplifiers and operational
amplifiers.
POWER AMPLIFIERS
All power amplifiers have a power supply, an input stage, and an output stage. Many
amplifiers have various protection features (briefly outlined above) which fall into a
category I refer to as housekeeping.
Power Supply: The primary purpose of a power supply in a power amplifier is to take
the 120 VAC power from the outlet and convert it to a DC voltage (VAC is an
abbreviation for Volts Alternating Current, and DC is an abbreviation for Direct
Current). Conversion from AC to DC is necessary because the semiconductor devices
(transistors, FETs, MOSFETs, etc.) used inside the equipment require this type of
voltage. (By the way, FET stands for Field Effect Transistor, and MOSFET stands for
Metal Oxide Semiconductor Field Effect Transistor). Many different types of power
supplies are used in power amplifiers, but in the end they all basically aim to generate DC
voltage for the transistor circuits of the unit. By having a separate power supply for the
signal level signals in the amplifier, the distortion added by a sagging power supply is
kept out of all but the final (output) stage.
www.jdrr5.co.cc

www.theo7.co.cc Page 20

Input stage: The general purpose of the input stage of a power amplifier (sometimes
called the "front end") is to receive and prepare the input signals for "amplification" by
the output stage. Most professional quality amplifiers have various input connectors;
typically they will have XLR inputs, quarter inch" inputs, and sometimes a simple
terminal strip input (although these tend to be found on amplifiers intended primarily for
public address systems). XLR and most quarter inch inputs are balanced inputs (as
compared to single ended inputs). Balanced inputs are much preferred over single ended
inputs when interconnection cables are long and/or subject to noisy electrical
environments because they provide very good noise rejection. The input stage also
contains things like input level controls. Some amplifiers have facilities for "plug in"
modules (such as filters); these too are grouped into the input stage.
Output stage: The output stage of an amplifier is the portion which actually converts the
weak input signal into a much more powerful "replica" which is capable of driving high
power to a speaker. This portion of the amplifier typically uses a number of "power
transistors" (or MOSFETs) and is also responsible for generating the most heat in the unit
(unless the amplifier happens to have a very bad power supply design, in which case it
too generates a lot of heat). The output stage of an amplifier interfaces to the speakers.
Amplifier Classes:
The Class of an amplifier refers to the design of the circuitry within the amp. For
audio amplifiers, the Class of amp refers to the output stage of the amp (in practice there
may be several classes of signal level amplifier within a single unit). There are many
classes used for audio amps. The following is brief description of some of the more
common amplifier classes you may have heard of.
Class A: Class A amplifiers have very low distortion (lowest distortion occurs
when the volume is low) however they are very inefficient and are rarely used for
high power designs. The distortion is low because the transistors in the amp are
biased such that they are half "on" when the amp is idling (this is the point at
which the semiconductor devices are most linear in behavior). As a result of being
www.jdrr5.co.cc

www.theo7.co.cc Page 21

half on at idle, a lot of power is dissipated in the devices even when the amp has
no music playing! Class A amps are often used for "signal" level circuits (where
power requirements are small) because they maintain low distortion. High end
Class A audio amplifiers are sometimes used by the most discriminating
audiophiles. Distortion for class A amps increases as the signal approaches
clipping, as the signal is reaching the limits of voltage swing for the circuit. Some
class A amps have speakers connected via capacitive coupling.
Class B: Class B amplifiers are used in low cost designs or designs where sound
quality is not that important. Class B amplifiers are significantly more efficient
than class A amps, however they suffer from bad distortion when the signal level
is low (the distortion in this region of operation is called "crossover distortion").
Class B is used most often where economy of design is needed. Before the advent
of IC amplifiers, class B amplifiers were common in clock radio circuits, pocket
transistor radios, or other applications where quality of sound is not that critical.
For example, a siren driver is one application of a Class B amp. Siren drivers are
amplifiers that are basically driven into clipping (to produce a square wave type
signal). In such a drive situation there would be little need to care about crossover
distortion (the design can be less expensive due to reduced parts count).
Class AB: Class AB is probably the most common amplifier class currently used
in home stereo and similar amplifiers. Class AB amps combine the good points of
class A and B amps. They have the improved efficiency of class B amps and
distortion performance that is a lot closer to that of a class A amp. With such
amplifiers, distortion is worst when the signal is low, and generally lowest when
the signal is just reaching the point of clipping. Class AB amps (like class B) use
pairs of transistors, both of them being biased slightly ON so that the crossover
distortion (associated with Class B amps) is largely eliminated.
Class C: Class C amps are never used for audio circuits. They are commonly
used in RF circuits. Class C amplifiers operate the output transistor in a state that
results in tremendous distortion (it would be totally unsuitable for audio
reproduction). However, the RF circuits where Class C amps are used employ
www.jdrr5.co.cc

www.theo7.co.cc Page 22

filtering so that the final signal is completely acceptable. Class C amps are quite
efficient.
Class D: The concept of a Class D amp has been around for a long time (~ 50
years or so), however only fairly recently have they become more commonly used
in consumer applications. Due to improvements in the speed, power capacity and
efficiency of modern semiconductor devices, applications using Class D amps
have become affordable for the common person. Class D amplifiers use a
completely different method of amplification as compared to Class A, B and AB.
Whereas the aforementioned classes of amplifier operate the semiconductor
devices in the linear mode, Class D amplifiers operate the output semiconductor
devices as switches (ON or OFF). In a Class D amplifier, the input signal is
compared with a high frequency triangle wave, resulting in the generation of a
Pulse Width Modulation (PWM) type signal. This signal (which some people
incorrectly identify as a digital signal) is then applied to a special filter that
removes all the unwanted high frequency by-products of the PWM stage. The
output of the filter drives the speaker. Please note that this is a VERY high level
idea of how Class D amplifiers work! Class D amps are (today) most often found
in car audio subwoofer amplifiers. The major advantage of Class D amplifiers is
that they have the potential for very good efficiency (due to the fact that the
semiconductor devices are ON or OFF in the power stage, resulting in low power
dissipation in the device as compared to linear amplifier classes). One notable
disadvantage of Class D amplifiers: they are fairly complicated and special care is
required in their design (to make them reliable). Due to the high frequencies that
are present in the audio signal (as a result of the PWM stage), Class D amps used
for car stereo applications are often limited to subwoofer frequencies, however
designs are improving all the time. It will not be too long before a full band class
D amp becomes commonplace and less costly. Class D amps find use in many
other applications besides audio.
www.jdrr5.co.cc

www.theo7.co.cc Page 23

UNIT II LINEAR AND DIGITAL ICS

IC Technology

A Sample of Integrated Circuit technologies:
o MOS
CMOS
PMOS-only
NMOS-only

o Bipolar
Transistor-transistor logic
(TTL)
I ntegrated Injection Logic
(I
2
L)

o Gallium Arsenide (GaAs)
o Silicon Germanium
o BiCMOS
o Superconducting technologies



www.jdrr5.co.cc

www.theo7.co.cc Page 24

Changing the value of a physical variable requires more power as you
change it more quickly.

CMOS Technology
Power consumption (heat) of bipolar circuits reduce level of integration.
Reducing chip size increases physical size of the system.
Multiple ICs offset advantage of faster speed of bipolar since intra-chip signal
propagation is much smaller than inter-chip propagation.
On-chip wires suffer capacitance and resistance. However, off-chip wires suffer
from capacitance and inductance (ringing effects).
CMOS advantages:
Low power.
Fully restored logic levels.
Rise and fall transition times are of the same order.
Very high levels of integration.
High performance.
ANALOG TO DIGITAL CONVERTERS
A/D converters are electrical circuits that have the following characteristics.
The input to the A/D converter is a voltage.
o A/D converters may be designed for voltages from 0 to 10v, from -5 to
+5v, etc., but they almost always take a voltage input. (Some rare
exceptions occur with current inputs!) In any event, the input is an analog
voltage signal for most cases.
The output of the A/D converter is a binary signal, and that binary signal encodes
the analog input voltage. So, the output is some sort of digital number.
An analog-to-digital converter (abbreviated ADC, A/D or A to D) is an
electronic integrated circuit, which converts continuous signals to discrete digital
www.jdrr5.co.cc

www.theo7.co.cc Page 25

numbers. The reverse operation is performed by a digital-to-analog converter
(DAC).
Typically, an ADC is an electronic device that converts an input analog voltage
(or current) to a digital number. The digital output may be using different coding
schemes, such as binary, Gray code or two's complement binary.
DIGITAL TO ANALOG CONVERTERS
In electronics, a digital-to-analog converter (DAC or D-to-A) is a device for
converting a digital (usually binary) code to an analog signal (current, voltage or electric
charge). An analog-to-digital converter (ADC) performs the reverse operation.

DAC types
The most common types of electronic DACs are:
Pulse Width Modulator, the simplest DAC type. A stable current or voltage is
switched into a low pass analog filter with a duration determined by the digital
input code. This technique is often used for electric motor speed control, and is
now becoming common in high-fidelity audio.
Oversampling DACs or Interpolating DACs such as the Delta-Sigma DAC,
use a pulse density conversion technique. The oversampling technique allows for
the use of a lower resolution DAC internally. A simple 1-bit DAC is often chosen
because the oversampled result is inherently linear. The DAC is driven with a
pulse density modulated signal, created with the use of a low-pass filter, step
nonlinearity (the actual 1-bit DAC), and negative feedback loop, in a technique
called delta-sigma modulation. This results in an effective high-pass filter acting
on the quantization (signal processing) noise, thus steering this noise out of the
low frequencies of interest into the high frequencies of little interest, which is
called noise shaping (very high frequencies because of the oversampling). The
quantization noise at these high frequencies are removed or greatly attenuated by
www.jdrr5.co.cc

www.theo7.co.cc Page 26

use of an analog low-pass filter at the output (sometimes a simple RC low-pass
circuit is sufficient). Most very high resolution DACs (greater than 16 bits) are of
this type due to its high linearity and low cost. Higher oversampling rates can
either relax the specifications of the output low-pass filter and enable further
suppression of quantization noise. Speeds of greater than 100 thousand samples
per second (for example, 192kHz) and resolutions of 24 bits are attainable with
Delta-Sigma DACs. A short comparison with pulse width modulation shows that
a 1-bit DAC with a simple first-order integrator would have to run at 3 THz
(which is physically unrealizable) to achieve 24 meaningful bits of resolution,
requiring a higher order low-pass filter in the noise-shaping loop. A single
integrator is a low pass filter with a frequency response inversely proportional to
frequency and using one such integrator in the noise-shaping loop is a first order
delta-sigma modulator. Multiple higher order topologies (such as MASH) are
used to achieve higher degrees of noise-shaping with a stable topology.
Binary Weighted DAC, which contains one resistor or current source for each bit
of the DAC connected to a summing point. These precise voltages or currents sum
to the correct output value. This is one of the fastest conversion methods but
suffers from poor accuracy because of the high precision required for each
individual voltage or current. Such high-precision resistors and current-sources
are expensive, so this type of converter is usually limited to 8-bit resolution or
less.
R-2R Ladder DAC, which is a binary weighted DAC that uses a repeating
cascaded structure of resistor values R and 2R. This improves the precision due to
the relative ease of producing equal valued matched resistors (or current sources).
However, wide converters perform slowly due to increasingly large RC-constants
for each added R-2R link.
Thermometer coded DAC, which contains an equal resistor or current source
segment for each possible value of DAC output. An 8-bit thermometer DAC
would have 255 segments, and a 16-bit thermometer DAC would have 65,535
segments. This is perhaps the fastest and highest precision DAC architecture but
www.jdrr5.co.cc

www.theo7.co.cc Page 27

at the expense of high cost. Conversion speeds of >1 billion samples per second
have been reached with this type of DAC.
Segmented DAC, which combines the thermometer coded principle for the most
significant bits and the binary weighted principle for the least significant bits. In
this way, a compromise is obtained between precision (by the use of the
thermometer coded principle) and number of resistors or current sources (by the
use of the binary weighted principle). The full binary weighted design means 0%
segmentation, the full thermometer coded design means 100% segmentation.
Hybrid DACs, which use a combination of the above techniques in a single
converter. Most DAC integrated circuits are of this type due to the difficulty of
getting low cost, high speed and high precision in one device.
Comparison of Representations
System Digits
Binary (Base 2): 0, 1
Octal (Base 8): 0, 1, 2, 3, 4, 5, 6, 7
Decimal (Base 10): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Hexadecimal (Base 16): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Decimal Hexadecimal Binary Octal

0 00 0000 0000 0
1 01 0000 0001 1
2 02 0000 0010 2
3 03 0000 0011 3
4 04 0000 0100 4
5 05 0000 0101 5
www.jdrr5.co.cc

www.theo7.co.cc Page 28

6 06 0000 0110 6
7 07 0000 0111 7
8 08 0000 1000 10
9 09 0000 1001 11
10 0A 0000 1010 12
11 0B 0000 1011 13
12 0C 0000 1100 14
13 0D 0000 1101 15
14 0E 0000 1110 16
15 0F 0000 1111 17
16 10 0001 0000 20
17 11 0001 0001 21
18 12 0001 0010 22
. . . . . . . . . . . .
255 FF 1111 1111 377

Converting from either Hexadecimal, Binary or Octal to Decimal
A binary, a hexadecimal or an octal number can be expressed as the sum of the
successive powers of the base (either 2, 16, or 8, respectively), with the coefficients being
the digits.

www.jdrr5.co.cc

www.theo7.co.cc Page 29

For example,
Decimal 1111
(base 10)
= 1

1000
(10
3
)
1

100
(10
2
)
1

10
(10
1
)
1

1
(10
0
)
= (1*1000) + (1*100) + (1*10)
+ (1*1) = 1111
(base 10)


Hexadecimal 1111
(base 16)
= 1

4096
(16
3
)
1

256
(16
2
)
1

16
(16
1
)
1

1
(16
0
)
= (1*4096) + (1*256) + (1*16)
+ (1*1) = 4369
(base 10)


Binary 1111
(base 2)
= 1

8
(2
3
)
1

4
(2
2
)
1

2
(2
1
)
1

1
(2
0
)
= (1*8) + (1*4) + (1*2) +
(1*1) = 15
(base 10)


Octal 1111
(base 8)
= 1

512
(8
3
)
1

64
(8
2
)
1

8
(8
1
)
1

1
(8
0
)
= (1*512) + (1*64) + (1*8) +
(1*1) = 585
(base 10)


Converting from Decimal to Binary
To convert a decimal number into a binary number, divide it by 2 repeatedly and note the
remainders. The remainders are the bits of the binary number. The last remainder is the
most significant bit, and the first remainder is the least significant bit.

www.jdrr5.co.cc

www.theo7.co.cc Page 30

For example,
13
(base 10)
= 1101
(base 2)
13 2 = 6 remainder 1 LSB
6 2 = 3 remainder 0
3 2 = 1 remainder 1
1 2 = 0 remainder 1 MSB

Converting from Decimal to Hexadecimal
There are two different ways to convert a decimal number into a hexadecimal number.
1. The first method is similar to converting a decimal to a binary and involves dividing
the number by decimal 16 and noting the remainders. The first remainder is the least
significant digit and the last remainder is the most significant digit.
For example,
4620
(base 10)
= 120C
(base 16)
4620 16 = 288 remainder 12 = C LSB
288 16 = 18 remainder 0
18 16 = 1 remainder 2
1 16 = 0 remainder 1 MSB

2. The second method involves converting the decimal number into a binary, then
convert the binary into a hexadecimal number. To change the representation of the
binary number to hexadecimal, separate the digits into 4-bit groups beginning with the
least significant bit. Then write the hexadecimal equivalent of each group.
For example,
23
(base 10)
= 17
(base 16)


23
(base 10)
= 0001 0111
(base 2)
23 2 = 11 remainder 1 LSB
www.jdrr5.co.cc

www.theo7.co.cc Page 31

11 2 = 5 remainder 1
5 2 = 2 remainder 1
2 2 = 1 remainder 0
1 2 = 0 remainder 1 MSB

0001 0111
(base 2)
= 17
(base 16)
0001

0111

(base 2)
1 7 (base 16)

Converting from Decimal to Octal
To convert a decimal number into an octal number, divide it by 8 repeatedly and note the
remainders. The remainders are the digits of the octal number. The last remainder is the
most significant digit, and the first remainder is the least significant digit.
For example,
1701
(base 10)
= 3245
(base 8)
1701 8 = 212 remainder 5 LSB
212 8 = 26 remainder 4
26 8 = 3 remainder 2
3 8 = 0 remainder 3 MSB

Converting between Binary and Hexadecimal
From Binary to Hexadecimal: To convert a binary number into its hexadecimal form,
start by grouping the digits into 4-bit groups. Beginning with the least significant bit (all
the way to the right of the number), write the hexadecimal equivalent of each group.


www.jdrr5.co.cc

www.theo7.co.cc Page 32

For example,
1001111101100101
(base 2)
= 9F65
(base 16)
1001

1111

0110

0101

(base 2)
9 F 6 5 (base 16)
MSB LSB
From Hexadecimal to Binary: To convert a hexadecimal number into a binary, just
reverse the above process; starting all the way to the right, convert each digit into a 4-bit
binary number.
Converting between Binary and Octal
From Binary to Octal: To convert a binary number into its octal form, start by grouping
the digits into 3-bit groups. Beginning with the least significant bit (all the way to the
right of the number), write the octal equivalent of each group.
For example,
10110111011
(base 2)
= 2673
(base 8)
010

110

111

011

(base 2)
2 6 7 3 (base 8)
MSB LSB
From Octal to Binary: To convert an octal number into a binary, just reverse the above
process; starting all the way to the right, convert each digit into a 3-bit binary number.
One and Two Input Gates
AND Gate

NAND Gate

www.jdrr5.co.cc

www.theo7.co.cc Page 33











Output is TRUE only if both inputs are TRUE.

Output is FALSE only if both inputs are TRUE.

A B output

F F F
F T F
T F F
T T T


A B output

0 0 0
0 1 0
1 0 0
1 1 1

(The AND gate is useful for masking or clearing
specified bit positions.)

A B output

F F T
F T T
T F T
T T F


A B output

0 0 1
0 1 1
1 0 1
1 1 0


OR Gate NOR Gate





Output is TRUE if either input (or both) is TRU

Output is FALSE if either input (or both) is TRUE.

A B output

F F F

A B output

0 0 0

A B output

F F T

A B output

0 0 1
www.jdrr5.co.cc

www.theo7.co.cc Page 34

F T T
T F T
T T T

0 1 1
1 0 1
1 1 1

(The OR gate is useful for setting specified bits.)
F T F
T F F
T T F

0 1 0
1 0 0
1 1 0


XOR (EXCLUSIVE OR) Gate XNOR (EXCLUSIVE NOR) Gate
(or Equality Gate)





Output is TRUE if either input (but not both) is TRUE.

Output is FALSE if either input (but not both) is TRUE.

A B output

F F F
F T T
T F T
T T F


A B output

0 0 0
0 1 1
1 0 1
1 1 0

(The XOR gate is useful for complementing specified
bits.)

A B output

F F T
F T F
T F F
T T T


A B output

0 0 1
0 1 0
1 0 0
1 1 1


NOT Function
(or Inverter or Complement Function)


www.jdrr5.co.cc

www.theo7.co.cc Page 35



A output

F T
T F


A output

0 1
1 0

(The NOT function is useful for complementing every
bit.)


Three Input Gates
AND Gate NAND Gate





Output is TRUE only if all inputs are TRUE.

Output is FALSE only if all inputs are TRUE.

A B C output

F F F F
F F T F
F T F F
F T T F

A B C output

0 0 0 0
0 0 1 0
0 1 0 0
0 1 1 0

A B C output

F F F T
F F T T
F T F T
F T T T

A B C output

0 0 0 1
0 0 1 1
0 1 0 1
0 1 1 1
www.jdrr5.co.cc

www.theo7.co.cc Page 36

T F F F
T F T F
T T F F
T T T T

1 0 0 0
1 0 1 0
1 1 0 0
1 1 1 1

T F F T
T F T T
T T F T
T T T F

1 0 0 1
1 0 1 1
1 1 0 1
1 1 1 0


OR Gate NOR Gate





Output is TRUE if any input (or all) is TRUE.

Output is FALSE if any input (or all) is TRUE.

A B C output

F F F F
F F T T
F T F T
F T T T
T F F T
T F T T
T T F T
T T T T


A B C output

0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 1
1 0 0 1
1 0 1 1
1 1 0 1
1 1 1 1


A B C output

F F F T
F F T F
F T F F
F T T F
T F F F
T F T F
T T F F
T T T F


A B C output

0 0 0 1
0 0 1 0
0 1 0 0
0 1 1 0
1 0 0 0
1 0 1 0
1 1 0 0
1 1 1 0


XOR (EXCLUSIVE OR) Gate XNOR (EXCLUSIVE NOR) Gate
www.jdrr5.co.cc

www.theo7.co.cc Page 37






A B C output

F F F F
F F T T
F T F T
F T T F
T F F T
T F T F
T T F F
T T T T


A B C output

0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1


A B C output

F F F T
F F T F
F T F F
F T T T
T F F F
T F T T
T T F T
T T T F


A B C output

0 0 0 1
0 0 1 0
0 1 0 0
0 1 1 1
1 0 0 0
1 0 1 1
1 1 0 1
1 1 1 0



FLIP FLOPS
In digital circuits, a flip-flop is a bistable multivibrator, an electronic circuit that
has two stable states and thereby is capable of serving as one bit of memory. Today, the
term flip-flop has come to mostly denote non-transparent (clocked or edge-triggered)
devices, while the simpler transparent ones are often referred to as latches, however, as
this distinction is quite new, the two words are sometimes used interchangeably (see
history).
www.jdrr5.co.cc

www.theo7.co.cc Page 38

A flip-flop is usually controlled by one or two control signals and/or a gate or
clock signal. The output often includes the complement as well as the normal output. As
flip-flops are implemented electronically, they require power and ground connections.
CLOCKED R-S FLIP-FLOP

To ensure that flip-flops change in synchronism with other parts of
the circuit, they are not allowed to change state until they receive a
CLOCK PULSE.
SET and RESET cannot affect the outputs unless the clock pulse is
high.
In the TIMING DIAGRAM below, at A, SET is HIGH but the
CLOCK is LOW, so there is no change in the outputs.
At B, SET is still HIGH, and CLOCK is HIGH.
Therefore Q goes HIGH.
At C, the CLOCK is HIGH and RESET has gone HIGH.
Therefore Q goes LOW.
At D, the CLOCK is HIGH but SET is LOW.
There is no change in output levels.
At E, CLOCK and SET are both HIGH.
Q goes HIGH.
www.jdrr5.co.cc

www.theo7.co.cc Page 39


CLOCKED D TYPE FLIP-FLOP

The D type flip-flop has only one input (D for Data) apart from the
clock.
The INDETERMINATE state is avoided with this flip-flop.
When the clock goes high, D (a 0 or a 1) is transferred to Q.
When the clock goes low, Q remains unchanged.
Q stores the data until the clock goes high again, when new data
may be available.
www.jdrr5.co.cc

www.theo7.co.cc Page 40


At A, clock and data are high.
Q goes high and stays high until B.
At B, clock is high and data is low.
Q goes low and stays low until C.
At C, clock and data are both high.
Q goes high and stays high until E.
Q does not change during clock pulse D, because clock and data are
still both high.
At E, data is low, so Q goes low.
At F, data is high so Q goes high.

EDGE TRIGGERED FLIP-FLOP

Q follows D while the clock is high.
www.jdrr5.co.cc

www.theo7.co.cc Page 41

If the data at D changes during the clock pulse, then Q will change.
This may be undesirable.
With the edge triggered flip-flop, Q will only follow D during the
instant of the clock edge.
Either clock pulse edge may be used, positive going (rising) or
negative going (falling).


The timing diagram shows the rising edges of the clock pulses.
At edge A, data is low, and even though there is a positive pulse
during the clock period, Q stays low.
At edge B, data is high and Q goes goes high.
At edge C, data is still high and Q stays high.
At edge D, data is still high and Q stays high.
During clock pulse D, data goes low for a period, but Q stays high.
At edge E, data has gone low and Q goes low.
Data goes high for a period during clock pulse E, but Q stays low.
At edge F, data is still low and Q stays low.
Below is a negative edge clocked flip-flop.
www.jdrr5.co.cc

www.theo7.co.cc Page 42



TOGGLE TYPE FLIP-FLOP

This flip-flop toggles (Q changes state) on the negative going edge
of the clock pulse.
T acts as an ENABLE / INHIBIT control.
Q will only toggle on the negative edge of the clock pulse, when T
is high.
Below is shown a D type flip-flop connected as a toggle type.
On each clock pulse positive going edge, Q will go to the state bar Q
was before the clock pulse arrived.
Remember that bar Q is the opposite level to Q.
Therefore Q will toggle.
www.jdrr5.co.cc

www.theo7.co.cc Page 43


MASTER/SLAVE D TYPE FLIP-FLOP
A couple of definitions :-
RIPPLE THROUGH. An input changes level during the clock
period, and the change appears at the output.
PROPAGATION DELAY. The time between applying a signal to
an input, and the resulting change in the output.
These can give problems in logic circuits.
The master/slave flip-flop overcomes them.
It consists of two rising edge triggered D type flip-flops.
The clock of the slave is fed via an inverter so that the falling edge
of the origonal clock pulse becomes a rising edge.
The slave clock pulse is an inverted version of the clock pulse
shown in the lower diagram.
The flip-flops are triggered at different levels of the clock pulse
edge.
When data is to be entered, the slave is isolated from the master, so
that changes at the input do not appear at the output.
Data on D is passed to Q of the master.
The master is then isolated from the D input.
www.jdrr5.co.cc

www.theo7.co.cc Page 44

Data, from the Q of the master, is passed to Q of the slave.

t1. Slave isolated from Master.
t2. Master connected to D input.
t3. Master isolated from D input.
t4. Master Q connected Slave D.

www.jdrr5.co.cc

www.theo7.co.cc Page 45



J-K MASTER/SLAVE FLIP-FLOP


The J-K flip-flop can be wired to behave as most other types of flip-flop.
If J is high and K is low, Q will go high on the negative going edge of the clock
pulse.
If K is high and J is low, Q will go low on the negative going edge of the clock
pulse.
If J and K are both low, Q will not change.
If J and K are both high, the output toggles on the negative going edge of the
clock pulse.
J-K WITH SET AND RESET FLIP-FLOP

www.jdrr5.co.cc

www.theo7.co.cc Page 46


The J and K inputs are said to be SYNCHRONOUS with the clock pulse.
Their effect on the outputs occurs during the negative edge of the clock pulse.
The preset and clear are independent of the clock pulse and are
ASYNCHRONOUS inputs.
With preset low and clear high, Q is set high.
With preset high and clear low, Q is set low.
Half Adder
A half adder is a logic circuit that performs one-digit addition. It requires two
inputs, and the output is the sum of the inputs. An example of a Boolean half
adder is this circuit:

www.jdrr5.co.cc

www.theo7.co.cc Page 47

So, as you can see, the output of the whole circuit is the sum digit (the ones
digit), and the output of the AND gate is the carry digit (the twos digit). Thus,
according to the half-adder, 1 + 1 = 10 (keep in mind that this is in base 2).
Likewise, 0 + 1 and 1 + 0 both equal 01, or 1.
If you want to add two multiple-digit numbers, you must use a full adder. A full
adder is basically two (or more) half adders linked together.
Full Adder
A full adder is a logical circuit that performs an addition operation on three
binary digits. The full adder produces a sum and carry value, which are both
binary digits. It can be combined with other full adders (see below) or work on
its own.

S = (A xor B) xor Ci

Co = (A and B) or (Ci and (A xor B))

= (A and B) or (B and Ci) or (Ci and A)

Rearranging the circuit, it can be seen that it comprises two half-adders and an OR gate:
www.jdrr5.co.cc

www.theo7.co.cc Page 48



REGISTERS
A register that is capable of shifting data one bit at a time is called a shift
register. The logical configuration of a serial shift register consists of a chain of flip-
flops connected in cascade, with the output of one flip-flop being connected to the input
of its neighbour. The operation of the shift register is synchronous; thus each flip-flop is
connected to a common clock. Using D flip-flops forms the simplest type of shift-
registers.
The basic data movements possible within a four-bit shift register is shown in Figure 3-
22.
www.jdrr5.co.cc

www.theo7.co.cc Page 49


Figure 3-22 Data movement diagrams
Serial In - Serial Out
Shift Registers
A basic four-bit shift register can be constructed using four D flip-flops, as shown
below. The operation of the circuit is as follows. The register is first cleared, forcing
all four outputs to zero. The input data is then applied sequentially to the D input of the
first flip-flop on the left (FF0). During each clock pulse, one bit is transmitted from left
to right. Assume a data word to be 1001. The least significant bit of the data has to be
shifted through the register from FF0 to FF3.
www.jdrr5.co.cc

www.theo7.co.cc Page 50



In order to get the data out of the register, they must be shifted out serially. This can be
done destructively or non-destructively. For destructive readout, the original data is lost
and at the end of the read cycle, all flip-flops are reset to zero.

To avoid the loss of data, an arrangement for a non-destructive reading can be done by
adding two AND gates, an OR gate and an inverter to the system. The construction of
this circuit is shown below.

The data is loaded to the register when the control line is HIGH (ie WRITE). The data
can be shifted out of the register when the control line is LOW (ie READ). This is
shown in the animation below.

www.jdrr5.co.cc

www.theo7.co.cc Page 51

Serial In - Parallel Out
Shift Registers
For this kind of register, data bits are entered serially in the same manner as discussed in
the last section. The difference is the way in which the data bits are taken out of the
register. Once the data are stored, each bit appears on its respective output line, and all
bits are available simultaneously. A construction of a four-bit serial in - parallel out
register is shown below.

In the animation below, we can see how the four-bit binary number 1001 is shifted to
the Q outputs of the register.


Parallel In - Serial Out
Shift Registers
A four-bit parallel in - serial out shift register is shown below. The circuit uses D flip-
flops and NAND gates for entering data (ie writing) to the register.
www.jdrr5.co.cc

www.theo7.co.cc Page 52


D0, D1, D2 and D3 are the parallel inputs, where D0 is the most significant bit and D3
is the least significant bit. To write data in, the mode control line is taken to LOW and
the data is clocked in. The data can be shifted when the mode control line is HIGH as
SHIFT is active high. The register performs right shift operation on the application of a
clock pulse, as shown in the animation below.

COUNTERS

In electronics, counters can be implemented quite easily using register-type circuits such
as the flip-flop, and a wide variety of designs exist, e.g:
Asynchronous (ripple) counters
Synchronous counters
Johnson counters
Decade counters
Up-Down counters
Ring counters
www.jdrr5.co.cc

www.theo7.co.cc Page 53

Each is useful for different applications. Usually, counter circuits are digital in nature,
and count in binary, or sometimes binary coded decimal. Many types of counter circuit
are available as digital building blocks, for example a number of chips in the 4000 series
implement different counters.
Asynchronous (ripple) counters

Asynchronous Counter created from JK flip-flops.
The simplest counter circuit is a single D-type flip flop, with its D (data) input fed from
its own inverted output. This circuit can store one bit, and hence can count from zero to
one before it overflows (starts over from 0). This counter will increment once for every
clock cycle and takes two clock cycles to overflow, so every cycle it will alternate
between a transition from 0 to 1 and a transition from 1 to 0. Notice that this creates a
new clock with a 50% duty cycle at exactly half the frequency of the input clock. If this
output is then used as the clock signal for a similarly arranged D flip flop (remembering
to invert the output to the input), you will get another 1 bit counter that counts half as
fast. Putting them together yields a two bit counter:
cycle Q1 Q0 (Q1:Q0)dec
0 0 0 0
1 0 1 1
www.jdrr5.co.cc

www.theo7.co.cc Page 54

2 1 0 2
3 1 1 3
4 0 0 0



Synchronous counters

A 4-bit synchronous counter using J-K Flip-flops
Where a stable count value is important across several bits, which is the case in
most counter systems, synchronous counters are used. These also use flip-flops, either the
D-type or the more complex J-K type, but here, each stage is clocked simultaneously by a
common clock signal. Logic gates between each stage of the circuit control data flow
from stage to stage so that the desired count behavior is realized. Synchronous counters
can be designed to count up or down, or both according to a direction input, and may be
presetable via a set of parallel "jam" inputs. Most types of hardware-based counter are of
this type.
A simple way of implementing the logic for each bit of an ascending counter
(which is what is shown in the image to the right) is for each bit to toggle when all of the
less significant bits are at a logic high state. For example, bit 1 toggles when bit 0 is logic
www.jdrr5.co.cc

www.theo7.co.cc Page 55

high; bit 2 toggles when both bit 1 and bit 0 are logic high; bit 3 toggles when bit 2, bit 1
and bit 0 are all high; and so on.
Johnson counters
A Johnson counter is a special case of shift register, where the output from the last
stage is inverted and fed back as input to the first stage. A pattern of bits equal in
length to the shift register thus circulates indefinitely. These counters are sometimes
called "walking ring" counters, and find specialist applications, including those
similar to the decade counter, digital to analogue conversion, etc.
Decade counters
Decade counters are a kind of counter that counts in tens rather than having a binary
representation. Each output will go high in turn, starting over after ten outputs have
occurred. This type of circuit finds applications in multiplexers and demultiplexers,
or wherever a scanning type of behaviour is useful. Similar counters with different
numbers of outputs are also common.
Up-Down Counters
It is a combination of up counter and down counter, counting in straight binary
sequence. There is an up-down selector. If this value is kept high, counter
increments binary value and if the value is low, then counter starts decrementing the
count. The Down counters are made by using the complemented output to act as the
clock for the next flip-flop in the case of Asynchronous counters. An Up counter is
constructed by linking the Q out of the J-K Flip flop and putting it into a Negative
Edge Triggered Clock input. A Down Counter is constructed by taking the Q output
and putting it into a Positive Edge Triggered input.


www.jdrr5.co.cc

www.theo7.co.cc Page 56

Ring Counters
A ring counter is a counter that counts up and when it reaches the last number
that is designed to count up to, it will reset itself back to the first number. For
example, a ring counter that is designed using 3 JK Flip Flops will count
starting from 001 to 010 to 100 and back to 001. It will repeat itself in a 'Ring'
shape and thus the name Ring Counter is given.
MULTIPLEXERS
A multiplexer performs the function of selecting the input on any one of 'n' input
lines and feeding this input to one output line. Multiplexers are used as one method of
reducing the number of integrated circuit packages required by a particular circuit design.
This in turn reduces the cost of the system.
Assume that we have four lines, C0, C1, C2 and C3, which are to be multiplexed
on a single line, Output (f). The four input lines are also known as the Data I nputs. Since
there are four inputs, we will need two additional inputs to the multiplexer, known as the
Select I nputs, to select which of the C inputs is to appear at the output. Call these select
lines A and B.
The gate implementation of a 4-line to 1-line multiplexer is shown below:
www.jdrr5.co.cc

www.theo7.co.cc Page 57


The circuit symbol for the above multiplexer is:

DEMULTIPLEXERS
A demultiplexer (DMUX) is a device which essentially performs the opposite
operation to the MUX. That is, it functions as an electronic switch (/data distributor) to
route an incoming data signal to one of several outputs. Figure 2-15 shows the logic
www.jdrr5.co.cc

www.theo7.co.cc Page 58

symbol for the 1-line-to-4-line demultiplexer circuit and Table 2-15 list the associated
Truth table. The corresponding logic circuit implementation is then shown in Figure 2-16.

Figure 2-15 Logic symbol for 1-line-to-4-line demultiplexer


Data
Address Outputs
S
1
S
0
Y
0
Y
1
Y
2
Y
3

D 0 0 D 0 0 0
D 0 1 0 D 0 0
D 1 0 0 0 D 0
D 1 1 0 0 0 D
Table 2 -15 Demultiplexer Function Tables

www.jdrr5.co.cc

www.theo7.co.cc Page 59


Figure 2-16 1-line-to-4-line Demultiplexer
Encoder
An encoder is a device used to change a signal (such as a bitstream) or data into a
code. The code may serve any of a number of purposes such as compressing information
for transmission or storage, encrypting or adding redundancies to the input code, or
translating from one code to another. This is usually done by means of a programmed
algorithm, especially if any part is digital, while most analog encoding is done with
analog circuitry.

Single bit 4 to 2 Encoder
A single bit 4 to 2 encoder takes in 4 bits and outputs 2 bits. It is assumed that there are
only 4 types of input signals these are : 0001, 0010, 0100, 1000.
www.jdrr5.co.cc

www.theo7.co.cc Page 60




I
3
I
2
I
1
I
0
O
1
O
0

0 0 0 1 0 0
0 0 1 0 0 1
0 1 0 0 1 0
1 0 0 0 1 1
4 to 2 encoder
[edit] Priority encoder
A priority encoder prioritizes more significant bits in the data stream, and once it finds a
high signal will ignore all other bits. An example of a single bit 4 to 2 encoder is shown.
I
3
I
2
I
1
I
0
O
1
O
0

0 0 0 d 0 0
0 0 1 d 0 1
0 1 d d 1 0
1 d d d 1 1
4 to 2 priority encoder
DECODER
A decoder is a device which does the reverse of an encoder, undoing the encoding so that
the original information can be retrieved. The same method used to encode is usually just
reversed in order to decode.
Gate level circuit diagram of a single bit 4-to-2 line encoder
www.jdrr5.co.cc

www.theo7.co.cc Page 61

In digital electronics this would mean that a decoder is a multiple-input, multiple-output
logic circuit that converts coded inputs into coded outputs, where the input and output
codes are different. e.g. n-to-2
n
, BCD decoders.
Enable inputs must be on for the decoder to function, otherwise its outputs assume a
single "disabled" output code word. Decoding is necessary in applications such as data
multiplexing, 7 segment display and memory address decoding.
The simplest decoder circuit would be an AND gate because the output of an AND gate
is "High" (1) only when all its inputs are "High".
Example: A 2-to-4 Line Single Bit Decoder
A slightly more complex decoder would be the n-to-2
n
type binary decoders. These type
of decoders are combinational circuits that convert binary information from 'n' coded
inputs to a maximum of 2
n
unique outputs. We say a maximum of 2
n
outputs because in
case the 'n' bit coded information has unused bit combinations, the decoder may have less
than 2
n
outputs. We can have 2-to-4 decoder, 3-to-8 decoder or 4-to-16 decoder. We can
form a 3-to-8 decoder from two 2-to-4 decoders (with enable signals).
A 2-to-4 line decoder/demultiplexer is shown below.
www.jdrr5.co.cc

www.theo7.co.cc Page 62









As a decoder, this circuit
takes an n-bit binary
number and produces an
output on one of 2
n
output
lines. It is therefore
commonly defined by the
number of addressing input
lines and the number of
data output lines. Typical
decoder/demultiplexer ICs
might contain two 2-to-4
line circuits, a 3-to-8 line
circuit, or a 4-to-16 line
circuit. One exception to
the binary nature of this
circuit is the 4-to-10 line
decoder/demultiplexer,
which is intended to
convert a BCD (Binary
Coded Decimal) input to an
output in the 0-9 range.
If you use this circuit
as a demultiplexer, you
may want to add data
latches at the outputs to
retain each signal while
the others are being
transmitted.

www.jdrr5.co.cc

www.theo7.co.cc Page 63

UNIT III MICROPROCESSORS
ADDRESS BUS
The 8085 microprocessor has a 16 bit address lines (A15-A0), These are the
unidirectional bus, the address buses are divided in to two groups, higher order bus
((A15-A8)and lower ordered bus(A7-A0). The lower order address bus AD7-AD0 are
called as multiplexed bus. The lower ordered bus can carry the address and data.

DATA BUS
The 8085 microprocessor has a 8bit data lines (A7-A0), The data lines AD7 - AD0 are
bidirectional and are multiplexed. These buses can carry address and data, the address
transfer and the data transfer is controlled by the control signal ALE.

CONTROL & STATUS SIGNAL
The group of signals includes two control signals (RD and WR), three status signals
(IO/M, S1 and S0) to identify the operation, and a special signal (ALE), to select the
mode of multiplexed bus.
RD: Read control signal is an active low signal. Which indicates that the microprocessor
connected to I/O or memory device has to read the data available in the data bus.
WR: Write control signal is an active low signal. which indicates that the data on the data
bus are to be written in the selected I/O or memory device.
10/M: This status signals indicates whether the operation is with I/O devices or memory
when it is high, it indicates an I/O operation. When it is low, it indicates a memory
operation.
S1 and So: These are status signals, to identify the operation such as opcode fetch,
memory read, memory write, I/O read, I/O write, etc.
ALE :(Address Latch Enable) This is a positive pulse generated at the beginning of an
operation. It indicates that AD7toADo are lower order address lines. This signal is used
to enable the latch of the lower order address from the multiplexed bus.

POWER SUPPLY AND CLOCK FREQUENCY
Power supply signals are:
www.jdrr5.co.cc

www.theo7.co.cc Page 64

a. Vcc + 5V power supply
b. Vss Ground Reference.
Clock signals are
c. X1, X2: A crystal is connected at these two pins. Two internally divides the Frequency;
therefore to operate a system at 3MHz, the crystal should have a frequency of 6MHz.
CLK: clock signal, which controls the whole operations of the microprocessor.

EXTERNALLY INITIATED SIGNALS
External initiated signals are 5 interrupt signals, RESET HOLD and READY signals.
INTR This signal is active high signal, which is used to indicate the interrupt.
INTA This signal is active low signal, which issued to acknowledge the interrupt.
RST Restart Interrupt signal, which are vectored interrupts that transfer the
program control to specific memory location.
TRAP This is a non-maskable interrupt and has the highest priority.
HOLD This signal indicates that a peripheral such as a DMA controllers is requesting to
use the address and data bus.
HLDA This is an acknowledge signal for the HOLD request signal given by the
microprocessor.
READY This signal is used to delay the microprocessor read or write cycles until a
slow responding peripheral is ready to send or accept data.
RESET IN When the signal on this pin goes low, the program counter is set to zero, the
MPU is reset.
RESET OUT This signal indicates that the MPU is being reset.
SERIAL I/O PORTS
The 8085 has two signals to perform the serial transmission through SID and SOD.
(Serial input data and serial output data).





www.jdrr5.co.cc

www.theo7.co.cc Page 65
































www.jdrr5.co.cc

www.theo7.co.cc Page 66



UNIT IV MICROPROCESSOR MEMORY DEVICES
Read-Only Memory (ROM)
One major type of memory that is used in PCs is called read-only memory, or ROM for
short. ROM is a type of memory that normally can only be read, as opposed to RAM
which can be both read and written. There are two main reasons that read-only memory is
used for certain functions within the PC:
Permanence: The values stored in ROM are always there, whether the power is
on or not. A ROM can be removed from the PC, stored for an indefinite period of
time, and then replaced, and the data it contains will still be there. For this reason,
it is called non-volatile storage. A hard disk is also non-volatile, for the same
reason, but regular RAM is not.
Security: The fact that ROM cannot easily be modified provides a measure of
security against accidental (or malicious) changes to its contents. You are not
going to find viruses infecting true ROMs, for example; it's just not possible. (It's
technically possible with erasable EPROMs, though in practice never seen.)
Read-only memory is most commonly used to store system-level programs that we want
to have available to the PC at all times. The most common example is the system BIOS
program, which is stored in a ROM called (amazingly enough) the system BIOS ROM.
Having this in a permanent ROM means it is available when the power is turned on so
that the PC can use it to boot up the system. Remember that when you first turn on the PC
the system memory is empty, so there has to be something for the PC to use when it starts
up.
ROM is supposed to be that the contents cannot be changed, there are times when being
able to change the contents of a ROM can be very useful. There are several ROM
variants that can be changed under certain circumstances; these can be thought of as
www.jdrr5.co.cc

www.theo7.co.cc Page 67

"mostly read-only memory". :^) The following are the different types of ROMs with a
description of their relative modifiability:
ROM: A regular ROM is constructed from hard-wired logic, encoded in the
silicon itself, much the way that a processor is. It is designed to perform a specific
function and cannot be changed. This is inflexible and so regular ROMs are only
used generally for programs that are static (not changing often) and mass-
produced. This product is analagous to a commercial software CD-ROM that you
purchase in a store.
Programmable ROM (PROM): This is a type of ROM that can be programmed
using special equipment; it can be written to, but only once. This is useful for
companies that make their own ROMs from software they write, because when
they change their code they can create new PROMs without requiring expensive
equipment. This is similar to the way a CD-ROM recorder works by letting you
"burn" programs onto blanks once and then letting you read from them many
times. In fact, programming a PROM is also called burning, just like burning a
CD-R, and it is comparable in terms of its flexibility.
Erasable Programmable ROM (EPROM): An EPROM is a ROM that can be
erased and reprogrammed. A little glass window is installed in the top of the
ROM package, through which you can actually see the chip that holds the
memory. Ultraviolet light of a specific frequency can be shined through this
window for a specified period of time, which will erase the EPROM and allow it
to be reprogrammed again. Obviously this is much more useful than a regular
PROM, but it does require the erasing light. Continuing the "CD" analogy, this
technology is analogous to a reusable CD-RW.
Electrically Erasable Programmable ROM (EEPROM): The next level of
erasability is the EEPROM, which can be erased under software control. This is
the most flexible type of ROM, and is now commonly used for holding BIOS
programs. When you hear reference to a "flash BIOS" or doing a BIOS upgrade
by "flashing", this refers to reprogramming the BIOS EEPROM with a special
software program. Here we are blurring the line a bit between what "read-only"
www.jdrr5.co.cc

www.theo7.co.cc Page 68

really means, but remember that this rewriting is done maybe once a year or so,
compared to real read-write memory (RAM) where rewriting is done often many
times per second!
Magnetic Bubble Memory:
A memory that stores data in the form of bubbles, or circular areas, on a thin film
of magnetic silicate. No longer used in most computers, magnetic bubble memory
is similar to RAM but does not lose the stored information when the computer is
turned off.
Bubble memory is a type of non-volatile computer memory that uses a thin film
of a magnetic material to hold small magnetized areas, known as bubbles, which
each store one bit of data
Hard Disk:
A magnetic disk on which you can store computer data. The term hard is used to
distinguish it from a soft, or floppy, disk. Hard disks hold more data and are faster than
floppy disks. A hard disk, for example, can store anywhere from 10 to more than 100
gigabytes, whereas most floppies have a maximum storage capacity of 1.4 megabytes.
A single hard disk usually consists of several platters. Each platter requires two
read/write heads, one for each side. All the read/write heads are attached to a single
access arm so that they cannot move independently. Each platter has the same number of
tracks, and a track location that cuts across all platters is called a cylinder. For example, a
typical 84 megabyte hard disk for a PC might have two platters (four sides) and 1,053
cylinders.
In general, hard disks are less portable than floppies, although it is possible to buy
removable hard disks.
Floppy Disk:

www.jdrr5.co.cc

www.theo7.co.cc Page 69






A soft magnetic disk. It is called
floppy because it flops if you
wave it (at least, the 5-inch
variety does). Unlike most hard
disks, floppy disks (often called floppies or diskettes) are portable, because you can
remove them from a disk drive. Disk drives for floppy disks are called floppy drives.
Floppy disks are slower to access than hard disks and have less storage capacity, but
they are much less expensive. And most importantly, they are portable.

The Keyboard
The keyboard is perhaps the most efficient form of human input to an electronic
system. Our faculties are specially adapted to hand and finger movements (we can
learn to type without having to think about it consciously, and some of us can play
pianos). In fact, two-hand typing is an essential skill, the only one I ever learned in
public school.






www.jdrr5.co.cc

www.theo7.co.cc Page 70

The principle of the electronic keyboard is shown at the
right. It is essentially crossbar switching, or a key matrix.
There are multiple rows "x" that may be connected
individually to ground, and multiple columns "y" with
pullup resistors as shown. When the keyswitch at the
intersection of row x, currently grounded, and column y is
pressed, the output voltage of column y goes from +5 to ground, which can be sensed
by the controlling circuit, identifying the key that was pressed. For eight rows and
eight columns, 64 keys can be employed. The controlling circuit is continuously
grounding successive rows, and scanning the columns for each row, to detect a
keypress. This can be done much more rapidly than a person can press keys.
At least two details must be considered. First, since the keyswitches are mechanical,
they may "bounce" for a few milliseconds when pressed. The circuit testing the
columns must read a column it finds low a second time to see if it is still low, to
verify that the keypress is real, and not just a bounce of a previous keypress
(computers are very fast, and could process a keypress and return while the key was
still bouncing, so instead of A you would see AAA). An interval of 20 ms is usually
sufficient for this "debouncing." The second problem is the simultaneous pressing of
two or more keys. There is an order of priority established by the scanning sequence
that normally takes care of this well enough.
A keyboard can be managed by a computer with ease. At the parallel port, we have 8
output data bits, and 5 input bits, which could scan an 8 x 5 key matrix handling 40
keys without further complication. A keyboard can also be managed by fixed logic,
and present the decoded data without the aid of a computer. Computer keyboards are,
in fact, managed by an embedded microcomputer that sends keypresses to the BIOS
keyboard buffer using a keyboard interrrupt. I have a Cherry Pro B70-05AB keyboard
with discrete logic. While a key is pressed, the ASCII code for the corresponding
character appears at the output, while a strobe signal STB ouputs a positive pulse
lasting 100 s. There is also a complementary strobe output /STB. The 8th bit of the
www.jdrr5.co.cc

www.theo7.co.cc Page 71

data is an even parity bit, which should usually be ignored.
An interface for the keyboard is shown at the left. Since
the data disappears when the key is released, the data
must be latched. A 74LS374 is appropriate for this task.
The STB signal latches the output data so that it
persists. The output enable /OE is shown tied high, so
the output is permanently enabled. For a computer bus
interface, this pin would normally be high except on a
read cycle from the assigned address. A bidirectional
parallel port can receive data from the latch as shown. The msb of the data can be
hard-wired to 0 or 1, as desired. Most printers respond to all 8 bits, and give different
results for the msb 0 and 1.
There is also a 74LS74 flip-flop used for handshaking. The same STB pulse that
latches new data also causes the output of the flip-flop to go high. This is a "data
available" or DAV signal that the computer can poll (sample repeatedly) to see when
new data is available. When the computer reads the data, it also pulses the "data
accepted" or DAC line low, which clears the flip-flop, making DAV 0. This two-line
polling handshaking works very well, in cases where an interrupt would be wasted.
To use an interrupt, the /STB signal would be connected to an interrupt request line.
When a new character was available, the computer would service the interrupt and
read the character immediately (in this case, a latch would not be necessary).
The Printer
The serial-impact dot-matrix printer is a much simpler and cheaper device than the
teletype printer with its type bars. It was made possible by the microprocessor,
leading to much cheaper and faster printing. The small print head moves instead of
the platen, and (usually) carries the inked ribbon with it. Together with the paper feed
mechanism, these are the only mechanical parts, driven by two stepping motors.
Serial-impact means that the letters are formed by vertical columns of pixels. The
www.jdrr5.co.cc

www.theo7.co.cc Page 72

original printers had 9 pins, but 24-pin printers came in later and gave very good
results. The inkjet print head is even simpler mechanically, using small spurts of ink
controlled electrostatically instead of impact pins and a ribbon. Fanfold paper, a long
strip 9-1/2" wide with sprocket holes (0.5" spacing) down each side that was laser-
scored to peel down to 8-1/2 x 11, has been replaced by single-sheet feeders on recent
printers.
Printers typically fill a print buffer and print out what is in it on receiving a carraige
return. Data transfer is much faster than printing, so this saves computer time. To
simulate a teletype, we would like a printer that prints each character as it is received.
It is possible to do this by flushing the print buffer after each character. The printer I
used here is the Panasonic (Matshusita) KX-P1123 24-pin dot matrix printer. This is
an excellent printer making copy almost as good as an inkjet's, but the fanfold paper
loading is diabolical. I also used an Okidata Microline 192, a 9-pin printer with IBM-
compatible codes that is typical of earlier dot-matrix printers. In this page, we are
talking about character-based printers, which accept a byte and then construct and
print the corresponding character themselves. Most printers used now mostly accept
graphic data from Windows, not individual characters.
The KX-P1123 and the 192 were furnished with manuals listing control codes and
programming information, which is necessary for making full use of the printers.
Some word processors need these codes so they can print intelligently to your printer.
Recent printers, such as the HP-540 Deskjet, are not furnished with this information,
though it is mentioned that a technical manual can be ordered, which probably is
expensive and contains a lot of information one does not need to know. This seems
mainly to be a business ploy to screw the user so that the software has to be obtained
from the company. It is very easy to write printer drivers for simple uses, incidentally,
especially for DOS. Another reason for this is not just weaselly greed, but that most
computer equipment is now bought by "consumers" who don't know what they are
doing, and don't care to find out--they just want it to work when plugged in, so that
any information would be wasted on them. In line with this, the KX-P1123 has an
www.jdrr5.co.cc

www.theo7.co.cc Page 73

elaborate front panel (that takes intelligence to operate), while the HP-540 has only an
on-off switch and a button to press to restart is after running out of paper. Such
printers are furnished with Windows drivers, which have not always been written
correctly. It was easy to write DOS drivers, which acted like files you could send data
to, and were loaded with the AUTOEXEC file when the computer was booted. One
can actually send ASCII data directly to the parallel port quite successfully, bypassing
DOS, BIOS and any drivers.
On the subject of HP printers, it is droll that the much-overrated company now
derives most of its revenue from printers, having finally designed a product with
consumer appeal that sold for a reasonable price. Now prices are climbing above
those of competitors with excellent products, and ink cartridges are becoming
equipped with chips that mark them as "empty" when they have been used once, and
with terminal dates after which they will not be accepted by the printer. Most of the
printer profit actually comes from cartridges, so this is understandable. One can
always make more money in business by cheating people than by being honest, a fact
not lost on businessmen, as we have recently observed. It's time for HP's printer
bubble to burst.
It is tedious to investigate how a printer works with DEBUG, as will be seen below,
so it is better to write a program (in C, for example) that can select different ports,
report the status and control conditions on the interface, send individual bytes and
strobe them in, type characters to send to the printer, flush the print buffer, and
perform a number of other functions. My program can select superscript, subscript,
underline, emphasized, double height, double width, character set, and a few other
things as well. Making and testing such a program will verify that you understand
how to control the functions, and will enable you to write printer drivers, at least for
DOS. You will discover many surprises in how your printer works!
The KX-P1123 print head contains a vertical staggered column of 24 pins, 1/180"
apart vertically, and 1/120" apart horizontally. The pins fire through an inked ribbon,
making a dot on the paper. Since the pins are 1/127" in diameter, the dots made by
www.jdrr5.co.cc

www.theo7.co.cc Page 74

them can overlap. The print quality is very good, and the dots are not seen in letter-
quality printing. The size of the print head controls the size of the characters, which
are usually 0.11" high, or 8-point (1 point = 1/72"). This leaves two rows of pins
above and below, used for superscripts, subscripts and underlining. The normal line
feed amount is 1/6", though any amount from 1/360" to 2" can be selected. This is
handled by the paper drive, and can be programmed. The print head moves left to
right or right to left, and can overprint any position. The printing is based on a pixel
matrix, 24 x 11 for draft-quality and 24 x 37 for letter-quality. The printer is capable
of graphics printing as well.
Letters are spaced horizontally at 10 c.p.i. (pica), 12 c.p.i. (elite), 15 c.p.i. (micron)
and 17 c.p.i. or 20 c.p.i. (compressed). Pica spacing was the earlier rule, with 6 lines
per inch. The difference between pica and elite is just the space between the letters
(which can be programmed). This means that one 7" line can contain 70 pica, 84 elite,
105 micron or 140 compressed characters. The page length is 11" by default, but can
be set for up to 22" as well as shorter. If 9" is used for printing, leaving 1" margins at
top and bottom, there will be 54 printed lines. Therefore, one page of elite pitch text
will require 4644 bytes. By comparison, 9" x 7" graphics with 72 pixels per inch
would take at least 36,288 bytes, about 7.8 times as much. Page layout and line feed
are important considerations in using a printer.
The parallel interface is the Centronics standard, which agrees with the original PC
printer port. The printer has a female Centronics connector, while the printer port has
a DB-25S connector. Special printer cables compromise between these connectors. If
you simply plug in the printer to a parallel port and turn it on, it will usually work
with any standard printing program, such as the PRINT command in DOS. To see
that your printer works, connect it to a parallel port, say LPT2, and turn it on. Prepare
a short ASCII text file with any utility, and call it, say TEST.TXT. At the DOS
prompt, type PRINT TEST.TXT. DOS will ask you for what device, and tell it LPT2.
It will tell you that it has installed the resident part of PRINT, and will then print out
the file. This at least will tell you if the printer has been properly installed.
www.jdrr5.co.cc

www.theo7.co.cc Page 75

The parallel interface signals are the 8 data bits (input to printer), on pins 2-9, the data
strobe /STB on pin 1 (input), the interfacing signals BUSY (inverted on pin 11) and
/ACK on pin 10, both outputs, the printer reset signal /PRIME on pin 16 (input), the
paper out signal PO on pin 12 (output), the SELECT signal on pin 13 (output) that
signals that the printer is ON LINE, an /ERROR signal on pin 15 (outupt) that shows
when the printer is offended, and finally an /AUTO FEED signal on pin 14 (input)
that tells the printer to add a LF (line feed) after every CR (carriage return)
automatically when low.
The handshaking is very important, since the computer is faster than the printer
buffer, and the printer buffer is faster than the printing mechanism. Two signals are
provided, BUSY for polling and /ACK for interrupt. Only one need be used and the
other ignored. I will use BUSY here. The BUSY signal must read high (the level is
inverted) when the printer buffer is ready to receive a new character. The normal
initialization of the parallel port makes pin 16 low, which causes the printer to be in a
reset state. Pin 16 must be pulled high for the printer to work. All other inputs and
outputs can be neglected for the purposes of testing

Keyboard Interfacing
The keyboard uses a special, dedicated interface to talk to the PC. The basic design
and operation of this interface is largely unchanged since the days of the old IBM
PC/AT of the mid-1980s. Only in the last few years has the availability of the
universal serial bus (USB) on newer systems created an alternative way of attaching a
keyboard to the PC. The conventional keyboard interface is still used in almost all
PCs, however, despite USB's growing popularity.
The traditional keyboard interface is in some ways similar to a "stripped-down
version" of a regular serial (COM) port. Communication between the keyboard and
the PC is accomplished over the lines in the keyboard cable, which connect the
www.jdrr5.co.cc

www.theo7.co.cc Page 76

internal controller in the keyboard with a matching device on the motherboard, called
the keyboard controller. This is really a misnomer of sorts, since it's arguable that the
chip within the system doesn't control the keyboard; the chip within the keyboard
does! It would probably be better if it were called the keyboard interface controller,
actually.
Motherboards in older PCs, which were designed before the invention of integrated
chipsets, used an Intel 8042 chip for their keyboard controller. This became the
standard on virtually all PCs. Today, motherboards don't necessarily include a
physical 8042 chip, but they emulate its functionality for the sake of compatibility.
The keyboard controller is also responsible for other tasks within the PC


Asynchronous transmission uses start and stop bits to signify the beginning bit
ASCII character would actually be transmitted using 10 bits e.g.: A "0100 0001"
would become "1 0100 0001 0". The extra one (or zero depending on parity bit) at the
start and end of the transmission tells the receiver first that a character is coming and
secondly that the character has ended. This method of transmission is used when data
are sent intermittently as opposed to in a solid stream. In the previous example the
start and stop bits are in bold. The start and stop bits must be of opposite polarity.
This allows the receiver to recognize when the second packet of information is being
sent.
Synchronous transmission uses no start and stop bits but instead synchronizes
transmission speeds at both the receiving and sending end of the transmission using
clock signals built into each component. A continual stream of data is then sent
between the two nodes. Due to there being no start and stop bits the data transfer rate
is quicker although more errors will occur, as the clocks will eventually get out of
sync, and the receiving device would have the wrong time that had been agreed in
protocol (computing) for sending/receiving data, so some bytes could become
www.jdrr5.co.cc

www.theo7.co.cc Page 77

corrupted (by losing bits). Ways to get around this problem include re-
synchronization of the clocks and use of check digits to ensure the byte is correctly
interpreted and received.

Direct Memory Access (DMA)
Using interrupts driven device drivers to transfer data to or from hardware devices
works well when the amount of data is reasonably low. For example a 9600 baud
modem can transfer approximately one character every millisecond (
'th second).
If the interrupt latency, the amount of time that it takes between the hardware device
raising the interrupt and the device driver's interrupt handling routine being called, is
low (say 2 milliseconds) then the overall system impact of the data transfer is very
low. The 9600 baud modem data transfer would only take 0.002% of the CPU's
processing time. For high speed devices, such as hard disk controllers or ethernet
devices the data transfer rate is a lot higher. A SCSI device can transfer up to 40
Mbytes of information per second.
Direct Memory Access, or DMA, was invented to solve this problem. A DMA
controller allows devices to transfer data to or from the system's memory without the
intervention of the processor. A PC's ISA DMA controller has 8 DMA channels of
which 7 are available for use by the device drivers. Each DMA channel has associated
with it a 16 bit address register and a 16 bit count register. To initiate a data transfer
the device driver sets up the DMA channel's address and count registers together with
www.jdrr5.co.cc

www.theo7.co.cc Page 78

the direction of the data transfer, read or write. It then tells the device that it may start
the DMA when it wishes. When the transfer is complete the device interrupts the PC.
Whilst the transfer is taking place the CPU is free to do other things.
Device drivers have to be careful when using DMA. First of all the DMA controller
knows nothing of virtual memory, it only has access to the physical memory in the
system. Therefore the memory that is being DMA'd to or from must be a contiguous
block of physical memory. This means that you cannot DMA directly into the virtual
address space of a process. You can however lock the processes physical pages into
memory, preventing them from being swapped out to the swap device during a DMA
operation. Secondly, the DMA controller cannot access the whole of physical
memory. The DMA channel's address register represents the first 16 bits of the DMA
address, the next 8 bits come from the page register. This means that DMA requests
are limited to the bottom 16 Mbytes of memory.
DMA channels are scarse resources, there are only 7 of them, and they cannot be
shared between device drivers. Just like interrupts the device driver must be able to
work out which DMA channel it should use. Like interrupts, some devices have a
fixed DMA channel. The floppy device, for example, always uses DMA channel 2.
Sometimes the DMA channel for a device can be set by jumpers, a number of
ethernet devices use this technique.

You might also like