cancel
Showing results for 
Search instead for 
Did you mean: 

STM32l4 LPTimer and Stop mode

patrick_hofstetter
Associate
Posted on September 19, 2016 at 17:13

Hi,

I am new to programming the stm32 chips and I want to use the LPTimer to wake up from Stop mode. I used CubeMX to initialize the timer with interrupt. I use the LSI with no prescaler (I can change this of course), so the clock period would be 31,25 us. Now I want to do something in the while loop of the main function and go into stop mode. After x*32,25 microseconds the chip should wake up with a lptimer interrupt.

With the normal timers there was no problem doing this (tim6 and sleep mode) with the HAL_base_IT function. But there is no such HAL-function with the LPTimer.

I would be happy, if you could help me here,

Greetings

 
1 REPLY 1
Nesrine M_O
Lead II
Posted on September 20, 2016 at 10:37

Hi Yellowchip,

I suggest you to have a look to this example under the STM32L4 cube firmware package:

STM32Cube_FW_L4_V1.5.0\Projects\STM32L476RG-Nucleo\Examples\LPTIM\LPTIM_PulseCounter

This example describes how to configure and use LPTIM to count pulses through the LPTIM HAL API.

To reduce power consumption, MCU enters stop mode after starting counting. Each time the counter reachs the maximum value (Period/Autoreload), an interruption is generated, the MCU is woke up from stop mode and LED2 toggles the last state.

-Syrine-