Specialist Supplier of Crystals & Frequency Control Componentssales@mecxtal.com.cn0755-26500570
MERLIN home / Rednote / Passive Crystals and Oscillator Circuits

Why can an STM32G071 reset early when its 32.768 kHz crystal keeps accurate time?

An STM32G071 logger keeps calendar time with a 32.768 kHz quartz crystal. The calendar looks accurate at room temperature, but the board sometimes resets at low temperature. Shortening the watchdog service interval can make it worse. The RTC source and independent watchdog source are separate. With an IWDG refresh window enabled, refreshing too early can also reset the device.

Identify the clock and reset source

ST specifies the external low-speed oscillator LSE and the internal low-speed RC oscillator LSI. The RTC can use the external 32.768 kHz crystal and keep time in the appropriate backup configuration. The IWDG takes its reference from LSI. Switching the RTC to an active external oscillator does not change that IWDG source. Read the RTC source selection and RCC reset indications. Identify which watchdog is active before attributing a reset to timing tolerance.

The STM32G071 data sheet gives 31.04 to 32.96 kHz at 3 V and 30°C, and 29.5 to 34 kHz across the broader voltage and temperature conditions listed in the table. Choose the applicable range for the actual package and operating conditions. Use the nominal 32 kHz value for a first estimate, then calculate the bounds. Consider how supply and temperature affect the service task as well as the clock.

Compute the common window

For an illustrative configuration, use a prescaler of 32, a reload value of 999 and a window of 699. With nominal 32 kHz LSI, 1,000 prescaled cycles are about one second. The counter passes through about 300 counts before reaching the window level, approximately 300 ms at nominal frequency. Stay away from equality at the window boundary. Account for the register comparison rule, synchronization and measurement uncertainty.

At the slower 29.5 kHz bound, the window-opening estimate is 300 times 32 divided by 29,500, or about 325 ms. At the faster 34 kHz bound, the timeout estimate is 1,000 times 32 divided by 34,000, or about 941 ms. A service interval that actually varies from 360 to 750 ms therefore leaves roughly 35 and 191 ms of margin at the ends of this simplified calculation. Subtract the relevant startup, low-power and uncertainty allowances before qualifying the result. The application must also meet its independent fault-response requirement.

Changing a 400 ms interval to 200 ms can move service into the early-refresh region. A busy task can instead miss the deadline. Both failures may appear as an IWDG reset. Capture when service was expected and when the IWDG register was actually written. Number the events to detect a missing refresh during an intermittent failure.

Collect evidence that tells the team what to change

Confirm the window was enabled. RM0444 states that the default all-ones setting leaves the option disabled, and writing a new window setting reloads the counter. That can change the start of the first interval. Follow the documented updates for the prescaler, reload and synchronization status. Test cold power-on and software reset separately. Compare results without the debugger if debug settings can pause the watchdog. An external timebase can record the last refresh, reset indication and supply condition together.

Use a valid baseline, then test one intentionally early refresh and one missed refresh on an approved separate board. Verify that the external trace or reset log distinguishes them. Specify the state reached after reset and which application condition permits a refresh. A periodic task continuing to run is not evidence that the monitored function completed.

Also test a wakeup with concurrent logging. Count time spent asleep and waking if the watchdog remains active. If an option pauses it in that mode, document and verify that condition separately. Keep the firmware, option settings and reset flags together.

For separate RTC drift, check the selected low-speed sources. The STM32G071 can output selected LSI or LSE via LSCO subject to the documented power-mode limits. Label the measurement route each time the selection changes. Record the internal RC result for analysis of watchdog margins and the external reference result for calendar accuracy. Keep the full crystal part number, load, drive, temperature and startup requirements in procurement. If the calendar passes and the watchdog timing reaches a calculated boundary, adjust and retest the relevant firmware schedule or window.

References

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.