Skip to main content
Graduate II
June 5, 2025
Solved

How to use LPTIM with LSE source clock

  • June 5, 2025
  • 1 reply
  • 431 views

Greetings, 
I am using a Discovery Kit (B-U585I-IOT02A) and I want to use the LPTIM1 to wait 5 seconds (counting x ticks), at the end of the 5 seconds enter in a Callback to do something and then restart the counter again.I want to use as clock source the 32.768Khz crystal (LSE). 
So, I configured the LSE clock in the RCC section of the .ioc, then I set the LSE as clock source for LPTIM1, and activated the interrupts. 
At the main function, I used the HAL_LPTIM_TimeOut_Start_IT(&hlptim1, 16383) and used the void HAL_LPTIM_AutoReloadMatchCallback (LPTIM_HandleTypeDef* hlptim) callback to do something. 
The callback is not being called, I measured the signal at the crystal, and I can't see any clock in it. I guess something's missing in the configuration but I have no clue what it is and I can't make it work. 
An helping hand would be appreciated.

    This topic has been closed for replies.
    Best answer by j_filipe

    I figured it out. 
    The function I needed to call is HAL_LPTIM_Counter_Start_IT and it works with the AutoReloadMatchCallback. Thank you anyway!

    1 reply

    Super User
    June 6, 2025

    > I measured the signal at the crystal, and I can't see any clock in it.

    LSE is a ultralow-power oscillator, and connecting a normal oscilloscope probe to it can prevent it from working.

    You can output the LSE oscillator to MCO pin; some STM32 also have a dedicated LSCO output. Also, read out and observe the RCC_BDCR register's content.

    JW

    j_filipeAuthor
    Graduate II
    June 6, 2025

    Thank you for the advice, I'll try to do that. I'm quite new at embedded with stm32. 
    But I’d like to know whether the way I’m doing it — the function "HAL_LPTIM_TimeOut_Start_IT" and the corresponding callback "HAL_LPTIM_AutoReloadMatchCallback"— is actually the most appropriate way for what I’m trying to achieve?
    Thank you! 

    j_filipeAuthorAnswer
    Graduate II
    June 6, 2025

    I figured it out. 
    The function I needed to call is HAL_LPTIM_Counter_Start_IT and it works with the AutoReloadMatchCallback. Thank you anyway!