2025-06-05 8:06 AM
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.
Solved! Go to Solution.
2025-06-06 8:34 AM
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!
2025-06-06 12:35 AM
> 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
2025-06-06 1:39 AM
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!
2025-06-06 8:34 AM
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!