The first concept to nail down is
that the PIC can run either on a
primary clock or a secondary clock.
The former accounts for most
situations. In particular, a typical
project contains a single clock
guiding the microcontroller along
and that's the end of the matter. In
more advanced applications, we may
want a secondary clock to kick in
whenever the primary clock is out of
the scene. There are several reasons
for desiring such redundancy, and
we'll explore them in just a bit.
For now, let's focus on the
primary clock which is all we need
for most projects. Refer to Figure 1
which shows what's available. This
tree diagram organizes the types of
primary clocks available within the PIC16F88 in a top-down fashion. To begin, look at the first branches of the
tree diagram. A clock can be an internal RC affair or, if
you prefer, you can supply your own resistor and
capacitor and end up with an external RC arrangement.
For situations that demand more precision, an external
crystal or ceramic resonator can be employed. Lastly, if
you'd like, you can drive the PIC with an existing external
Adding a bit more detail now, the branches of the tree
split again showing the eight individual modes. Each has
an abbreviated name given to it by Microchip. These are
worth learning now to simplify reading the datasheet later
on. Let's scan these specific modes from left to right. The
first is INTRC which stands for internal RC oscillator.
Running at an approximate 31 kHz, this is a low speed
affair built inside the PIC. While that's pretty slow by any
standards, it does have the advantage of being simple and
consuming very little current.
The next mode is INTOSC. Like INTRC this is internal
(requiring no outboard components), but can run at seven
different speeds all the way up to 8 MHz. In some of the
PICs, INTRC and INTOSC are truly independent, but not
so in the PIC16F88 we're examining. For this reason, in
the datasheet the writers sometimes use INTRC to mean
INTRC only and at other times to signify either INTRC or
INTOSC. That only adds to the confusion, so I'm going to
keep the names separate here.
In either of these modes, port line A. 6 can be
configured to follow the clock divided by four if desired.
This is symbolized ϕ/4 — read "phi divided by four." Use
this output if you'd like to synchronize some external gear
to the micro. The datasheet calls this mode INTIO1, if
you're curious. Otherwise, you can optionally free up pin
A. 6 for ordinary digital I/O, referred to as INTIO2 mode.
Moving to the external RC modes, the first is simply
called RC. In this case, an external resistor and capacitor
on pin A. 7 get things going. Assuming a +5V power
supply, the resistor should lie between 3K and 100K, while
the cap should be greater than 20 pF. With the smallest
values, the clock will max out at around 4 MHz. Like we
saw with the internal clocks — if desired — A. 6 can be
caused to follow ϕ/4 (that's RC mode) or else be free for
ordinary use (that's RCIO). Incidentally, the resistor could
be a potentiometer wired as a rheostat which would give
you a variable clock.
Crystals and ceramic resonators are attractive since
they're much more accurate both in the short term and
long term, and also with respect to tolerances and
temperature. There are three modes here. The first, LP —
which stands for low power — is meant to be used with a
32.768 kHz tuning fork type crystal. These pop up
commonly in wristwatches and real time clocks. The
crystal and associated load capacitors connect to pins A. 6
and A. 7. The next mode — called XT — is similar but
meant for use with higher frequency crystals and
resonators up to about 4 MHz. The last mode is HS —
standing for high speed — and is needed for crystals or
resonators cranking above 4 MHz. Just so you know, the
upper limit for the PIC16F88 is 20 MHz. What's neat
about these three modes is that the chip automatically
selects the correct gain of the internal driver to the crystal
based on whether you specify LP, XT, or HS.
The last mode is ECIO which simply lets you pump in
an external clock signal on pin A. 7. This could come from
any sort of clock circuit that puts out square pulses
swinging from ground to the supply voltage.
Peeking ahead just a bit to the experiments, Figure 6
shows the hardware arrangements involved. We'll see how
to stipulate any of these eight modes in just a moment,
but first let's take a look at the secondary clock options.
Figure 2 shows a branching tree diagram for the
available secondary clocks. Recall that any of these can
January 2014 39
Figure 1. The eight modes
for a primary clock.