Skip to main content
MSipo
Senior II
December 12, 2022
Question

Can't capture all rising edges using timer CH3 while using CH1/CH2 as encoder counter. Chip bug?

  • December 12, 2022
  • 2 replies
  • 1186 views

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.

This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
December 12, 2022

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?

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
MSipo
MSipoAuthor
Senior II
December 12, 2022

I'm going to measure the signal with an oscilloscope tomorrow. The signal gives a rising edge for every 4096 count on the encoder.

Tesla DeLorean
Guru
December 12, 2022

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?

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
waclawek.jan
Super User
December 12, 2022

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

MSipo
MSipoAuthor
Senior II
December 12, 2022

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.