Microcontroller Clock Options
Copyright 2000 G. Shearer
There are several basic methods to provide a clock
for the microcontroller. The microcontroller has an internal oscillator and
two pins are provided on the 16F84 (pins 15 & 16) to connect the frequency
standard for the clock. 16F84 microcontrollers are available in either DC
4 MHz and DC 10 MHz versions. The chip number has either a
/04 or /10 suffix. The 16F84A version is capable of operation from DC to
20 MHz, however this version is not readily available at this time. The Scenix
SX-18 and SX-28 microcontrollers boast of DC to 50 MHz clock rates and there
is a 75 MHz enhanced version of each as well.
The cost difference between the units is small and with small quantities, it would probably be better to buy the highest clock frequency version that is available. For large quantities, it would be prudent to select the lowest clock frequency that comfortably meets the application requirements as the cost savings increase with quantity. The frequency specifications are only the manufacturers guarantee. I am aware of experiments of overclocking (operating the microcontroller at a higher than specified rate) microcontrollers with acceptable results. This would be a good subject for experimentation although you might want to consider using an SX-18 or SX-28 if you need the higher clock frequencies as they can handle the higher clock rates.
The least accurate method would be a RC (resistor capacitor) network connected to pin 15. The RC mode can be used when timing is not a critical concern such as when two inputs are high, the desired output goes high. The time constant of the RC network determines the frequency, where
t = R * C
and
f=1 / T
t = time in Seconds
R = resistance in Ohms
C = capacitance in Farads
f = frequency in Hertz
It is recommended that if you do plan to use the RC frequency standard method, the resistor values should remain between 5 K and 100 K. Resistances <= 2.2k may cause the oscillator to become unstable or stop altogether. Extremely high resistances such as 1 Meg can cause the oscillator to become overly sensitive to noise, humidity and leakage. Using a capacitor value of approximately 20 pF would give a large working range and still allow you to remain within the 5 to 100K resistance range. The PIC microcontroller operates over such a wide voltage range that oscillator parameters may present the limiting factor in microcontroller operation.
Inexpensive resistors and capacitors do not have tolerances capable of providing an accurate clock frequency which is good enough for measuring time, transmitting or receiving serial information and other time measurement or time critical applications. Standard ¼ watt resistors commonly have a tolerance of 1% and ceramic capacitors would have a tolerance of approximately 5%. RC components having a sufficient tolerance for serial communications would be considerably more expensive than the other options available as a good frequency standard.
Quartz crystals have an extremely high tolerance, which is measured, in parts per million (PPM). Quartz crystals cost a little more, however, provide the highest accuracy. Along with the crystal, two phase shift capacitors of approximately 22 pF will be required (see the listing below). I recommend using monolithic ceramic capacitors for this job, as they are much smaller and more stable than the common ceramic disk version. If you were building a digital clock or capacitance meter, a quartz crystal would be the component of choice.
Microchip recommends the following capacitor values for crystal oscillators. Higher capacitance will increase the stability of the oscillator but will also increase the start-up time. The JAL target chip library will set the mode fuse properly for the selected frequency. Do, however, remember that selecting a frequency other than 4 MHz or 10 MHz when using a 16F84 will cause timing and delay problems as JAL calculates these values based on standard clock frequencies. 50 MHz is the standard for both the SX-18 and SX-28 microcontrollers. 10 and 20 MHz are the selections available for the 16F877. Libraries for other standard frequencies and microcontrollers may be available in the future.
Mode | Frequency | Capacitance |
LP |
23 kHz |
68 100 pF |
LP |
200 kHz |
15 33 pF |
XT |
100 kHz |
100 150 pF |
XT |
2 MHz |
15 33 pF |
XT |
4 MHz |
15 33 pF |
HS |
4 MHz |
15 33 pF |
HS |
10 MHz |
15 33 pF |
Two conditions must be met for oscillation to occur. The phase shift must be zero or 360 degrees at the desired frequency and the oscillator system gain must be greater than unity at that frequency. A series resistor is often used to adjust the loop gain. The lower limit of the loop gain is used to account for variations caused by temperature and voltage. The upper limit is where the oscillator would operate in a spurious mode. Some crystals or ceramic resonators could be damaged with too high an open loop gain (drive level). It may be necessary to use a series resistor limit the drive in some cases. This resistor value is best obtained by experimentation. Select the value at which the oscillator just runs at the lowest possible operating voltage that your project will require the microcontroller to operate. This would be the upper limit. The lower limit may be 0 Ohms for less fragile crystal units. If it is necessary to use a drive limiting resistor, it should be connected between the OSC2 terminal of the microcontroller and the crystal.
The third and in my opinion the best option for general use would be a ceramic resonator. Tolerance for a ceramic resonator is approximately 0.5%, which is more than adequate for all but the most critical time measurement applications. Remember also that dividing the clock frequency also divides the tolerance at the same time. Ceramic resonators also require capacitors like quartz crystals. For all intents and purposes, the microcontroller does not know the difference between a ceramic resonator and a quartz crystal. Better yet, there are versions of ceramic resonators available, which have built in capacitors and cost only pennies more than the version without capacitors. Best of all, either version costs less than one dollar.
The following is a list of ceramic resonators that I have used in the experiments I have conducted. Note the 20 MHz resonators are for use with the 16F877 Microcontroller.
Frequency |
Manufacturer |
Part Number |
W W/O Capacitors |
4 MHz |
Murata Erie |
CSA4.00MG |
W/O |
4 MHz |
Panasonic |
EFO-MN4004A4 |
W/O |
4 MHz |
Panasonic |
EFO-MC4004A4 |
W |
10 MHz |
Murata Erie |
CSA10.00MG |
W/O |
10 MHz |
Panasonic |
EFO-MN1005B4 |
W/O |
10 MHz |
Panasonic |
EFO-MC1005B4 |
W |
10 MHz |
ECS, Inc |
ZTA-10.00MT |
W/O |
10 MHz |
ECS, Inc |
ZTT-10.00MT |
W |
20 MHz |
ECS, Inc. |
ZTA-20.00MX011 |
W/O |
20 MHz |
ECS, Inc. |
ZTT-20.00MT |
W |
For ceramic resonators without capacitors, I have been successful using 22 pF for both 4 and 10 MHz resonators. Microchip recommends 15 33 pF and setting the mode fuse to XT for 4 MHz and HS for 10 MHz resonators. All of the resonators listed above are +- 0.5%.
This page will soon merge with /techref/microchip/osc.htm
See:
Questions:
Comments:
Interested:
file: /Techref/piclist/jal/MicrocontrollerClockOptions.htm, 15KB, , updated: 2007/5/16 07:24, local time: 2024/12/22 04:51,
3.133.149.244:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://sxlist.com/techref/piclist/jal/MicrocontrollerClockOptions.htm"> Microcontroller Clock Options</A> |
Did you find what you needed? |
Welcome to sxlist.com!sales, advertizing, & kind contributors just like you! Please don't rip/copy (here's why Copies of the site on CD are available at minimal cost. |
Welcome to sxlist.com! |
.