9.2.20 __osccal_val Inbuilt
A builtin function that returns the internal oscillator calibration constant.
Include
<xc.h>
Prototype
unsigned char __osccal_val(void);
Remarks
This is a builtin function that is expanded to a label associated with
address of the retlw
instruction that encapsulates the oscillator
configuration value. Calls to the function will return the device’s oscillator
configuration value, which can then be used in any expression, if required.
This function is only available for those devices that are shipped with such a value stored in program memory. It is automatically called by the runtime start-up code when required (unless you have explicitly disabled this option, see Section 3.7.1.14 “osccal”) and you do not need to explicitly call it to calibrate the internal oscillator.
Example
#include <xc.h>
int main(void)
{
OSCCAL = __osccal_val();
}