Specialist Supplier of Crystals & Frequency Control Componentssales@mecxtal.com.cn0755-26500570
MERLIN home / Rednote / Low-Frequency Timing and System Power

Why does the STM32F407 RTC keep its old clock after a firmware update enables an external crystal?

The original device keeps time from an internal low-speed clock. The second hardware revision adds a 32.768 kHz crystal. After installing firmware that enables the external oscillator, the crystal starts, but the calendar behaves as before. On the STM32F407, read RTCSEL in the backup domain as well as the external oscillator’s ready flag. Changing the RTC clock source after its first selection requires a backup-domain reset.

Test an existing unit with retained time separately from a blank board

Prepare two boards of the same revision. Initialize one from a blank state. Run the old firmware on the other while maintaining backup power. Install the same new firmware on both and read back RTCSEL and the external oscillator’s ready flag. If only the board with retained state fails to switch, this explains why upgrades in the field behave differently from new lab samples.

Before implementing the migration, inventory everything the backup domain retains, especially the calendar, alarms, and application flags in backup registers. Note which sources can supply trustworthy values. A backup-domain reset affects that state. On the prototype, copy data that must be preserved, confirm the external crystal meets startup conditions, then select the source and reinitialize according to the manual. Restore trusted time as specified by the project. Plan for power loss during migration and for units that have not yet obtained trusted time.

For acceptance, retain readings for first power-on, a firmware upgrade with the battery retained, and the restart after the upgrade. Subsequent boots should preserve the backup domain once the target source is selected. Separate the assembly check that the watch crystal is fitted from the functional check that the RTC uses it. One successful power-on observation does not cover all upgrades.ST RM0090 reference manual

Send us a part number or your requirements

Brand, frequency, quantity and delivery target — a useful place to start.

WeChat

MERLIN · TIMING COMPONENTS

Scan with WeChat to contact Sales

Add our WeCom contacts from your usual WeChat app.

On desktop, scan with your phone. On mobile, save the QR image and select it from your album in WeChat Scan.