There are many types of oscillator circuits that could be implementd from the simple resistor capacitor network to the low speed crystal, high speed crystal, ceramic resonators and then the more recent feature of an internal oscillator.
Whether it is better to use the internal vs an external resonator relies on a few items to consider.
- Is the application frequency dependant ie are you using the clock cycle as the time base
- Can the software compensate for the fluctuations in the environment or not
- Can the exclision of the crystal be an effective cost saving technique
If for example your PIC is being used to build a real time clock, then the crystal selection is imperative and a normal 4 MHZ crystal does not work for accuracy without compensation. However if a 3.27 MHZ crsytal is used, this enables you to build up an accurate 1 second pulse. You could compensate for the fluctuations in software using other crystals but hey, why when you can use a physical element in your design to make life simple and reliable.
The selection of frequencies from the internal oscillator is also limited to 4MHZ, 8 MHZ and so on depending on the device. If you neded a specific machine cycle frequency then you would have to decide based on accuracy, timed reliability or whether you can let that slide since a slight fluctuation would not make much difference.
A machine cycle is Crystal Clock Cycle / 4 ie 4 MHZ / 4 = 1 MHZ or 1 us / machine cycle / instruction.
Crystal oscillation can be affected by the environment, as a result an internal crystal’s oscillation would change when the ambient temperature changed. Some devices do have temperature compensation to get around this. But for time sensitive applications, choosing the right crystal is necessary.
The external crystal is more reliable and is not affected directly by for example the PIC heating up owing to the operational load stress it is under.
Internal Crystal as cost saving
An internal crystal can be used as a cost saving for two reasons:
- The PCB realestate no longer needs to accomodate the crystal cct, which includes the two stabilising capacitors.
- The cost of a) crystal and capacitors b) soldering and placement is eliminated
There is no actual change or difference when producing the software when an internal oscillator is chosen. A change comes in when the hex file is compiled and the configuration settings are set to use the internal oscillator instead of an external one.
Internal oscillators are best used for non time dependant applications or where the application can benefit from the cost saving.