cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 Timer Encoder mode delayed by 400ms

Nv7
Associate II

I am using two quadrature encoders through the STM32F411CEU6 timer encoder mode. Here is the graph for one of their CNT values:

Jfkd5b2C

As you can see, it takes about 400ms to update the value, but when it does, it seems accurate. How can I make it so that it doesn't do this? Timer settings (the same for both):

MgN1v9pB

The PLL is at 98 MHz and it says the peripheral clocks are at 48 MHz, although I'm not sure if that's the right number to read. I've tried changing:

- Encoder Mode
- Input Filter
- Some values of the Trigger Output Parameters, although not all of them

 

I am positive that the encoders are hooked up correctly and I took a look with the oscilloscope and the signal looks good. I'm simply plotting htim3.Instance->CNT to make this chart.

1 ACCEPTED SOLUTION

Accepted Solutions
Nv7
Associate II

Wow, I was using if (HAL_GetTick() % 50 == 0) to try to print every 50ms, but it turns out that doesn't work? I'm not sure why because I know the loop is running at much higher than 1000Hz but now that I switched to properly printing it works!

View solution in original post

2 REPLIES 2
TDK
Guru

The encoder is a hardware state machine. Its architecture precludes the possibility of a large delay. More likely to be an issue with your data transfer.

> I'm simply plotting htim3.Instance->CNT to make this chart.

How are you obtaining the values of TIM3->CNT? Why do the values jump? Perhaps you are using UART and the values are getting buffered/lost.

If you feel a post has answered your question, please click "Accept as Solution".
Nv7
Associate II

Wow, I was using if (HAL_GetTick() % 50 == 0) to try to print every 50ms, but it turns out that doesn't work? I'm not sure why because I know the loop is running at much higher than 1000Hz but now that I switched to properly printing it works!