Spark Logic

Diagnose an STM32F103 hardware RTC that does not tick

Find failures in the STM32F103 RTC clock, backup-domain configuration and synchronization.

Check the selected clock source

Verify that the RTC clock is enabled and that the source selected in RCC_BDCR is running. For LSE, look for LSERDY with a bounded timeout. Check if the board actually carries a 32.768 kHz crystal on PC14 and PC15. When a board has no crystal, an LSI test can help isolate the RTC from the LSE hardware. Its frequency tolerance differs from LSE.

Check if the code enables the power and backup peripheral clocks and permits writes to the backup domain before selecting the clock. Changing the RTC clock source can require a backup-domain reset, which clears the retained RTC configuration and backup registers.

Separate register access from counter operation

Follow RM0008 for RTC synchronization and wait for the documented completion flags before reading or writing. If sync never completes, inspect the source ready bit and clock selection before extending the timeout. With the clock working, read the counter twice more than a second apart and verify that the prescaler matches the expected clock.

If the clock loses time only when the main supply is removed, verify VBAT at the MCU as well as the chosen oscillator's backup power support. For initialization problems in a sketch, start from one known core and RTC library version.

References