cancel
Showing results for 
Search instead for 
Did you mean: 

Can I set a timer in encoder mode and gated mode simultaneously with the STM32F76ZI?

Dennis Ai
Associate II
Posted on March 09, 2018 at 22:06

I am using STM32Cube to setup my timers.  I would like to have TIM1 in Encoder Mode.  I would like to do two things:

  1. When the counter overflows, I would like to enable TIM2.  If I look through the reference documentation, is it correct to say I can do this by setting (in code) TIM1 to Master Mode: Update (The update event is selected as trigger output), and setting TIM2 to Slave Mode with Trigger Source ITR0?  Is there any reason I can't set Master Mode in STM32Cube?
  2. I would like to enable TIM1 on the rising edge of an external input.  I notice in STM32Cube, if my timer is NOT set to Encoder Mode, I can set TIM1 to Slave Mode: Gated with Trigger Source: ETR1.  However, if my timer IS set to Encoder Mode, I cannot set the Slave Mode.  Therefore, my question is, what's the best way to ensure that TIM1 starts only on an external trigger?  Should I use the CPU to monitor a GPIO pin and then enable TIM1, or is there an alternative, more elegant solution?

Thanks for all of your help.

1 REPLY 1
Posted on March 11, 2018 at 21:59

Is there any reason I can't set Master Mode in STM32Cube?

Cube - as any other library - usually provides support for standard usage scenarios. It's quite unusual to do anything on update in encoder mode - and I'd say, if you want to do that, you are probably mistaken in your problem analysis.

Otherwise I don't see any problem setting TRGO to Update in encoder mode (and then whatever slave mode in the target timer).

However, if my timer IS set to Encoder Mode, I cannot set the Slave Mode. 

Encoder mode *is* one of the slave modes. Read the TIM chapter of RM, concentrate on the description of TIMx_SMCR.

Also, Encoder mode *does* work only on externally supplied signals, why would you want to start it in any particular way?

You may want to tell us what do you want to accomplish.

JW