Change Timer clock source

Post here first, or if you can't find a relevant section!
Post Reply
MystikReasons
Posts: 2
Joined: Tue May 26, 2020 12:24 pm

Change Timer clock source

Post 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
ABOSTM
Posts: 60
Joined: Wed Jan 08, 2020 8:40 am
Answers: 7

Re: Change Timer clock source

Post 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).
MystikReasons
Posts: 2
Joined: Tue May 26, 2020 12:24 pm

Re: Change Timer clock source

Post by MystikReasons »

Hi [mention]ABOSTM[/mention]
Yes I meant the LSE crystal.
Thank you for your detailed explanation and sorry for the delay, I was on vacation.
Post Reply

Return to “General discussion”