Distinguish a failure to enter Stop from a failure to wake afterward. The STM32L031 errata ES0322 §2.8.1 describes a race while disabling LPTIM: clearing ENABLE near an interrupt can leave the wakeup interrupt signal stuck active, preventing Stop even with a stable 32.768 kHz crystal. The documented way to disable LPTIM in this case is to reset the entire peripheral through RCC instead of directly clearing ENABLE. If LPTIM itself is meant to wake the system, do not disable it without first separating that use case.
Identify where the sequence stops
An external crystal can provide 32.768 kHz LSE, which the controller can then select for LPTIM. A fitted crystal and visible oscillation do not prove selection. Check LPTIM1SEL for APB, internal LSI, HSI16 or LSE. The reference manual states that LPTIM can operate in Stop when clocked by LSE or LSI and that LPTIM interrupts can exit Stop. Standby is different: the peripheral has to be reinitialized after exiting it.
| Observation | First diagnostic path | Do not start by |
|---|---|---|
| Runs normally, no timed event in Stop | LPTIM1SEL and the actual power mode | Replacing the crystal |
| Repeated interrupt immediately after disabling LPTIM | ES0322 ENABLE timing limitation | Attributing it to frequency drift |
| Wakes from true Standby | Peripheral reinitialization | Treating it as resumed Stop counting |
| LSE itself is not ready | Crystal circuit, configuration and startup | Attributing every symptom to the errata |
The observations are clues, not diagnoses. Mark the point before entry and log interrupt entry, exit and events after wake. A “ready to sleep” log is not proof of Stop if current does not fall. If consumption is consistent with Stop but the application never resumes, distinguish missing wakeup from application recovery.
Check the scale of the timing error
At nominal 32,768 Hz one cycle is about 30.52 µs. Without prescaling, 32,768 elapsed cycles are about one second. That does not prescribe an ARR setting for every mode. Prescaler, count origin, overflow, compare events and interrupt response affect observed timing. A few tens of ppm of crystal error are not a sound explanation for code remaining in an interrupt.
What triggers the erratum?
ES0322 describes disabling the timer near a timer interrupt, in a narrow window. It does not happen on every ENABLE write and is not solved by a more accurate crystal. If the application really needs to stop LPTIM before entering Stop, check the applicable manufacturer procedure. This section recommends asserting and releasing the appropriate RCC peripheral reset. Resetting the whole peripheral is not the same as changing one enable bit. Verify the count, compare and interrupt configuration after restore rather than assuming it survived.
If LPTIM is supposed to provide the Stop wake event, configure a suitable low-speed source and preserve the required wake conditions; do not apply a disable workaround to all modes. Record whether another source wakes the system after LPTIM shuts down, or whether LPTIM must remain active. These are different tests.
Clearing an event flag is a separate issue
A neighboring erratum concerns a flag-clear operation overlapping with a new event. This is distinct from clearing ENABLE while disabling the timer. If the application did not disable LPTIM but still repeatedly enters the interrupt, compare configured interrupts and actual flag-clear order against that other section. Repeatedly clearing all flags in arbitrary contexts can hide which event is involved. Preserve software revision and the enabled interrupt list before concluding that the crystal is unstable.
When the crystal does need review
If LSE never becomes ready or startup and frequency differ between boards, review the resonant circuit. Epson FC-135R, for example, is a passive 32.768 kHz family; the actual order must still identify load, maximum ESR, operating range and package. A family sheet is not blanket approval for STM32L031. Check the originally approved part, MCU requirements, layout and loading before recording startup.
A probe can disturb the oscillator node. Use a documented buffered output or validated low-loading method when available. Record oscillation, source readiness and software events independently. If the waveform is good but software selects a different source, correct that interpretation first. If LSE actually fails to become ready, the erratum does not eliminate the need for circuit diagnosis.
Keep power state, source and interrupt evidence separate
Put timer startup in Run, preparation for low power, timer disable or retention, and measured consumption in one timeline. Retain configuration and capture separately for both designs: a timer-disabled run cannot qualify a design that relies on that timer to wake. If a cold sample wakes late, distinguish late timer startup from late application interrupt handling. Where serial logs are the only markers, account for delay between a real event and its log.
Test one cold startup and one transition with LSE already ready. A first-cycle-only issue suggests checking readiness at initialization. An intermittent issue during repeated transitions near LPTIM disable is a stronger reason to review the erratum. State which events, modes and timer settings were observed, not merely that sleep failed. One successful attempt does not disprove a narrow timing issue, and one occurrence does not establish that every board will reproduce it.
Check whether attaching a debugger changes low-power behavior, and document connected and standalone conditions separately. If supply current indicates the state, preserve representative power and loading. When evaluating the peripheral-reset approach, check that the stall is gone and that subsequently reinitialized timer functions work. A mitigation for failure to enter Stop does not qualify period accuracy, cold crystal startup or other wake sources. Keep passed checks and untested boundaries separate.
Divide the checks between firmware, hardware and purchasing
Firmware verifies mode, clock source and disable sequence. Hardware verifies startup, reset and achieved power state. Purchasing uses an exact approved crystal specification only when replacement is justified. Compare normal timing, low-power entry and a reproduced failure on the same hardware and firmware. If the fault tracks peripheral disable, verify the applicable erratum before ordering a more accurate crystal. If the design needs timed wakeup, qualify real sleep and wake behavior, not a frequency reading made only while awake.
