Set_OSCCAL
Syntax
Set_OSCCAL
Overview
Calibrate the on-chip oscillator found on some PICmicro™ devices.
Notes
Some devices, such as the PIC12C67x or 16F62x range, have on-chip RC oscillators. These devices contain an oscillator calibration factor in the last location of code space. The on-chip oscillator may be fine-tuned by reading the data from this location and moving it into the OSC- CAL SFR (Special Function Register). The command Set_OSCCAL has been specially created to perform this task automatically each time the program starts: -
Device = 12C671
' Select the device to compile for
Set_OSCCAL
' Set OSCCAL for 1K device 12C671
Add this command near the beginning of the program to perform the setting of OSCCAL.
If a UV erasable (windowed) device has been erased, the value cannot be read from memory. To set the OSCCAL register on an erased part, add the following line near the beginning of the program: -
OSCCAL = $C0
' Set the OSCCAL SFR to $C0
The value $C0 is only an example. The part would need to be read before it is erased to obtain the actual OSCCAL value for that particular device.
Always refer to the device’s data sheet for more information on OSCCAL.