Skip to main content
Visitor
Nov 2, 2026 11:51 AM UTC
Question

STM32L476 – LPTIM2 asynchronous external pulse counting in STOP2 mode

I am working on an equipment  based on an STM32L476 and would like to clarify the actual behaviour of LPTIM2 in STOP2 mode.

The objective is to count external pulses while the MCU is in STOP2, in order to minimise power consumption.

Hardware and configuration

  • MCU: STM32L476VET6
  • External pulse signal connected to PD12 (LPTIM2_IN1, AF14).
  • Pulse frequency: approximately 1 Hz.
  • Pulse signal: 0–3 V.
  • LPTIM2 configured as an external counter, with the following settings:
    • Clock source: LPTIM_CLOCKSOURCE_ULPTIM
    • Prescaler: DIV1
    • Counter source: LPTIM_COUNTERSOURCE_EXTERNAL
    • Input 1 source: GPIO
    • Input 2 source: GPIO
    • Rising edge polarity (CKPOL = 00)
    • No input filtering (CKFLT = 00).

Initialisation issue

When using the asynchronous clock configuration, the HAL function HAL_LPTIM_Counter_Start_IT() times out while waiting for the ARR register update to be acknowledged (ARROK).

This appears to be because the ARR update is synchronised with the external clock on LPTIM2_IN1. With a 1 Hz input signal, the update may take several seconds.

To avoid this problem, I initially configure LPTIM2 using the internal kernel clock (synchronous mode), load ARR successfully, and then switch to asynchronous mode by setting CKSEL = 1, disabling and re-enabling the peripheral.

This works correctly: LPTIM2 counts external pulses in normal operating mode.

STOP2 experiment

I then tested the same configuration with STOP2 enabled.

The MCU is periodically woken up by an RTC interrupt every second. I verified that the STOP2 code path is executed and that the program resumes after each RTC wake-up.

The observed count is approximately the same in both cases:

  • STOP2 disabled: approximately 72 CPM after 1 min 20 s.
  • STOP2 enabled: approximately 72 CPM after 1 min 20 s.

The input pulse generator runs continuously at approximately 1 Hz.

This suggests that LPTIM2 may continue counting external pulses while the MCU is in STOP2.

However, I have not yet confirmed this with a direct measurement of the supply current or by comparing the LPTIM2 counter value immediately before entering STOP2 and immediately after waking up.

My questions

  1. Is LPTIM2 expected to continue counting external pulses in asynchronous mode (CKSEL = 1) during STOP2 on the STM32L476?
  2. Is this behaviour documented or supported, despite the reference manual stating that LPTIM2 must be disabled before entering STOP2?
  3. Could this be an undocumented hardware capability, or am I overlooking something in the power-management configuration?

I am aware that ST application note AN4865 demonstrates asynchronous external pulse counting during STOP2 using LPTIM1. My question specifically concerns LPTIM2.

Any clarification from ST would be appreciated.