cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 Timer encoder mode with synchronization

MJ_1992
Associate II

I am using STM32H753.

My TIM2 is in Encoder mode, and I give two external signals from my incremental encoder to TIM2_CH1 and TIM2_CH2. My TIM2 is counts perfectly (Up or Down) when I move the encoder clockwise or anticlockwise.

Now i want to syncronize another two timer TIM1 and TIM8 (or any other ) with TIM2. so that when i move encoder Clockwise or Anticlockwise then conunts of all three timers are increase or decrease togather.

 

Is it possible ? How ? 

 

As per Reference Manual Chepter of Timer synchronization, I can connect TRGO internally (For Update Event) to another Timer but will it be work in Encoder mode ? I mean how single line (TRGO) can send increment or decrement data to another timer ?

 

MJ_1992_0-1734619617197.png

 

 

 

4 REPLIES 4
SofLit
ST Employee

Hello,

I don't think you can propagate the increment/decrement behavior between timers. But what is your use case?

Why don't connect the encoder output in parallel to other TIMs channels then?

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.
Karl Yamashita
Lead III

Why would you want two additional timers in sync doing the same thing? If it was possible, the CNT would be the same on all 3 timers and would not benefit you.

If you are trying to do something else using 3 timers in sync, maybe explain in more detail what you're trying to accomplish?

Tips and Tricks with TimerCallback https://www.youtube.com/@eebykarl
If you find my solution useful, please click the Accept as Solution so others see the solution.
MJ_1992
Associate II

@Karl Yamashita and @SofLit  Thanks for your replay.

I need to use other timers for scanning other external Eight Signals with respect to Encoder signals ( As Input capture ) So that i can get encoder count (Or encoder position) at Rissing or Falling Eadge of that Eight Signals.

As others said above, there's no way you can transfer the clock and direction from one timer to other, so you have to look for workarounds.

You certainly can use the remaining two channels of given timer (TIM2) to do the capture.

As suggested by @SofLit above, you can connect several timers in parallel, all of them in encoder mode, so you'd need four timers for the eight input signals. That's not that far fetched and easy to accomplish, but will cost the extra pins.

Another option might be to trigger DMA transfer from TIM2_CNT to memory by the pins. There is some latency involved and that may or may not be an issue in your case. This is traditionally done via timer input capture, too, that capture not performing the capture itself but serving as a DMA trigger; but maybe in your 'H7 there are ways to trigger DMA from pins directly (EXTI), I am not familiar with the 'H7 and its DMAMUX.

JW