Technical information
The internal RTC Clock subsystem of the STM32F103 microprocessor is using external 32kHz quartz to provide a stable clock reference signal. As individual quartz components may vary the uC provides a method to adjust deviation by setting divider registers. In Total there are 3 registers called PRLH, PRLL, and RTCCR.
For the purpose of the SD4ST Device the registers above have been simplified, the main reason is that the registers provide the ability to connect external sources with quite a vast variety of frequencies. In our case, RTC submodule is using 32kHz quartz which may have a freq deviation btw 2-5% depending on the quartz provider.
(CPU/hidden) PRLL and PRLH Registers:
The (CPU) PRLH register (16 bit) has a fixed value (0x0000) and never is going to be changed.
The value of the (CPU) PRLL (CPU) register (16 bit) is calculated from M_RTC_PRLL_BASE 0x7F7F and the PRLL_OFFSET (default 0x7C=124dec).
Those registers are not accessible via SD4ST API. PRLL can be changed via PRLL_OFFSET
PRL_OFFSET Register
The default value for SD4ST PRLL_OFFSET reg, is 124 which is very close to the middle of the range 8bit range. This allows symmetrically +/- adjust RTC clock within the range +/- 326.9508 sec/day.
By increasing the value of this register PRLL by one (+1) it slows down the RTC clock by -2.6367 sec/day
Decreasing value by on (-1) we Speed up the RTC clock by +2.6367 sec/day
RTC_CAL Register
This is a 7-bit SD4ST register which is directly mapped to the RTCCR CPU Register of the STM32F103 microprocessor.
Technically this register substracts X amount of RTC cycles on every 2^20 RTC Clock Cycles.
This means that is ‘forgetting X amount of RTC Clock cycles every 32seconds.
This allows for more fine-grained tuning of the RTC Clock.
As the default value of this register is 0 it allows only to slow the clock by increasing the value.
By increasing the value by one (+1) we will slow down RTC Clock by -0.0824 sec/day.
S4T_CAL2.TOS:
Screenshot from utility s4d_cal2.tos:
The utility allows you to change PRLL_OFFSET and RTC_CAL registers.
The values are stored in the Backup Registers of SD4ST and they are sustained by the RTC Battery.
Reference: (Very good article in German): http://cool-web.de/arduino/interne-stm32-echtzeituhr-kalibrieren.htm
(Tip: use google translator).