2024-12-19 06:51 AM - edited 2024-12-19 06:52 AM
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 ?
Solved! Go to Solution.
2024-12-20 12:23 AM
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
2024-12-19 08:58 AM - edited 2024-12-19 09:00 AM
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?
2024-12-19 11:38 AM
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?
2024-12-19 09:08 PM - edited 2024-12-19 09:13 PM
@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.
2024-12-20 12:23 AM
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