In order to enable the microcontroller to operate properly it is necessary to provide:
- Power Supply;
- Reset Signal; and
- Clock Signal.
As seen in figure above, it is about simple circuits, but it does not have to be always like that. If the target device is used for controlling expensive machines or life-support devices, everything gets increasingly complicated! However, this solution is sufficient for the time being…
Even though the PIC16F887 can operate at different supply voltages, why to test ‘Murphy’s low’?! A 5V DC power supply is the most suitable. The circuit, shown on the previous page, uses a cheap integrated three-terminal positive regulator LM7805 and provides high-quality voltage stability and quite enough current to enable the microcontroller and peripheral electronics to operate normally (enough here means 1A).
In order that the microcontroller can operate properly, a logic one (VCC) must be applied on the reset pin. The push button connecting the reset pin MCLR to GND is not necessary. However, it is almost always provided because it enables the microcontroller to return safely to normal operating conditions if something goes wrong. By pushing this button, 0V is brought to the pin, the microcontroller is reset and the program execution starts from the beginning. A10K resistor is used to allow 0V to be applied to the MCLR pin, via the push button, without shorting the 5VDCrail to earth.
Even though the microcontroller has a built-in oscillator, it cannot operate without external components which stabilize its operation and determine its frequency (operating speed of the microcontroller). Depending on elements in use as well as their frequencies, the oscillator can be run in four different modes:
- LP – Low Power Crystal;
- XT – Crystal / Resonator;
- HS – High speed Crystal / Resonator; and
- RC – Resistor / Capacitor.
Why are these modes so important? Owing to the fact that it is almost impossible to make a stable oscillator which operates over a wide frequency range, the microcontroller must know which crystal is connected so that it can adjust the operation of its internal electronics to it. This is why all programs used for chip loading contain an option for oscillator mode selection. See figure on the left.
When the quartz crystal is used for frequency stabilization, a built-in oscillator operates at a precise frequency which is not affected by changes in temperature and power supply voltage. This frequency is usually labeled on the crysal casing.
Apart from the crystal, capacitors C1 and C2 must also be connected as per schematic below. Their capacitance is not of great importance. Therefore, the values provided in the table below should be considered as a recommendation, not as a strict rule.
Ceramic resonator is cheaper, but very similar to quartz by its function and the way of operation. This is why schematics illustrating their connection to the microcontroller are identical. However, the capacitor value is slightly different due to different electric features. Refer to the table below.
Such resonators are usually connected to oscillators when it is not necessary to provide extremely precise frequency.
If the operating frequency is not of importance then there is no need to use additional expensive components for stabilization. Instead, a simple RC network, as shown in figure below, is sufficient. Since only the input of the local oscillator is used here, the clock signal with the Fosc/4 frequency will appear on the OSC2 pin. This frequency also represents the operating frequency of the microcontroller, i.e. the speed of instruction execution.
If it is required to synchronize the operation of several microcontrollers or if for some reason it is not possible to use any of the previous schematics, a clock signal may be generated by an external oscillator. Refer to figure below.
Regardless of the fact that the microcontroller is a product of modern technology, it is of no use if not connected to additional components. Simply put, the appearance of voltage on the microcontroller pins means nothing if not used for performing certain operations such as to turn something on/off, shift, display etc.