RTCC Calibration

The RTCC module can be calibrated using the periodic auto-adjust feature and can provide the user with an error of less than three seconds per month, when calibrated correctly. The first step to calibrating the input clock source is to determine the error of the input clock frequency, which can be done using another timer resource available on the PIC® microcontroller such as the Signal Measurement Timer (SMT) module. The calculated error in the RTCC module source clock should be stored in the calibration register (RTCCAL) as a signed 8-bit value. The value stored in this register determines the auto adjustment that must be made to the RTCC clock source to calibrate it to the ideal frequency expected. Equation 1-1 below, from the RTCC section of the product data sheets, can be used to determine the error between the ideal expected frequency and the actual measured frequency. For more information about calibrating the RTCC and the SOSC, refer to the device data sheet.

Figure 1. Converting RTCC Source Clock Error Clock Pulses of SCK Output Signal Calculation

ErrorClocksMinute=(IdealFrequency(32,768)MeasuredFrequency)60

In the event where the measured frequency is faster than ideal (Equation 1-1 yields a negative result), the value stored in the RTCCAL register must be negative. When the measured frequency is slower than ideal (Equation 1-1 yields a positive result), the value stored in the RTCCAL register must be positive. Although the calibration value stored in RTCCAL from Equation 1-1 is specified in clock pulses per minute, the actual calibration is performed by applying RTCCAL<7:0>/4 clock pulses every 15 seconds. Any initial error from the clock source is not included in the calculation of Equation 1-1 and the user must consider that when calibrating the RTCC module. It is important to note that any writes to the RTCCAL register should only occur when the timer is turned off or right after the rising edge of the seconds pulse. The only exception to this is when the SECONDS value is 00 ,15 ,30, or 45 to avoid being manipulated by an auto-adjust events occurring.