2022-12-12 09:58 AM
I'm using an STM32F429ZI (NUCLEO-F429ZI)
I have setup Timer 1 CH1/CH2 in encoder mode TI1 and TI2.
I have also setup CH3 as input capture a rising edge. I want to capture the encoder counter every time I have a rising edge on CH3. But I have trouble catching all the rising edges. I can see them on my logic analyzer but often the STM32 misses to capture all of them.
I then tried to configure a GPIO pin to capture the rising edge using an external interrupt. And then manually capture the encoder counter inside the interrupt. Looks like this works.
But why can't I do this using CH3 on the timer? Am I missing something, chip bug?
I haven't measured the rising edge signal yet, so I don't know if it is a problem there.
2022-12-12 10:11 AM
A signal on CH3 should allow you to latch CNT into CCR3. The count's going to depend on the quadrature input. Signal placement, might want to use a 32-bit free-running counter.
Solid grounds, inputs pulled-up? Signals CMOS, or Open Collector?
What do the signals look like on a scope? Clear edges, no bounce?
What kind of frequency?
2022-12-12 10:18 AM
I'm going to measure the signal with an oscilloscope tomorrow. The signal gives a rising edge for every 4096 count on the encoder.
2022-12-12 10:26 AM
So an Index / Top-Dead-Center type third signal?
Are you using the full 16-bit range of the timer?
Any setting of ClockDiv or Input Prescalers?
2022-12-12 10:28 AM
What's the system/timer frequency and what is the frequency/period of input signal on CH3?
> STM32 misses to capture all of them.
How do you observe that, exactly?
Read out and check/post TIM registers content.
JW
2022-12-12 10:46 AM
I have a timer capture callback that reads the captured values and places them into an array. I can for example see more than one pulse on my logic analyzer but software has only captured one value to the array. And if I examine the TIM1 registers I can see that the latest captured value in my array is the same as in the TIM1 capture register. I will investigate further tomorrow.
2022-12-12 10:51 AM
The encoder is connected to a motor that software can control. Yes, it's an index puls (8 per turn). And I also have a center signal (from an optical sensor) that I use for initial centering (but it isn't as precise as the index pulses). At optical center I reset the timer counter to 0. From there I can count right or left (32767 to -32768). Then I search for the index pulses to again calibrate the position more accurately.