cancel
Showing results for 
Search instead for 
Did you mean: 

Counting pulse + direction encoder

APoto.2
Associate

Hello,

I'm trying to read the pulse counter with a timer on STM32H747. The counter produces pulses up to 100KHz on one timer channel and high \ low signal to define the direction.

I tried two approaches.

  1. Reference manual says, as I understand, that such signals are supported out of the box. Section 40.3.22 says "To select Encoder Interface mode write SMS=‘001’ in the TIMx_SMCR register if the counter is counting on TI2 edges only, SMS=’010’ if it is counting on TI1 edges only and SMS=’011’ if it is counting on both TI1 and TI2 edges." But setting it to TI1 only mode still behaves as TI1 & TI2. So, it reads quadrature signal, not pulses.
  2. Then I tried to use the timer in counter mode. It didn't work for me.

My questions are: does encoder mode supports pulse + direction signal, and is there a good example of using a timer in counter mode (mode 1)?

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions

The "Encoder mode" is for quadrature encoders. Timers in 'H7 don't have the direction-step mode (only 'G4 and 'U5 timers support this).

@berendi​ posted here a possible workaround, but you may want to use an undocumented feature or give up a couple of pins.

JW

View solution in original post

2 REPLIES 2

The "Encoder mode" is for quadrature encoders. Timers in 'H7 don't have the direction-step mode (only 'G4 and 'U5 timers support this).

@berendi​ posted here a possible workaround, but you may want to use an undocumented feature or give up a couple of pins.

JW

Thank you. Very interesting links.