19.5.2 Main RC Oscillator Frequency Adjustment
The user can adjust the value of the Main RC oscillator frequency by modifying the trimming values set in production by Microchip. This may be used to compensate frequency drifts due to temperature or voltage. The values stored in the Flash cannot be erased by a Flash erase command or by the ERASE pin. Values written by the user application in the Oscillator Calibration register (PMC_OCR) are reset after each power-up or peripheral reset.
By default, PMC_OCR.SEL12 is cleared, so the Main RC oscillator is driven with the factory-defined calibration bits which are programmed during chip production.
In order to adjust the oscillator frequency, PMC_OCR.SEL12 must be set to ‘1’ and a valid value must be configured in PMC_OCR.CAL12.
It is possible to adjust the oscillator frequency while operating from this oscillator.
When reading PMC_OCR, CAL12 contains the value of the trimming that is currently sent to the Main RC oscillator. This means that the read value is either the factory-defined value (PMC_OCR.SEL12=’0’) or the value written in the register by the user (PMC_OCR.SEL12=’1’).
At any time, the user can measure the main RC oscillator output frequency by means of the Main Frequency Counter (refer to Main Frequency Counter). Once the frequency measurement is done, the main RC oscillator calibration field CAL12 can be adjusted accordingly to correct this oscillator output frequency.
