take over duties from the primary clock under certain
circumstances. The datasheet likes to group these into the
categories RC_RUN and SEC_RUN, but both indicate
There are two choices for RC_RUN. Either the INTRC
or INTOSC internal clocks described earlier can be used;
the only difference really being the rate of oscillation.
Or, if desired, you can attach the 32.768 kHz crystal
and load capacitors to B. 6 and B. 7. What’s so cool about
this is that the watch crystal always runs — even when you
put the chip into what's known as sleep mode. This mode
— designated T1OSC — is ideal for real time clock
applications. (Normally, the PIC will shut down unused
clocks when going to sleep).
Observe that primary clocks use A. 6 and A. 7 in
various combinations, but secondary clocks do not — at
least for the PIC16F88. The schematic in Figure 7 (for one
of the experiments coming up) shows what's involved.
With that, we've concluded our overview of the
primary and secondary clocks. Why not take a few
moments to study Figures 1 and 2 once more to really fix
the distinctions and details in your mind before
How to Make
So, you've decided what kind of clock you want. Now,
how do you express your wishes to the PIC? The answer
lies in the configuration bits and three special registers.
The configuration bits are set during the burning (Flashing
or programming) phase, while the register bits are
accessible during runtime. Here's the scoop.
Figure 3 illustrates the two sets of configuration bits
within the PIC16F88. (Simpler PICs only have one set.)
Yes, there's a lot here, but when it comes to setting up the
clock only a handful need concern us. For example, the
three bits labeled FOSC designate the primary oscillator as
described earlier. In other words, these establish the
default behavior on power-up.
In the second set of configuration bits, you'll find two
that govern what will happen when you switch over from
the primary to secondary clocks, or vice-versa. We'll save
that for the next section.
Once a program is running, you can manipulate the
clock (or clocks) in various ways by modifying the
registers OSCON, OSCTUNE, and T1CON. These are
shown in Figure 4. Let's ponder the details.
Perhaps the most important bits in OSCON are the
ones labeled IRCF, which stands for internal RC oscillator
frequency. As the name suggests, these bits select the
desired clock rate of the internal oscillator(s). Next up are
the two bits labeled SCS, denoting system clock select.
Here, you can choose to use the primary or secondary
clocks. It's no big surprise that the register OSCTUNE lets
you fine-tune the INTRC or INTOSC clock frequency. (On
Figure 3. Configuration bits are set
when the PIC is burned.
modes for a
40 January 2014