internal clock driver circuit, to generate the clock. The time constant (product R C) determines the clock period. A variable resistor can be used to give a manually adjustable frequency, although it is not very stable or accurate.
CRYSTAL OSCILLATOR
If greater precision is required, especially if the program uses the hardware timers to make accurate measurements or generate precise output signals, a crystal (XTAL) oscillator is needed. Normally, it is connected across the clock pins with a pair of small capacitors (15 pF) to stabilise the frequency. The crystal acts as a self-contained resonant circuit, where the quartz or ceramic crystal vibrates at a precise frequency when subject to electrical stimulation. The oscillator runs at a set frequency with a typical accuracy of better than 50 parts per million (ppm), which is equivalent to /− 0.005%. A convenient value (used in our examples later) is 4 MHz; this gives an instruction cycle time of 1 µs, making timing calculations a little easier (each instruction takes four clock cycles). This is also the maximum frequency allowed for the XT configuration setting. The PIC 16FXXX series MCUs generally run at a max- imum clock rate of 20 MHz, using a high-speed (HS) crystal which requires the selection of the HS configuration option.
CONFIGURATION SETTINGS
The default setting for the configuration bits is 3FFF, which means that the code protection is off, in-circuit debugging disabled, program write enabled, low-volt- age programming enabled, brown-out reset enabled, power-up timer disabled, watchdog timer enabled and RC oscillator selected. A typical setting for basic development work would enable in-circuit debugging, enable the power-up timer for reliable starting, disable the watchdog timer and use the XT oscillator type.
By default, the watchdog timer is enabled. This produces an automatic reset at regular intervals, which will disrupt normal program operation. Therefore, this option will usually be disabled (bit 2 0). Conversely, it is generally desirable to enable the power-up timer, to minimise the possibility of a faulty start-up.
PIC Instruction Set
Each microcontroller family has its own set of instructions, which carry out essentially the same set of operations, but using different syntax. The PIC uses a minimal set of instructions, which makes it a good choice for learning.
A version of the PIC instruction set organised by functional groups is listed in Table 1.3. It consists of 35 separate instructions, some with alternate result destinations. The default destination for the result of an operation is the file.