cancel
Showing results for 
Search instead for 
Did you mean: 

How to use LPTIM with LSE source clock

j_filipe
Associate II

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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!

View solution in original post

3 REPLIES 3
waclawek.jan
Super User

> 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

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! 

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!