Skip to main content
Associate III
Mar 28, 2024 12:29 PM UTC
Question

STM32H755 Quadrature Encoder direction Bit

Hello all,

I am attempting to read the direction bit and have observed a surprising behaviour. Let’s say my encoder was set to the reverse direction. If I attempt to move the encoder in the opposite direction, the direction bit doesn’t update until I halt the movement.

sarun_0-1711626455738.png

sarun_1-1711626462915.png

just reading the value in the main loop

encoder_direction = (TIM3->CR1 & 0x10) >> 4;

Basically direction is not being updated on the move,  Is this the intended behaviour of this bit?

This topic has been closed for replies.

4 replies

Uwe Bonnes
Chief
Mar 28, 2024 12:46 PM UTC

TIM_CR1_DIR is for normal counter mode and not set in encoder mode.

sarunAuthor
Associate III
Mar 28, 2024 1:01 PM UTC

Hello @Uwe Bonnes The reason i used that bit 

sarun_0-1711630553096.png

As per the description it should be updating. 

Uwe Bonnes
Chief
Mar 28, 2024 4:35 PM UTC

Probably I am wrong. But maybe DIR is only visible internal. Can some ST insider confirm if DIR is set and readable in encoder mode?

sarunAuthor
Associate III
Mar 29, 2024 3:39 AM UTC

@Uwe Bonnes Just to clear any confusion this is already running on my target, I am able to read the the bit but the behaviour is the issue.