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

STM32F407 changes from an 8 MHz to a 25 MHz crystal. Why does RTC timing need separate work after fixing the CPU clock?

If STM32F407 uses HSE for the RTC reference, updating the main PLL does not automatically fix calendar timing. The RTC has a dedicated HSE divider. An old divide-by-8 gives 1 MHz from 8 MHz. Keeping it with 25 MHz calculates to 3.125 MHz, not the 1 MHz RTC scheme described in the manual. Check whether the calendar actually uses HSE or LSE, then verify both clock trees and the calendar prescalers.

1. Separate CPU clock, RTC input, and the one-second tick

The main PLL can supply the CPU and buses. An RTC using HSE takes its reference through a dedicated divider, so it does not inherit the corrected CPU frequency. The calendar has asynchronous and synchronous prescalers to produce its tick. One clock readout cannot establish that the other branches are correct.

ItemExpected check
Original 8 MHz HSEDivide by 8 to obtain 1 MHz
New 25 MHz HSEDivide by 25 to obtain 1 MHz
Old divider retainedArithmetic result of 3.125 MHz
RTC calendar prescalersMatch the actual RTC input

The 3.125 MHz result indicates a mismatch. It is not a proposed RTC operating condition or a claim that the calendar will reliably run that many times faster. Use documented conditions for qualification.

2. Check RTCSEL before RTCPRE

If RTC uses the 32.768 kHz LSE, an HSE change does not directly change nominal LSE frequency. Verify initialization, reading behavior, and actual source when the calendar appears wrong. Only apply the HSE-divider calculation after confirming that path. A fitted watch crystal is not proof that the RTC uses it.

Source migration and divider correction are different

The manual requires resetting the backup domain to change an already selected RTC source. Here the focus is keeping the HSE route while changing its input frequency and reviewing the prescaler. It is not the same as migrating to LSE. Record actual settings and preserve backup data before troubleshooting. If migration is required, follow the project's backup and initialization procedure rather than resetting indiscriminately.

Bind HSE frequency and RTC source to the hardware revision. Firmware can update a system clock constant yet leave an old fixed value in calendar initialization. Test revision-specific images on real boards. If both revisions use one image, check how that image identifies each board.

3. Recompute the prescalers that make one second

ST's 1 MHz HSE_RTC calendar example uses asynchronous prescaler 124 and synchronous prescaler 7999. Their factors are 125 and 8000, for a product of one million. The field values are one below the factors. This illustrates an intended 1 MHz configuration, not a universal pair for every RTC source.

Do not validate a clock from one display screenshot

Run the device for a known interval and compare against an independent reference. Record startup and periodic time corrections; they can conceal the underlying rate. Account for polling and display rounding. If a log looks fast or slow, see whether the interval crosses reset, sleep, or a time write.

Read the current source and prescalers without changing the CPU PLL as an initial check. Compare results under approved settings and document the settling interval. Verify alarm or wakeup timing separately if used. A display that increments once a second does not qualify every wake event.

4. Test backup timekeeping as a separate requirement

LSE is in the backup domain; HSE is not. With HSE as the RTC source, RTC state is not guaranteed when VDD or the internal regulator is off. VBAT does not turn the HSE path into a backup oscillator. If the device requires continued timekeeping after power loss, review an appropriate LSE and VBAT design. Correct division in steady operation does not prove holdover after power loss.

An Epson FA-238 family part is an example to investigate for the high-frequency reference. Use the exact 25 MHz ordering code and check CL, ESR, drive, and board fit. This is not an approved replacement for an 8 MHz part. Review other derived clocks as well; matching package size does not establish electrical or firmware compatibility.

For products that need low-power operation, observe the actual clock across entry and exit. If the high-frequency reference stops, a steady-state pass does not cover that mode. Record calendar state before, during, and after on a dedicated sample. To assess time across a VDD interruption, confirm that VBAT remains available, compare with a known pre-interruption time, and do not use automatic time synchronization after reboot as the measurement.

Use the same conditions for both board revisions. An older board may retain an earlier backup-domain configuration while a new one starts blank. Record that state before comparing, and preserve data before any deliberate test reset. Also label where each value came from: register readback, an independent measurement, or a configuration-tool estimate. A discrepancy between design and implementation is different from probing the wrong clock.

5. Make the verification reproducible

Record board revision, exact HSE part, measured frequency, RTCSEL, RTCPRE, and both calendar prescalers. Separate steady VDD operation from backup testing, and report any time writes or calibration. Supply-driven substitutions can still require firmware updates, so write those into the change record. Release against the complete configuration and observed conditions rather than CPU clock alone.

An 8-to-25 MHz change requires a separate review of an HSE-driven RTC. Correct CPU frequency is not evidence of correct calendar timing or backup behavior.

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.