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

How can a 32.768 kHz crystal trim the STM32G0B1’s 48 MHz USB clock after sleep?

A USB device enumerates normally, but sometimes fails on wake. Its 32.768 kHz passive crystal appears to be running, so the team considers adding a 48 MHz active oscillator. First identify the signal the firmware uses for clock recovery. The STM32G0B1 can trim an internal 48 MHz oscillator with its Clock Recovery System. If it relied on USB Start of Frame and the host stops sending frames in the relevant sleep state, the 32.768 kHz crystal does not automatically take over. After selecting a different reference, recompute the recovery counter for that reference frequency.

Separate the three clocks

The full-speed device needs an accurate 48 MHz working clock. On the STM32G0B1, HSI48 is an internal RC oscillator that the CRS can trim under supported conditions. USB Start of Frame can supply synchronization. Depending on the configuration, CRS can also use LSE or the designated external sync input. SOF is the reference for correction. HSI48 produces the 48 MHz clock. A board’s 32.768 kHz crystal can provide a different reference for correction without directly clocking the USB transceiver.

ST’s RM0444 notes that in the described USB Link Power Management sleep state, the host does not generate periodic SOF. For required precision on wake, the manual specifies LSE or the external sync signal. Verify that the product uses this sleep state, when entry and exit occur, whether LSE stays running, and whether any control register resets. An ordinary active USB session only verifies the settings in that state. Purchasing should establish whether the board depends on its low-speed crystal for wake before removing it.

Recalculate the synchronization period and reload

The reference manual defines the reload as the target frequency divided by the post-prescaler synchronization frequency, minus one. With 1 kHz SOF, 48,000,000/1,000 is 48,000, giving a reload of 47,999. If a 32.768 kHz crystal provides LSE and the CRS sync divider divides by 32, the synchronization frequency is 1,024 Hz. Now 48,000,000/1,024 is 46,875, giving a reload of 46,874. These are nominal calculations. Check the silicon revision, source selection, divider, and frequency error limits for the actual configuration.

If the source and divider change but the SOF reload of 47,999 stays in place, the interval still expects 48,000 clocks. The new reference corresponds to 46,875 clocks, a difference of 1,125. This is far larger than the small clock corrections the application needs. If bench logs show repeated errors, read back the configuration and when it was written. Confirm that reference and reload actually agree before changing load capacitors or limits.

During normal SOF synchronization, the cycle error can also help diagnose the scale of an issue. Forty-eight extra cycles in a nominal millisecond correspond to about 1,000 ppm, or 48,000 Hz at the target. This estimate assumes an accurate synchronization interval and a capture from that event. A late or missing frame makes it inappropriate to assign the entire difference to the internal oscillator. Preserve the captured count and its direction so an equally large slow and fast error do not look identical.

Separate missing frames from a clock error

Correlate USB protocol events with firmware timestamps. Record the last frame, sleep entry, resume, the first frame, and the first successful transfer. Log CRS sync success, missing or erroneous sync, and the selected reference. SYNCMISS can indicate missing synchronization or excessive internal frequency error, so the flag alone does not establish that the 32.768 kHz crystal stopped. Compare it with LSE readiness, the actual sync source, and bus traffic. If SOF remains the active reference, the test should show how missing SOF relates to the logged event.

For comparison, repeat the permitted SOF and LSE configurations on the same board, host, and cable. If the LSE configuration still fails, verify the selected source and that it survives sleep, then check the crystal circuit, startup, and resume code. For a low-power crystal node, prefer status observations and validated buffered test points to a high-capacitance probe directly on the pin. If only cold startup becomes slower after a change, measure crystal startup separately from the time to the first frame after wake. Run separate cold-connect and suspend-resume tests because the initial availability of the oscillator and synchronization source differs.

Preserve the sourcing and acceptance record

If a 32.768 kHz passive crystal is used for LSE, keep its load capacitance, ESR, stability over temperature, and related power conditions with the board verification. If an external clock is considered, identify whether the chosen input is used for synchronization, an oscillator bypass, or a PLL reference. Verify electrical and frequency limits for that path. A 48 MHz working-clock label does not make a 48 MHz active oscillator a substitute for a low-speed crystal on its original pads. After a change, retain evidence for this MCU’s clock tree and USB device mode.

An acceptance record should state which reference survives sleep, whether frames continue, when the first successful transfer occurs, and whether the reload matches the selected source. Repeat under the product’s supply and temperature conditions. This gives purchasing and engineering an evidence-based decision about the passive crystal or any external oscillator option.

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.