Showing results for 
Search instead for 
Did you mean: 

STM32F030R8 PWM using LSE as source for Timer

Associate II

Hi all, 

I was wondering if there is a way to set up the LSE as the source for a Timer on the STM32F030R8 to generate a PWM output signal. Currently doing a deep dive on clock configurations, timers, etc. and I have been able to use the HSE for PWM, but can I use the LSE for PWM? Maybe with RTC?

Thank you in advance for answers!


why dont you look at the clock tree, CubeMx shows you , what you can do/connect or not ?

If you feel a post has answered your question, please click "Accept as Solution".
ST Employee

Hello @tolgaust and welcome to the ST COMMUNITY 😊.

According to the clock tree of the STM32F030R8 (DS9773 page 15) you Can find that the timer Can use only 4 clock sources (HSE, HSI, HSE_PLL and HSI_PLL). So you can't use LSE as clock source for a timer.


Best Regards 


To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Reading the clock tree, I don't think LSE can be directly fed into a timer, so I was just curious if I was forgetting about something / unaware of some special thing to do to be able to use LSE as the source! 

ST Employee

Hello @tolgaust,

According to RM0360 STM32F030R8, the timer clock frequencies are automatically fixed by hardware. There are two cases:
– if the APB prescaler is 1, the timer clock frequencies are set to the same frequency as that of the APB domain;
– otherwise, they are set to twice (x2) the frequency of the APB domain.

In particular, TIM14 channel 1 input capture, can be used for the calibration HSI, LSI or HSI14 or to measure the frequency of all on-board clock sources (see RM0360, section 7.2.12).

Here HSE/32 can be connected to TIM14 channel1, but I can't understand how you were able to use the HSE for PWM ? Can you give more details ?


Best regards

I followed a guide online on configuring a timer to generate a PWM, and set TIM16 for the following settings:


Then I selected HSE as the source on the System Clock Mux for the APB1 peripheral clocks. 


Lastly, from my understanding, setting HSE source to BYPASS uses the High Speed crystal on the ST-Link debugger part of the nucleo board as its HSE crystal



ST Employee

In this case the HSE is the clock source of the System Clock, the rest of the clocks in the tree derived from this clock source, mainly the AHB clock HCLK and the APB clock PCLK. The timers clock source is the PCLK.


For the HSE Bypass : In this mode, an external clock source must be provided (from a GBF for example ...). It can have a frequency of up to 32 MHz.

According to the Nucleo board schematic (MB1136), there is no way to use the STLINK HSE crystal (fig1 the HSE feeding the STM32F0 and fig2 the HSE that feeds STLINK)