Page 1 of 1

Change Timer clock source

Posted: Tue May 26, 2020 12:27 pm
by MystikReasons
I want to use the external quartz crystal (32.768kHz) as the ETR (external trigger input).
Currently I'm using the HardwareTimer library.
How can I change the clock source for example the Timer1 on the STM32L452RE?

Thank you

Re: Change Timer clock source

Posted: Tue May 26, 2020 2:19 pm
by ABOSTM
Hi @MystikReasons,
Current implementation of HardwareTimer does not support ETR management. And there is no plan to do it.

But it is still possible to use STM32 HAL API (which are usable directly within Arduino sketch) to use ETR as clock source.

When you say
the external quartz crystal (32.768kHz) as the ETR
do you mean LSE crystal ?
Because it is not possible to use LSE as a source of timer (General purpose Timer TIMx). Using ETR requires an external square signal connected to ETR pin.
Nevertheless it is possible to use LSE as source of LPTimer (LowPower Timer) but it is not in use in Arduino. You can still use STM32 cube HAL/LL to use LPTIM. And because LPTIM peripheral is completly different than TIM, using LSE as source of clock will not go through ETR but will be configured directly thanks to RCC (Reset and Clock Control).

Re: Change Timer clock source

Posted: Wed Jun 03, 2020 6:31 am
by MystikReasons
Hi @ABOSTM
Yes I meant the LSE crystal.
Thank you for your detailed explanation and sorry for the delay, I was on vacation.