How do I read the OSCCAL value for my PIC® device?
At runtime, this calibration value can be read using the macro _READ_OSCCAL_DATA(). To be able to use this macro, make sure that <xc.h> is included in the relevant modules of your program. This macro returns the calibration constant which can then be stored in the OSCCAL register, as follows: