Showing results for 
Search instead for 
Did you mean: 

LPTIM interrupt can't wake STM32u5 from STOP low power mode

Associate III

I am trying to us the LPTIM low power timer to trigger interrupts intermittently while the MCU is in STOP2 mode, but I am unable to do so. I am testing the interrupts by toggling a GPIO pin and checking the output on a scope.

Without STOP mode I see the interrupts and GPIO toggle as expected. Once I enter STOP2 mode I don't see any interrupts. Interestingly, if I debug the microcontroller via STLINK, I can see the GPIO toggle and a single interrupt trigger if I pause and then resume the debugger.

Is the LPTIM capable of doing this? I want to achieve repeated wake events to perform actions at specified times. The datasheet and reference manual say the LPTIM1 should be fully functional in this low power mode. If this is possible, what am I missing?

Using STMcube to configure the LPTIM and enable interrupts. I have tried configuring with LSI, MSI, and LSE as clock sources.

I am using HAL_LPTIM_Counter_Start_IT(&hlptim1) to start the interrupts and have used callbacks: LPTIM1_IRQHandler() and HAL_LPTIM_AutoReloadMatchCallback().

I am using the development kit B-U585I-IOT02A Discovery.

_legacyfs_online_stmicro_images_0693W00000bkEVhQAM.pngSome excerpts from the code:

 * Enter stop 2 mode
void GoToSleep()
	  __disable_irq(); //Disable interrupt to avoid timing issues
	  // Useful if already in low power run mode, see
	//  HAL_PWREx_DisableLowPowerRunMode();
	  is_asleep = true;
 * Interrupt that results in wake from stop 2 mode
void HAL_LPTIM_AutoReloadMatchCallback(LPTIM_HandleTypeDef *hlptim)
	if(hlptim == &hlptim1)
		toggle = true;
/* In main: */
/* Infinite loop */
  HAL_StatusTypeDef status = HAL_LPTIM_Counter_Start_IT(&hlptim1);
  while (1)
	  if(toggle == true)
		if(is_asleep == true)
			SystemClock_Config(); // Need to reconfigure the clock on exit from sleep mode to use HSI clock
			is_asleep = false;
		  HAL_GPIO_TogglePin(LED_GPIO_Port, LED_Pin);
		  toggle = false;
    /* USER CODE BEGIN 3 */

Kamil Duljas
Senior III

Did you try it without debug mode?


Yes. I have tried deploying through debug mode and then disconnecting the debugger and restarting the MCU.

Also tried compiling in Release configuration and flashing the MCU manually.

Neither works

Associate III

I tried the same code with a similar configuration on a different development kit, the STM32L562E-DK Discovery. It works as expected there. Still not working on the STM32u585

Associate III

Managed to solve this thanks to

Needed to set the LPTIM1AMEN bit in the RCC_SRDAMR register to enable autonomous mode in stop mode.

Used the __HAL_RCC_LPTIM1_CLKAM_ENABLE(); macro to do this.

ST Employee

Hello @JKahn.1​,

Glad that you managed to solve your problem, by using STM32U5 you can use the LPBAM feature that allows LPTIM to request its clock and can stay functional in stop2 mod without even waking up the CPU!

Check this knowledge article about the feature and its advantages

I hope that helps in your future projects!

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.