I have a project where I need to read the encoder phase A&B to output the pulse so I can drive a motor, I did some research and saw this picture where it is exactly what I wanted to do: output a pulse signal to a gpio pin triggered by the rising and falling edge of both A & B. my setting: using STM32CubeMX: encoder mode TIM2.

Now, can someone point out to me where and how I can output the pulses into a gpio pin? I only want to output the pulses when the encoder is running in a clockwise direction. I now can read the correct encoder value. I tried outputting the signal like this:

             HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, GPIO_PIN_SET);
            HAL_GPIO_WritePin(GPIOB, GPIO_PIN_8, GPIO_PIN_RESET);   

however, the output signal isn't consistent. enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.