Skip to main content
HWickham
Associate II
March 22, 2022
Solved

Setting up a LPTIM with AR Interrupt on STM32WLE5

  • March 22, 2022
  • 2 replies
  • 1645 views

I have a program that requires a 30 second wake up period to feed a watchdog but use as little power a possible. To initiate the LPTIM using an external 32.768kHz watch crystal I am doing this:

__HAL_RCC_LPTIM1_CONFIG(RCC_LPTIM1CLKSOURCE_LSE); //LSE LPTIM1
 __HAL_RCC_LPTIM1_CLK_ENABLE();
 LPTIM1->CR &= ~LPTIM_CR_ENABLE; //Ensure Disabled
 LPTIM1->IER |= LPTIM_IER_ARRMIE; //Auto-reload match Interrupt
 NVIC_EnableIRQ(LPTIM1_IRQn);
 NVIC_SetPriority(LPTIM1_IRQn, 40);
 LPTIM1->CFGR |= (0b110 << LPTIM_CFGR_PRESC_Pos); // /64 prescaler, restart on trigger
 LPTIM1->CR |= LPTIM_CR_ENABLE;// | LPTIM_CR_RSTARE;
 LPTIM1->ARR = 15360; //Reload on cnt==15360 (30 seconds at 32,768/64)
 LPTIM1->CR |= LPTIM_CR_CNTSTRT; //Start LPTIM1 in continuous mode

Once this has been initiated I put the device into STOP2, after 30 seconds I was expecting this

void LPTIM1_IRQHandler( void ){
 LPTIM1->ICR |= LPTIM_ICR_ARRMCF | LPTIM_ICR_CMPMCF; //Clear Status
}

interrupt handler to be called which would wake the device out of STOP2 and would continue round the main loop.

I cant tell if this interrupt is being called, or if the interrupt gets called but then does not continue the program back into the main loop.

Is this the correct way to set up an auto-reload interrupt on a low power timer?

Thanks

Best answer by HWickham

https://community.st.com/s/question/0D53W000010u6rHSAQ/has-anyone-had-a-problem-with-the-lptimtimeout-example-on-stm32wl55

Needed to enable the EXTI line for the LPTIM1

EXTI->IMR1 |= EXTI_IMR1_IM29;

2 replies

HWickham
HWickhamAuthorBest answer
Associate II
March 22, 2022
Strooom
Senior
February 17, 2024

Thank you - I had a similar problem on STM32WLE5 : it would not wake up from STOP2 on LPTIM1 interrupt. 

Still need to further investigate what's happening, because the reference manuals did not mention anything extra was needed.