Skip to main content
Associate II
September 6, 2023
Question

STM32H745 Timer 2 Triggering Prematurely when using ITR1

  • September 6, 2023
  • 6 replies
  • 2080 views

I have set up TIM2 as a slave triggered by ITR1,  But have not started any other timers to generate a suitable TRGO to trigger TIM2.  However, when I run the software I can see an output from TIM2 as soon as it is started.

If I change TIM2 to be triggered by ITR0 I don't see any output, until I start TIM1 which sets it's TRGO.

Is there something else generating the ITR1? 

Can I clear any pending ITR1 before starting TIM2?

This topic has been closed for replies.

6 replies

NBrick67Author
Associate II
September 6, 2023

I have found the cause of the problem. 

I was using TIM1 to generate the ITR0 and TIM8 to generate the ITR1.

My configuration of the timers, prior to starting them was TIM1, TIM2, TIM8.  Although none of the timers has been started, TIM2 started running (CNT incrementing) when I configured TIM8.  Moving the configuration of TIM8 before TIM2 fixed the issue.

Any explanation?

Associate II
September 6, 2023

What happens to the CEN bit in TIM2's CR1? I think that I came across the same problem, but I somehow fixed it without knowing how I did so.

NBrick67Author
Associate II
September 6, 2023

With TIM2 configured before TIM8 the CEN bit of TIM2 CR1 gets set when TIM8 updates it's EGR:

 /* Generate an update event to reload the Prescaler
 and the repetition counter (only for advanced timer) value immediately */
 TIMx->EGR = TIM_EGR_UG;

 It seems it is important to configure your timers in the reverse order of any triggers between them.