cancel
Showing results for 
Search instead for 
Did you mean: 

Setting up a LPTIM with AR Interrupt on STM32WLE5

HWickham
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions
HWickham
Associate II
2 REPLIES 2
HWickham
Associate II
Strooom
Associate III

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.