STM32 gotchas
306. Jitter of 512Hz RTC calibration signal

The STM32 RTC provides a means to output a 512Hz signal from the RTC, to facilitate its calibration. Some users which wanted to adjust the RTC, observed, that this signal is jittery or even outright unstable.

One source of jitter is the peculiar way how the asynchronous divider in RTC generates the 512Hz signal. For whatever reason, it's not a plain divider and its output signal duty is not exactly 50%. As a result, the falling edges are not exactly the same period apart; however, the rising edges are, and there should be no jitter when measuring period between rising edges of the 512Hz signal. This is in fact also documented in the RM. (Also note, that the 512Hz output is valid only for the default setting of asynchronous divider to 0x7F; this too is documented).

There is another possible source of jitter: many STM32 (probably all with RTCv2) have an erratum, that there is a coupling between the LSE oscillator and PC13 pin, and signals at PC13 destabilize the LSE. As it happens, PC13 is the default output for the 512Hz calibration signal. In some STM32, this calibration signal can be redirected to other pins and users are reporting, that such redirection appears to be a good solution to instability coming from this erratum. Another option may be to output LSE to MCO pin, or to use the internal RTC-clock-to-TIMx connection together with some precise external clock signal fed to the same timer, to compare them and adjust RTC accordingly.

We have observed both these effects experimentally in g300.