Associate II
April 17, 2020
Solved
Huge repetitive LPTIM interrupts
- April 17, 2020
- 6 replies
- 2372 views
I am trying to start with stm32wle5j but got stuck with LPTIM irq. I configure it but it always send me Interrupts. I need irq with period 2sec
I checked this post, but it didnt help me.
https://community.st.com/s/question/0D50X00009XkYEiSAN/huge-repetitive-lptim-interrupts
This is my code where i configure LPTIM
I setup RCC and enable LSE
HAL_PWR_EnableBkUpAccess();
__HAL_RCC_LSE_CONFIG(RCC_LSE_ON);
while (__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) == 0U)
; // wait for it...
__HAL_RCC_LPTIM1_CLK_ENABLE();
__HAL_RCC_LPTIM1_CLK_SLEEP_ENABLE(); // enable clock to LPTIM peripheral also in low power mode
__HAL_RCC_LPTIM1_FORCE_RESET();
__HAL_RCC_LPTIM1_RELEASE_RESET(); // reset LPTIM interface
__HAL_RCC_LPTIM1_CONFIG(RCC_CCIPR_LPTIM1SEL_0 | RCC_CCIPR_LPTIM1SEL_1);
HAL_PWR_DisableBkUpAccess();Then i configure LPTIM interrupts with period 2 sec
NVIC_SetPriority(LPTIM1_IRQn, 30);
NVIC_EnableIRQ(LPTIM1_IRQn);
// enable update (overflow) interrupt
LPTIM1->IER = 0;
LPTIM1->CR |= LPTIM_CR_ENABLE; // Enable LPTIM1
LPTIM1->IER |= LPTIM_IER_ARRMIE; //Autoreload match Interrupt Enable
LPTIM1->ARR = 0xffff; // set AutoReloadRegister 32768/65536 = 0.5 Hz
LPTIM1->CR |= LPTIM_CR_CNTSTRT; // Start LPTIMIn LPTIM1_IRQHandler i check the isr and then i clear IRQ flags
void LPTIM1_IRQHandler(void)
{
NVIC_ClearPendingIRQ(LPTIM1_IRQn);
if (LPTIM1->ISR & LPTIM_ISR_ARRM)
{ // overflow
}
if ((LPTIM1->ISR & LPTIM_ISR_CMPM) && (LPTIM1->IER & LPTIM_IER_CMPMIE))
{ // expired
}
LPTIM1->ICR = LPTIM_ICR_CMPMCF | LPTIM_ICR_ARRMCF; // clear IRQ flags
}But it isn't 2 sec period . It always interrupts my program and i can't reset it and.
I check that code in stm32L0xx and it works well. I see the different in LPTIM1 reg in WLE5 chip i have isr->ARROK and UE in 1 but in L0xx they in 0.
I attach LPTIM1 and RCC register value in files