cancel
Showing results for 
Search instead for 
Did you mean: 

LPTIM1 with LSE clock gets stuck waiting for ARROK flag

Errorr__
Associate II

Hi all,
I’m running into an issue with LPTIM1 when using LSE as the clock source. The exact same configuration works perfectly when I use LSI or PCLK, but with LSE the code gets stuck waiting for the ARROK flag after writing ARR.
The code blocks forever at:
while (!LL_LPTIM_IsActiveFlag_ARROK(LPTIM1)) {} 
So it looks like the ARR register update is never acknowledged when LSE is the clock.
Important notes

  • LSE is definitely running — it’s already used elsewhere in the system without issues.
  • We are looking for low power application
  • we using STM32U073CBT6


Clock configuration

LL_RCC_SetLPTIMClockSource(LL_RCC_LPTIM1_CLKSOURCE_LSE); LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_LPTIM1); LL_IOP_GRP1_EnableClock(LL_IOP_GRP1_PERIPH_GPIOC);
NVIC_SetPriority(TIM6_DAC_LPTIM1_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 3, 0));
NVIC_EnableIRQ(TIM6_DAC_LPTIM1_IRQn);


LPTIM configuration

/* Make sure timer is disabled before config */
LL_LPTIM_Disable(LPTIM1);
/* Select clock & prescaler FIRST */
LL_LPTIM_SetClockSource(LPTIM1, LL_LPTIM_CLK_SOURCE_INTERNAL);
LL_LPTIM_SetPrescaler(LPTIM1, LL_LPTIM_PRESCALER_DIV1);
LL_LPTIM_SetUpdateMode(LPTIM1, LL_LPTIM_UPDATE_MODE_IMMEDIATE); LL_LPTIM_SetCounterMode(LPTIM1, LL_LPTIM_COUNTER_MODE_INTERNAL);
/* Enable peripheral */
LL_LPTIM_Enable(LPTIM1);
/* Enable interrupt */
LL_LPTIM_EnableIT_ARRM(LPTIM1);
/* Set ARR and wait until it is taken into account */
LL_LPTIM_ClearFlag_ARROK(LPTIM1);
LL_LPTIM_SetAutoReload(LPTIM1, 31199);
while (!LL_LPTIM_IsActiveFlag_ARROK(LPTIM1)) {}
/* Start counter */
LL_LPTIM_StartCounter(LPTIM1, LL_LPTIM_OPERATING_MODE_CONTINUOUS);


What I expected
ARR should be written successfully and ARROK should assert, just like when using LSI or PCLK.
What actually happens
With LSE as LPTIM clock, ARROK never sets and the code stalls.

2 REPLIES 2
waclawek.jan
Super User

Read out and check/post content of RCC_BDCR, RCC_CCIPR and LPTIM registers.

Is this issue LPTIM1-specific, or does it occur also on LPTIM2/3?

JW

Saket_Om
ST Employee

Hello @Errorr__ 

Did the LSE clock enabled? 

LL_RCC_LSE_Enable()
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.
Saket_Om