How the 
PIC Chip
Oscillates


Page 30
INDEX

This section covers some of the circuitry required to get the PIC16F84 chip to oscillate. 
There is basically two different oscillators. 
One is made by connecting  resistor and capacitor to the oscillator pin of the chip and the other is made by connecting a crystal to the oscillator pin. 
The first is called an RC (Resistor/Capacitor) oscillator and is the cheapest. It is also not an accurate oscillator, however this is not very important if you are accurately timing an operation. 
If you need to detect input devices such as switches and waveforms and output the result on a set of LEDs or display, any frequency from 100kHz to 4MHz will produce the same results on a display. 
This means the slight change in frequency of an RC oscillator due to temperature fluctuations or supply voltage will not alter the performance of the circuit. 
If you need to detect a particular frequency or create accurate time delays, it will be necessary to use a crystal for the oscillator. 
The best crystal to use is a 4MHz as the microcontroller divides the oscillator frequency by 4 to produce an instruction cycle of 1uS. 
In other words, the micro advances through a program at a rate of one million instructions per second. Each instruction takes 1uS except when a GOTO or CALL is executed. (These take 2uS).
If you use a colour-burst crystal (3.579545MHz) or any other frequency, you will have to work out the time taken for any delay routine you include in your program. 
The PIC16F84 microcontroller will operate from 0Hz (called single-stepping) to 4MHz and you have to know if your project is frequency sensitive or not. 
I cannot provide a set of rules and the easiest thing to do is use a crystal during development and change to an RC network at the end. 
There is a "bit" in the CONFIGURATION file that must be set or turned off (actually there are three bits in the group) to tell the micro to accept an RC network, a crystal of approx 4MHz (called a HIGH-SPEED crystal), a crystal of a lower frequency (say 3.579545MHz, 2MHz or 1MHz) or a watch crystal (38kHz). 
Before "burning" a chip, a small window on the programmer indicates the choice. You can select the type required. 
As the frequency of oscillation is lowered from 4MHz to 38kHz and lower, the current consumption of the chip is dramatically reduced. This may be one feature you need to take into account. 
As the frequency of oscillation is reduced, the execution of the program inside the chip is reduced. 
This means a switch may be looked at more slowly and in the worst case, you may be able to push the switch without the chip recognising the press.
If you are outputting a tone or tune or alarm sounds to a piezo diaphragm to transistor driver to a horn speaker, the frequency cannot be altered after the program has been finalised as the sound(s) will be incorrect. 
There is one other point to remember. 
If more than one 7-segment display is being driven from the chip, it is normal to multi-plex the two displays. This involves turning on one display at a time 

 

NEXT