Вы находитесь на странице: 1из 4

172 Harvard Road

Waterloo, ON N2J 3V3


CANADA
www.siriusmicro.com

Beginner Project 1
Basic Crystal
Oscillator Circuit
The function of an oscillator
circuit is to provide an accurate and
stable periodic clock signal to a
microcontroller. The frequency of
this clock signal can range from a
few kilohertz to tens of megahertz
and determines how quickly the
microcontroller executes its in-
structions.
Most microcontrollers include This schematic diagram illustrates both the clock oscillator and reset circuits.
a clock driver circuit which is de-
signed to drive a quartz crystal into The clock circuit consists of When the capacitance of C1 or
oscillation. The clock driver cir- capacitors C1 and C2, a quartz C2 is shown as a range of values,
cuitry built into the PICmicro fam- crystal or ceramic resonator Y1, select a higher capacitance for
ily is very flexible and allows for and a series resistor, R3. The val- lower frequencies of operation, and
four different clocking options: ues of capacitors C1 and C2 is de- a lower capacitance for higher
clock signal supplied from another termined by both the clock speed clock frequencies. For example,
oscillator, an R-C clock (based on at which you intend to run the when using the XT oscillator mode
a resistor-capacitor charging time PICmicro, and by the selection of with a 100 kHz quartz crystal, se-
constant), a ceramic resonator, or a quartz crystal or a ceramic reso- lect a value of C1 close to 30 pF
a crystal oscillator. nator as the clock source. Use the and a value of C2 close to 300 pF
An R-C clock circuit is the sim- table as a guide to select the ap- for the best performance.
plest but does not provide accurate propriate capacitors.
timing since both resistor and ca-
pacitor values can vary greatly with Oscillator Type Frequency Range C1 C2
temperature. Crystal oscillator and
XT - Resonator 1 - 4 MHz 20-330 pF 20-330 pF
ceramic resonator-based clock cir-
cuits provide the most stable and HS - Resonator 8 MHz 20-200 pF 20-200 pF
accurate timebases, and require LP - Crystal 32 - 200 kHz 15 pF 15 pF
only a few extra parts than a sim-
XT - Crystal 100 kHz - 1 MHz 15-30 pF 15-300pF
ple R-C oscillator (see the sche-
matic diagram, above). HS - Crystal 2 - 20 MHz 15 pF 15 pF
LP is low power mode, XT is a regular oscillator, and HS is high speed mode.

©1999 Sirius microSystems Basic Oscillator and Reset Circuit 1


Series resistor R3 is required Both quartz crystals and ce- commonly set by the downloading
for some types of crystals in HS or ramic resonators are non-polarized software, but some assemblers al-
XT mode. Including R3 with crys- electronic devices and can be in- low you to specify the oscillator
tals that do not require a series re- stalled in the oscillator circuit in ei- type in your source code. Make
sistor will not degrade the perform- ther orientation. sure that you know how to select
ance of the oscillator circuit. A low Lastly, the type of resistor and the oscillator before programming
value of resistance, up to a few hun- capacitors chosen for the circuit are your microcontroller.
dred ohms, will keep the clock not critical. Any ceramic or mono-
driver circuit in the PICmicro from lithic capacitor of the suggested
overdriving the crystal. value should work, as should any The Reset Circuit
typical ¼ watt metal or carbon film
A real reset circuit is not nec-
resistor.
essary in order for a PICmicro to
Selecting the Components
function in a circuit. The only com-
Building the Oscillator
ponent required to run a PICmicro,
A few general precautions other than those parts that make up
should be observed when building the oscillator circuit, is a pull-up
the oscillator circuit. Since the resistor connected to the MCLR/
clock oscillator is typically the Vpp pin. In the schematic diagram,
source of the fastest signals, and R2 functions as the pullup resistor.
potentially, the major source of RF If you omit the pull-up resistor,
emissions in a circuit, good design your PICmicro will remain in re-
practice dictates that all clock cir- set (clear) mode on power-up, and
cuit signal lengths should be kept will not execute its program.
A typical crystal (left) and resonator. as short as possible. A good, low Resistor R1 and pushbutton
impedance ground return wire from switch S1 make up an actual reset
Quartz crystals and ceramic capacitors C1 and C2 to the circuit circuit. When S1 is pressed, it com-
resonators are similar, but have ground is also necessary. pletes a low impedance connection
some physical differences. As Some PICmicros, like the from the MCLR/Vpp pin to
shown in the diagram, quartz crys- PIC16C711, use the pins adjacent ground, forcing the PICmicro into
tals are typically mounted in a to the clock oscillator circuit as reset (clear) mode. Resistor R1 is
hermetically sealed metal case with analog inputs. For accurate analog- optional, and is used to limit the
two wire leads protruding from the to-digital conversion it is especially current on the MCLR/Vpp pin to
bottom. Sometimes crystals may important to minimize the length prevent a condition called latch-
have a third ground lead soldered of any clock oscillator signal wires up—in which the input circuit of a
or welded to the top of the metal running in parallel with the analog CMOS chip can become ‘stuck’.
can. Grounding the pin on the metal input lines. Ideally, separate the Electrostatic discard (ESD) from a
can helps to both stabilize the crys- analog signal lines from any dig- person touching the reset switch
tal, lessening the impact of me- ital signals by using a ground wire could potentially cause latch-up.
chanical shock, as well as reduces as a shield between all analog and S1 is not two pushbutton
RF emissions. digital wiring. switches as the schematic seems to
Select a quartz crystal speci- indicate. We use a small pcb-
fied as a microprocessor crystal, mounted pushbutton switch with
rather than a tuning crystal for a Programming the Clock four legs in our circuits—that’s
radio. Typically, these are stocked why the one in the schematic is
Before you download your
in common frequencies by most shown with four circles attached to
program into a PICmicro, you must
large electronic distributors. wires.
select the appropriate clock oscil-
Ceramic resonators are usually There is one last part in the
lator fuse settings. These settings
produced in the form of molded or basic oscillator and reset circuit.
tell the PICmicro which of the four
dipped parts with two or three wire Capacitor C3 is a decoupling ca-
clock oscillator options to use. The
leads. The center wire, if present, pacitor which forms part of the
oscillator fuse settings are most
connects to the circuit ground. power supply circuit.

2 Beginner Project 1 ©1999 Sirius microSystems


The Power Supply output voltage (5V) and the input Project Summary
voltage is converted to heat. The
An electronic circuit is only as This project sheet has exam-
higher the input voltage, the hotter
stable as its power supply. Capaci- ined the components necessary to
U2 will get. You may need to add a
tor C3 is a decoupling capacitor support a PICmicro in a simple mi-
heat sink to U2 if you have a high
which is used to reduce ringing and crocontroller circuit. Start with the
input voltage, or a high output cur-
ground-bounce on the power sup- clock oscillator design by deter-
rent.
ply lines. In other words, C3 works mining the clock speed at which to
Capacitors C5 and C6 are in-
to clean up any voltage fluctuations run the PICmicro. The clock speed
put and output filter capacitors for
at the power supply pins of the PIC- you choose may depend on the re-
the voltage regulator. C5 may not
micro. To be most effective, it is quirements of your application.
be necessary if a battery is used to
important to mount C3 as close to Use the chart on the first page to
power the circuit, and as long as
the PICmicro power supply pin select the components for the clock
the battery wires are kept short. Ca-
(Vdd) as possible. oscillator circuit. Next, determine
pacitor C6 is important as an out-
The schematic diagram on the if your circuit needs user reset ca-
put filter capacitor for the regula-
last page of this project sheet shows pability. If not, simply use a pull-
tor.
a simple regulator circuit that will up resistor on the MCLR pin to get
If you wish to add other circuits
produce a five volt output from any the PICmicro going when power is
to the voltage regulator, try to run
input voltage between approxi- applied. Otherwise, add the reset
a separate set of wires from your
mately eight and twenty volts (it’s pushbutton to the MCLR line. Last,
new circuit back to the +5V and
shown with a 9V source attached). make sure that your project has a
ground common connections at C6.
U2 is a 7805 three-terminal regulated five volt DC source for
Remember to add a small
voltage regulator IC. It works by trouble-free operation. Once you
decoupling capacitor, like C3,
actively maintaining a five volt out- put all of the parts together, you’ll
across the power supply leads of
put independent of the output cur- have a basic PICmicro circuit ready
any active ICs in the circuits that
rent. The difference between the to program.
you add.

Notes:

©1999 Sirius microSystems Basic Oscillator and Reset Circuit 3


4 Beginner Project 1 ©1999 Sirius microSystems

Вам также может понравиться