http://www.digikey.com/Web%20Export/Supplier%20Content/Exar_1016/PDF/exar-dan-108.pdf?redirected=1

E
DATA COMMUNICATIONS APPLICATION NOTE
DAN108
March 2000
UART CRYSTAL OSCILLATOR DESIGN GUIDE
Author: Reinhardt Wagner
1. Frequently Asked Questions associated with UART Crystal Oscillators
•
•
•
•
•
•
•
“How does a crystal oscillator work?”
•
•
“Our crystal oscillator does not start up. Why?”
“What crystal should I use?”
“Do we have to use the oscillator circuit specified in the UART data sheet?”
“I want to use a different crystal. How do we adapt the circuit?”
“How accurate must the external R’s and C’s be?”
“What is the UART’s on chip oscillator made up of?”
“A second source UART’s data sheet specifies different oscillator loading capacitors - will
this work with the equivalent EXAR UART?”
”How accurate must the crystal’s frequency of oscillation be for the serial communication
link to work reliably?”
2. Generalized Oscillator
An oscillator may be modeled by the block diagram shown in Figure 1.
Active Element
Vout
A(ω)
Passive Feedback Element
F(ω)
Figure 1: Generalized Oscillator
1
EXAR Corporation, 48720 Kato Road, Fremont, CA 94538 Tel 510-668-7000 - Fax 510-668-7017 www.exar.com
E
DATA COMMUNICATIONS APPLICATION NOTE
DAN108
Here A(ω) is the transfer function of the amplifier that adds enough energy to the loop in order to
keep it oscillating, and F(ω) is the transfer function of a feedback element that sets the frequency
selectivity.
A and F are complex quantities that can be described by a gain and phase component:
A(ω ) =| A(ω ) | ⋅eα jω t
F (ω ) =| F (ω ) | ⋅e β jω t
Oscillation is achieved by feeding back enough electrical energy that is delayed by nx360° such
that the total loop gain is unity. Barkhausen‘s Criterion reflects this condition for steady state
oscillation:
A(ω)⋅F(ω)= 1
α(ω) + β(ω) = 2π.n
(amplitude condition)
(phase condition)
When both conditions are met, oscillation occurs at a frequency, f = ω/2π.
3. Oscillator Startup
In order to get the oscillator to start up, it needs initial electrical energy. Power-up transients as
well as noise can supply the needed energy. However the energy levels may not be adequately
high enough. This can be complemented by large open loop gain at any frequency that boosts the
energy to a necessary level.
Mathematically, this is represented by:
A(ω)⋅F(ω) >> 1
Since this condition may be met at a frequency different to the final steady state one, the start up
transient occurs at a differing rate. The time until steady state oscillation is reached, will depend
on how much the open loop gain is larger than unity.
2
EXAR Corporation, 48720 Kato Road, Fremont, CA 94538 Tel 510-668-7000 - Fax 510-668-7017 www.exar.com
E
DATA COMMUNICATIONS APPLICATION NOTE
DAN108
4. A Simple CMOS Amplifier
The Inverter is the basic building block of CMOS digital integrated circuits. An inverter is small
and its transfer characteristic is non-linear, as can be seen by the curves in Figure 2.
Vin
Vout
Vout
Vdd
Vdd
Vin
|A|
Vdd
Vin
Figure 2: Inverter Characteristics
The point of maximum gain depends on the transistor characteristics. These can be designed
such that the gain has its maximum near the Vdd/2 point.
3
EXAR Corporation, 48720 Kato Road, Fremont, CA 94538 Tel 510-668-7000 - Fax 510-668-7017 www.exar.com
E
DATA COMMUNICATIONS APPLICATION NOTE
DAN108
By biasing and operating the inverter near the maximum gain point, amplification (with negative
gain) is achieved. A resistor can be connected between the input and the output, as shown in
Figure 3. Since the input impedance of an inverter is very high (mainly capacitive), the inverter
autobiases to: Vin=Vout.
R
Vout
Vdd
Vin=Vout
bias point
Vdd
Vin
Figure 3: Biassing the Inverter
The feedback resistor converts the inverter into an amplifier (Figure 4) with an absolute gain >>1
near the logic switching midpoint.
R
Vin
Vout
Figure 4: Converting an Inverter into an Amplifier
4
EXAR Corporation, 48720 Kato Road, Fremont, CA 94538 Tel 510-668-7000 - Fax 510-668-7017 www.exar.com
E
DATA COMMUNICATIONS APPLICATION NOTE
DAN108
5. Achieving Barkhausen’s Criteria
Satisfying both Barkhausen’s Criteria for Oscillation is not easily achieved when one wants to
design a sinusoidal oscillator with a well-defined frequency of oscillation. Fortunately digital
circuits work off square wave clock, which can be produced from an amplifier whose gain is
high and whose input is overdriven.
An amplifier’s output voltage is limited by the supply voltage – which means that the amplifier’s
gain is not constant. The gain approaches zero as the input sinusoidal signal’s amplitude
increases. This means that the output amplitude of the amplifier/inverter is independent of both
frequency and input amplitude, assuming a high gain amplifier. This makes achieve
Barkhausen’s Amplitude Criteria feasible.
In order to satisfy Barkhausen’s Phase Condition for oscillation, a suitable feedback element,
F(ω), needs to be selected. Since the inverter creates 180° phase delay (within its pass-band), an
additional 180° is needed. This can be achieved with passive R, L, C elements. However
frequency selectivity is limited by the accuracy of the LC components. Enter the piezo-electric
quartz crystal.
6. Quartz Crystals
Electrically, a quartz crystal can be modeled by the equivalent circuit given in Figure 5.
Rs
Cs
L
Cp
Figure 5: Crystal Equivalent Circuit
Cp represents the capacitance of the crystal electrodes plus the holder and the leads. Rs, Cs and L
model the motional parameters of the crystal. The motional inductance, L, represents the
vibrating mass of the crystal. The motional capacitance, Cs, represents the elasticity of the
quartz. Rs represents the bulk losses that occur within the quartz. The relative magnitudes of the
shunt capacitance, Cp, series capacitance, Cs, inductance, L, and series resistance, R, results in a
typical crystal reactance curve shown in Figure 6.
5
EXAR Corporation, 48720 Kato Road, Fremont, CA 94538 Tel 510-668-7000 - Fax 510-668-7017 www.exar.com
E
DATA COMMUNICATIONS APPLICATION NOTE
DAN108
Inductive
Reactance
Parallel
Resonance
Anti
Resonance
Frequency
Fs
Capacitive
Reactance
Series
Resonance
Figure 6: Quartz Reactance Characteristic
At low frequencies, the crystal is capacitive up to the series resonant point, Fs. At Fs, the crystal‘s
impedance is purely resistive – and very small.
Fs =
1
2π L ⋅ C s
Cs = Motional capacitance
L = Motional Inductance
Hence Fs is solely determined by the crystal’s motional parameters.
At frequencies above Fs, its reactance becomes inductive, and the crystal is said to be in parallel
resonance. A crystal can oscillate at higher frequencies (odd overtones) if operation above, say,
30MHz is required.
The temperature dependence of quartz crystals is relatively small even for the inexpensive
consumer (AT cut) parts. The worst case frequency deviation from room temperature nominal
frequency is about ±100 ppm in the loosest specification over its specified temperature range.
6
EXAR Corporation, 48720 Kato Road, Fremont, CA 94538 Tel 510-668-7000 - Fax 510-668-7017 www.exar.com
E
DATA COMMUNICATIONS APPLICATION NOTE
DAN108
7. Crystal Oscillator Circuits
The attraction of a quartz crystal oscillator is its tightly controlled impedance characteristic. A
crystal with a desired series resonant frequency and parallel resonance curve can be
manufactured in mass production. Also, crystals have an extremely high Q factor. For instance a
4 MHz crystal commonly has a Q of about 26000.
By realizing that the impedance of a quartz crystal is solely resistive at Fs, an oscillator as shown
in Figure 7 can be made. Here a second inverter creates the required total 360° phase shift.
R
Figure 7: Series Resonant Oscillator
The oscillation frequency is strongly determined by the crystal, since only at Fs does the crystal
add no phase shift. Since the crystal’s resistance is very small at Fs, the oscillator’s energy may
damage the crystal. Hence special crystals need be selected for series resonance use.
At frequencies slightly higher than Fs, the crystal’s impedance is inductive. Hence inserting the
crystal in a π (pi) configuration with capacitors can achieve the additional 180° phase delay
necessary when used with a single inverter. Figure 8 shows the Parallel Resonant Oscillator.
7
EXAR Corporation, 48720 Kato Road, Fremont, CA 94538 Tel 510-668-7000 - Fax 510-668-7017 www.exar.com
E
DATA COMMUNICATIONS APPLICATION NOTE
DAN108
R
C1
C2
Figure 8: Parallel Resonant Oscillator
Since the capacitors become a frequency-determining element, the sensitivity to its values should
be investigated. The parallel resonant portion of the crystal’s reactance curve (Fig.6) is extremely
steep and short.
Figure 9 shows the dependence of the oscillation frequency on the load capacitance, CL, for a
typical crystal.
CL =
C1 ⋅ C 2
C1 + C 2
700
∆Fs (ppm)
600
500
400
300
200
100
0
10pF
20pF
40pF
60pF
80pF
100pF
CL
Figure 9: Frequency Sensitivity
8
EXAR Corporation, 48720 Kato Road, Fremont, CA 94538 Tel 510-668-7000 - Fax 510-668-7017 www.exar.com
E
DATA COMMUNICATIONS APPLICATION NOTE
DAN108
This validates the fact that:
1) A quartz crystal is an excellent frequency determining element for an oscillator, even when
used in conjunction with inaccurate capacitors.
2) The capacitors allow frequency fine-tuning. A varicap used in a parallel oscillator
configuration turns the circuit into a Voltage Controlled Oscillator, VCXO.
The parallel resonant configuration – also known as the PIERCE oscillator is the one suggested
for EXAR UARTs.
Since crystals can be made to oscillate at higher harmonics, one can limit oscillator‘s bandwidth
by appropriately choosing a feedback resistor. In general, the feedback resistor should have a
relatively high value to keep the input impedance to the inverter (Rin=R/(1-A) high. So, R is
typically chosen to be in the range: 100kΩ<R<5ΜΩ.
8. UART Oscillator Components integrated on chip
As a minimum, the inverter is always integrated on chip. However, depending on the particular
UART, the feedback resistor may or may not be integrated on chip.
8.1 Off-Chip Feedback Resistors
The first generation UARTs (16C450) and its derivatives do not feature integrated feedback
resistors. This includes the ST16C450, ST16C1450, ST16C550, ST16C1550, ST16C580,
ST16C650A, XR16C850, ST16C2450, ST16C2550, ST16C2552, XR16C2850 and XR16C2852.
These have the internal architecture as shown in Figure 10.
UART
Cp1
Cp2
XTAL1
XTAL2
Figure 10 : UART Oscillator Circuit without feedback resistor
9
EXAR Corporation, 48720 Kato Road, Fremont, CA 94538 Tel 510-668-7000 - Fax 510-668-7017 www.exar.com
E
DATA COMMUNICATIONS APPLICATION NOTE
DAN108
Here Cp1 and Cp2 represent the parasitic capacitances associated with the package, pins, bond
wires etc. Each is in the range of 2pF to 5pF in magnitude.
Since the feedback resistor is not integrated on chip, it needs to be added externally to the
UART, between the XTAL1 and XTAL2 pins.
8.2 Integrated Feedback Resistor
All QUARTs as well as all derivatives of the Motorola UARTs have integrated feedback
resistors. This includes the XR68C681, XR88C681, XR68C92, XR68C192, XR88C92,
XR88C192, ST16C454, ST16C554, ST16C654, XR16C854, XR16C864, XR16C872,
XR82C684 which integrate the biasing resistor on chip as shown in Figure 11. Its nominal value
is 300kΩ.
300kΩ
UART
Cp1
Cp2
XTAL1
XTAL2
Figure 11: Integrated Feedback Resistor
Hence only a crystal with two load capacitors need be added, in order to make an oscillator.
9. Required Clock Accuracy
The required accuracy of a UART‘s clock oscillator can be established by understanding the
UART’s receiver sampling mechanism. A UART’s receiver samples the received signal with the
externally applied clock. This has a 16x oversampling rate in order to achieve sampling near the
mid bit-period instant.
10
EXAR Corporation, 48720 Kato Road, Fremont, CA 94538 Tel 510-668-7000 - Fax 510-668-7017 www.exar.com
E
DATA COMMUNICATIONS APPLICATION NOTE
DAN108
(C L-0.5) x T
T
START 1
2
3
4
5
6
7
8
P
STOP
Figure 12: Receiver Mid-Bit Sampling
If the receiver‘s baud rate, B, deviates by ∆B=1/∆T, where T is the nominal bit period of the
transmitter, the START bit will be sampled at ∆T/2 from its nominal mid-bit instant. This
deviation in sampling instant adds up by an additional ∆T every bit period.
Consider a general bit pattern that has one START bit, WL user bits per word (word length), P
parity bits and at least one STOP bit. Hence the total bit count (also called Character Length), CL,
is:
CL = 1 + WL + P + 1
= WL+P+2.
If the first bit (the START bit) is sampled with a deviation of ∆T/2, then the last bit (the STOP
bit) is sampled with (CL-0.5).∆T deviation from its mid point. Figure 13 shows an example of a
long pattern with CL=11.
0.5 ∆T
10.5 ∆T
T
START 1
2
3
4
5
6
7
8
P
STOP
Figure 13: Deviation in Sampling from mid-bit Instant
11
EXAR Corporation, 48720 Kato Road, Fremont, CA 94538 Tel 510-668-7000 - Fax 510-668-7017 www.exar.com
E
DATA COMMUNICATIONS APPLICATION NOTE
DAN108
This deviation may not be larger than half the bit time of the received sequence, or else the
previous or next bits are erroneously sampled, instead of the desired STOP bit.
Thus |(CL-0.5).∆T| < T/2
Hence |∆T|/T < 1/(2.CL-1)
Converting this into Baud Rate terms.
Since B=1/T,
hence dB/dT = -B/T.
Where B is the received signal‘s Baud Rate, and dB is the difference between the receiver’s baud
rate and the received signal’s baud rate. Assuming small deviations, a linear relationship can be
approximated: ∆Β/∆Τ ≈ dB/dT
Substituting: |∆Β|/Β < 1/(2.CL-1)
Equation (1)
Relating this back to the receiving UART’s externally applied clock rate, Fs = 16.n.B.
Where,
n = programmed baud rate divider
= 256DLM+DLL.
DLM, DLL and n are in decimal.
Hence, ∆Fs/Fs = ∆B/B
Substituting this into Equation (1):
| ∆Fs |
1
<
Fs
(2.CL − 1)
For example, an 8 bit word with parity and one STOP bit pattern, as shown in Figure 13, allows
for a maximum deviation between receiving UART’s clock and the transmitting UART’s clock
of 4.76%. The other extreme of a very short character length of 5 bit, no parity, has CL=7. Here
the allowable clock rate deviation is 7.69%.
If the transmitting UART’s clock has the same tolerance as the receiving UART‘s clock, then
both UART’s clocks may not differ from the nominal clock rate by more than half of the
calculated value.
This analysis assumes an ideal, clean transmission channel with no jitter effects, which would
degrade the above analysis.
12
EXAR Corporation, 48720 Kato Road, Fremont, CA 94538 Tel 510-668-7000 - Fax 510-668-7017 www.exar.com
E
DATA COMMUNICATIONS APPLICATION NOTE
DAN108
10. Choosing a Crystal for UART use
When selecting a crystal, the following issues should be considered:
1) Parallel resonant crystals are preferable – series resonant crystals are not suitable.
2) Fundamental Oscillation Mode. Since typical UART applications require clock rates of
between 1 and 25MHz, fundamental mode resonant crystals are usually adequate.
3) Load Capacitance, CL. This is the parallel combination of the capacitors: parasitic and
external – as seen by the crystal:
C1 ⋅ C 2
C1 + C 2
As indicated in the previous section, the required UART frequency accuracy is relatively lax,
and variation in frequency with changing load capacitance is quite low. So capacitor values do
not have to be very accurate. The rule is to use capacitors that conform to the values specified by
the crystal manufacturer.
4) Temperature coefficients. Common crystals have temperature dependence well witin the
requirements for UART usage.
5) Package: A large variety of packages are available.
6) Cost: The most common crystals are cut in the “AT“ plane. These are relatively inexpensive,
but well suited for UART applications.
CL =
11. Design and Debugging Hints
Besides observing the points mentioned in the previous chapter on “Choosing a Crystal“, the
following should be observed for reliable crystal operation.
Some crystal oscillator circuits show the use of a series resistor (about 100Ω) at the inverter’s
output pin. While such a series resistor is needed for series resonant oscillator circuits in order to
protect the crystal from damage due to excessive energy, this is not required in a parallel
oscillating circuit, as suggested in this App Note.
Supply transients can result in:
- a lack of oscillation
- non crystal controlled oscillation (self-oscillation)
- crystal controlled oscillation modulated by self-oscillation frequencies
Hence supply-line bypassing techniques are important in order to ensure that the UART’s higher
frequencies are not within the oscillator loop’s pass band.
13
EXAR Corporation, 48720 Kato Road, Fremont, CA 94538 Tel 510-668-7000 - Fax 510-668-7017 www.exar.com
E
DATA COMMUNICATIONS APPLICATION NOTE
DAN108
Whilst the parasitic capacitances of the UART’s chip and package (typically between 2pF and
5pF) influence the frequency of oscillation, this is so small, that the capacitive effect may be
neglected.
The external components to the UART should be kept as close as possible to the UART to
reduce noise coupling and reduce parasitic inductance.
In order to check the crystal oscillator with an oscilloscope, it is recommended to apply the
oscilloscope’s probe on the XTAL2 pin of the UART’s package. This is the low impedance point
in the feedback loop – which is least disturbed by the oscilloscope’s input impedance. The
waveform will look like a square wave if the crystal oscillates at low frequencies (say less than
5MHz). At higher frequencies the signal will look more like a sinusoid with amplitude limiting,
as the oscillation frequency approaches unity open loop gain of the feedback loop.
The signal at the XTAL1 pin will be sinusoidal, since the feedback elements (capacitors and
crystal) form a high Q band-pass filter. The ‘scope probe may interfere with this signal due to
XTAL1 being a high impedance point.
For debugging purposes, some UARTs (ST16C450, ST16C550, ST16C580, ST16C650A,
XR16C850, XR16C864) have an output clock pin, called BAUDOUT. BAUDOUT’s pulse rate
reflects the programmed baud rate of the UART. It allows non-invasive monitoring.
BAUDOUT’s duty cycle is not necessarily 50%, as shown in the respective data sheets.
12. Application Example
An industrial control system shall employ a XR16C850IQ single channel UART that should
operate with standard Baud Rates (50 Baud to 115.2 kBaud) as well as at quadruple these baud
rates. The terminal that the XR16C850IQ will exchange data with via RS485, is specified to
operate at a baud rates of within 500ppm of the nominal rates. The serial communication link
uses 8bit, even parity with two stop bits protocol. Design a suitable crystal oscillator circuit for
the UART.
The XR16C850 has an additional divider (divide by four) besides the standard 16C550-style
baud rate generator. If this divider is used, the reference clock rate needs to be 7.3728MHz, as
shown in the UART’s data sheet baud rate table.
The maximum allowable tolerance of the UART’s reference frequency for the specified protocol
is 4.7%, as calculated in the example at the end of paragraph 9. Since this tolerance is orders of
magnitude looser than 500ppm, the XR16C850 crystal should operate within 4.7% from nominal
frequency (7.3728MHz). A typical loose frequency tolerance spec for a crystal is 100pm.
14
EXAR Corporation, 48720 Kato Road, Fremont, CA 94538 Tel 510-668-7000 - Fax 510-668-7017 www.exar.com
E
DATA COMMUNICATIONS APPLICATION NOTE
DAN108
Hence, a parallel resonant, fundamental mode, 100ppm, -20°C to +85° temperature range crystal
would suite this application.
For example, VITE Technology makes AT-cut crystals in the industry standard HC-49/U
package. The crystal’s data sheet shows 7.3728MHz to be a standard crystal frequency, in the
VXA1 range of crystals. The data sheet allows selection of load capacitance from 16pF to 30pF.
A 20pF load capacitance is arbitrarily selected here. These parameters make up the VITE part
number: VXA1-1C2-7M3727.
Since the parasitic capacitances C1p and C2p have negligible effect on the frequency, two
standard 39pF capacitors were selected for external connection – the parallel equivalent value of
which is close the desired load capacitance of 20pF.
Finally, the XR16C850 UART needs a large valued feedback resistor external to the UART for
biasing the inverter. A 1MΩ resistor was selected as shown in Figure 14; alternatively, a smaller
one could also have been used.
XR16C850
XTAL1
XTAL2
1ΜΩ
39pF
39pF
Figure 14: Example Design of a XR16C850 Crystal Oscillator
13. References
1) Parzen, Benjamin, Design of Crystal and Other Harmonic Oscillators, John Wiley and Sons,
New York, 1983.
2) EXAR Corporation. XR16C850 Data Sheet. URL: www.exar.com
3) VITE Technology VXA1-1C2-7M3727 Data Sheet, URL: www.viteonline.com
15
EXAR Corporation, 48720 Kato Road, Fremont, CA 94538 Tel 510-668-7000 - Fax 510-668-7017 www.exar.com