In order to enable the microcontroller to operate properly it is necessary to provide:
Reset signal; and
As can be seen in figure above, it’s about simple circuits. But it’s not always the case. If the target device is used to control expensive machines or life-support devices, everything gets increasingly complicated. Anyway, this simple solution will do for the time being...
Even though the PIC16F887 can operate at different power supply voltages, why test ‘Murphy’s law’?! A 5V DC power supply voltage is the most suitable. The circuit, shown on the previous page, uses a cheap integrated three-terminal positive regulator LM7805 and provides a highquality voltage stability and quite enough current to enable the microcontroller and peripheral modules to operate normally (enough means 1A).
In order for the microcontroller to operate properly, a logic one (VCC) must be applied on the reset pin. A push button connecting the MCLR reset pin to GND is not necessary, but is almost always provided as it enables the microcontroller to recover fast if something goes wrong. By pressing this button, the MCLR pin is supplied with 0V, the microcontroller reset occurs and the program execution starts from the beginning. A 10K resistor is used to prevent shortening the 5V DC rail to earth from occuring when the RESET button is pressed.
Even though the microcontroller has a built-in oscillator, it cannot operate without external components which make its operation stable and determine its operating frequency. Depending on components in use and their operating 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.
What’s the point of using these modes? Owing to the fact that it is almost impossible to design an oscillator to operate stably over a wide frequency range, the microcontroller must be familiar with the type of quartz crystal connected so that it can adjust the operation of its clock oscillator to it. This is why all the programs used for programming microcontrollers contain an option for oscillator mode selection. See figure on the left.
When the quartz crystal is used for frequency stabilization, the 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 quartz crystal casing.
In addition to the crystal, capacitors C1 and C2 must also be connected as per schematic above. Their capacitance is not of great importance. Therefore, the values provided in the table next to the schematic should be considered as a recommendation, not as a strict rule.
A ceramic resonator is cheaper, but very similar to quartz by its function and operating mode. This is why these two schematics, illustrating their connection to the microcontroller, are identical. However, compared to the quartz crystal, the capacitance of capacitors C1 and C2 is slightly different due to different electric features. Refer to table below.
Ceramic resonators are usually connected to oscillators when it is not necessary to provide extremely precise frequency.
If the operating frequency doesn’t matter then there is no need to use additional expensive components for its stabilization. Instead, a simple RC network, as shown in figure below, should be used. In this case only the input of the microcontroller’s clock oscillator is used, which means that the clock signal with the Fosc/4 frequency will appear on the OSC2 pin. This frequency is the same as the operating frequency of the microcontroller, i.e. represents 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 configurations, a clock signal may be generated by an external oscillator. Refer to figure below.