Skip to main content
Graduate II
March 28, 2024
Question

STM32H755 Quadrature Encoder direction Bit

  • March 28, 2024
  • 3 replies
  • 1182 views

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.

    3 replies

    Graduate II
    March 28, 2024

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

    sarunAuthor
    Graduate II
    March 28, 2024

    Hello @Uwe Bonnes The reason i used that bit 

    sarun_0-1711630553096.png

    As per the description it should be updating. 

    Graduate II
    March 28, 2024

    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
    Graduate II
    March 29, 2024

    @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.