Skip to main content
Senior
Jun 5, 2025 3:06 PM UTC
Solved

How to use LPTIM with LSE source clock

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.
j_filipeBest answer
Senior
Jun 6, 2025 3:34 PM UTC

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!

3 replies

waclawek.jan
Super User
Jun 6, 2025 7:35 AM UTC

> 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
Senior
Jun 6, 2025 8:39 AM UTC

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_filipeAuthorBest answer
Senior
Jun 6, 2025 3:34 PM UTC

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!