cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4 how to get LSE clock connected with an output pin?

RZ
Associate II

The output pin in question can be configured as LPTIM1_OUT and I know how to configure the LPTIM1 but I'm afraid I'll endup with LSE/2 as a clock. I need the LSE clock source to be connected to that output pin 1:1.

Besides using the LPTIM1 isn't there a more easy way to do this?

3 REPLIES 3
Peter BENSCH
ST Employee

If LSE is activated, you can output its clock via pin MCO. The MCO output is preceded by a multiplexer and a divider. This allows you to select the clock in question, and the divider also allows you to select a divider ratio from 1:1...1:16.

Does it answer your question?

Regards

/Peter

In order 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.
RZ
Associate II

Yes and no. Yes it answer my question but I realize my question is incomplete. The hardware is already fixed and I don't have any option to connect the peripheral to the MCO pin, it is connected to the LPTIM_OUT pin. The LSE clock source is much more accurate then the internal clock of the peripheral. Now we need to find a trick to get the LSE clock source connected to the LPTIM_OUT pin.

A hardware hack isn't the answer as the MCO pin is used for other functions, unfortunately.

Peter BENSCH
ST Employee
  • you have already selected LSE as clock for LPTIM
  • the prescaler is certainly set to /1, which means that the 16bit counter receives the LSE clock directly.
  • but you can let the 16bit counter generate three different output signals (called waveforms), whereas only the PWM mode seems to make sense for you

Well, the RM0394, section 30.4.9 should give a clear answer here:

  • The PWM mode: the LPTIM output is set as soon as the counter value in LPTIM_CNT exceeds the compare value in LPTIM_CMP. The LPTIM output is reset as soon as a match occurs between the LPTIM_ARR and the LPTIM_CNT registers.

This results in exactly at least a halving of the input frequency, so that you cannot output LSE directly 1:1 from LPTIMx_OUT.

The only chance besides MCO would be RCC_LSCO - unfortunately you are stuck with LPTIMx_OUT.

Regards

/Peter

In order 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.