cancel
Showing results for 
Search instead for 
Did you mean: 

How to count input pulses without waking from sleep mode.

Peter Simpson
Associate II

Hi, I have an STM32L072 micro. I need to count the transitions on two IO pins.

I would like to do it while the MCU is in sleep mode and periodically wake to process the results.

In this MCU there is only one LPTIMer . Is it possible to configure the other timers to capture the transitions in counter mode without waking the MCU?

Thank You

Regards

4 REPLIES 4
TDK
Guru

> The devices feature five low-power modes:

> • Low-power run mode: regulator in low-power mode, limited clock frequency, limited

> number of peripherals running (refer to Section 6.3.4)

> • Sleep mode: Cortex®-M0+ core stopped, peripherals kept running (refer to

> Section 6.3.7)

> • Low-power sleep mode: Cortex®-M0+core stopped, limited clock frequency, limited

> number of peripherals running, regulator in low-power mode, Flash stopped ((refer to

> Section 6.3.8))

> • Stop mode (all clocks are stopped, regulator running, regulator in low-power mode

> (refer to Section 6.3.9)

> • Standby mode: VCORE domain powered off ((refer to Section 6.3.10))

You can keep peripherals active during sleep mode, not just the LP ones.

If you feel a post has answered your question, please click "Accept as Solution".
berendi
Principal

All peripherals continue working in sleep mode by default, only code execution is stopped. Just configure two timers in ECM1 or ECM2 to count edges.

The RCC can shut down selected peripherals automatically when in sleep mode, see the description of the RCC_AHBSMENR / RCC_APBxSMENR registers in the reference manual.

LPTIM is different because it can run in stop mode as well.

Uwe Bonnes
Principal II

Sleep vs deep sleep. WFI saves a little power, Deep sleep much more. Low power run mode should also get considered.

Deep sleep is stop or standby, where normal timers are stopped, so it won't work.

Low power run or sleep would work, just one should mind the minimum pulse width of the input signal wrt the timer clock in order to not miss any pulses.​