diego peinado martin

STM32L4 Stop2 while using lptim1

Discussion created by diego peinado martin on May 11, 2018

Hello. I want to set one timer for a future event. Then set the stm32L4 to stop 2 and wake it up with the periodic wake up unit. My code is as follows:


while (1)
   HAL_GPIO_TogglePin(LD3_GPIO_Port, LD3_Pin);
   HAL_GPIO_TogglePin(LD3_GPIO_Port, LD3_Pin);
   HAL_LPTIM_Counter_Start_IT(&hlptim1, 65533);
   HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 0x2710, RTC_WAKEUPCLOCK_RTCCLK_DIV16);


If I remove the line: HAL_LPTIM_Counter_Start_IT(&hlptim1, 65533), then everything works ok, the MCU goes to stop mode, and it wakes up at the correct time given by HAL_RTCEx_SetWakeUpTimer_IT().

The problem arises when I put the LPTIM1 activation counter. Then the MCU does not go into stop mode. Probably there is something in the LPTIM1 counter that prevents the MCU from entering in stop mode.

 ¿Does anybody know what I should do to use the LPTIMER1 while the MCU being stopped?

Thanks in advance.