Recent Changes - Search:

Introduction to Microcontroller Programming

About PICmicro Chips

Clocking Your PICmicro Devices


Flowcode Step By Step

PICmicro Projects


The Clock Circuit

PICmicro microcontroller devices can be clocked in several ways. The methods we are concerned with on this course are principally:

  • Crystal clock
  • RC clock
  • Internal clock

Each of these methods is supported by the PICmicro Multiprogrammer. The following circuit shows how the clock mode switches on the PICmicro Multiprogrammer place different circuits on the OSC1 and OSC2 pins of the PICmicro device.

The oscillator pins on the PICmicro are the OSC1 (Clock in) and OSC2 (Clock out) pins. Internally to the PICmicro device it is possible to connect to the OSC1 and OSC2 pins a selection of different circuits. Each internal circuit will create a clock signal on the oscillator pins when the appropriate external circuit is placed on OSC1 and OSC2. This allows the frequency of oscillation to be determined by the external components.

Switch SW2 dictates whether an RC circuit is connected or a crystal circuit. When SW2 is in the RC position (left on the diagram, RC on the Multiprogrammer board) then the resistor capacitor values determine the speed of oscillation. SW1 dictates the speed of the RC circuit oscillation - it slows oscillation by introducing a far larger capacitor into the RC network.

When SW2 is in the Crystal position (right on the diagram, XTAL on the Multiprogrammer board) then the frequency is determined by the value of the crystal. By default the crystal is shipped with the Multiprogrammer is 19,660,800Hz. (We will come back to this strange number later on.)

For more information please refer to a PICmicro device datasheet.

Why have these modes? The frequency of oscillation is not that important for simple microcontroller applications most of which run at low speeds. However for more sophisticated applications the frequency of oscillation is very important as it dictates how systems communicate with each other. Many electronic systems consist of multiple processors which communicate together using serial communication protocols - for example the RS232 protocol. In serial communication systems the rate of change of 0's and 1's on a line must be agreed by each system before communication can take place: if systems are working at different speeds then communication will be impossible. Communication speed is often referred to as 'bits per second', or the 'Baud' rate of a connection system.

The crystal shipped with your Multiprogrammer is 19.660800MHz. Why such a precise number? The reason is that this frequency can be reduced by a sequence of binary counters to a standard Baud rate which facilitates communication between systems. In this case the fundamental clock frequency divided by two to the power of 10 is 19200. 19200 Baud is an internationally recognised as a standard serial communication rate. Mathematically:

19660800 / 210 = 19200

The RC mode of oscillation is provided partly as a historical legacy, and partly for reasons of economics. Modern PICmicro devices can be set to clock themselves internally without any external components, but this is a relatively new feature to microcontrollers. The RC mode of operation was introduced as a low cost alternative to a crystal clock. A Crystal, and the associated two capacitors required to make the crystal oscillate, is more expensive that a single resistor capacitor network. So the RC network mode of operation was introduced to save electronics manufacturers the expense of a crystal in a design. This technique is fine for applications that are not timing critical.

The RC mode is useful to us because it allows us to clock the PICmicro at a rate of a just few Hertz.

Print - Search - Login

Page last modified on August 19, 2011, at 02:29 PM