Skip to main content
Visitor II
March 11, 2024
Question

STM32F407G Disc: TIM input encoder mode

  • March 11, 2024
  • 4 replies
  • 1518 views

Good afternoon community,
I am trying to implement the Input Encoder in 
STM32F407G Discovery board.
I implement all things, but I am not able to generate desired the output from the board.
I get counter/count/position value as zero.

MG1_0-1710159725167.png

 


Can you please help me to implement the Input encoder?
Here is code for your reference, if any reference code you have then please provide me.
Thank you.

    This topic has been closed for replies.

    4 replies

    Super User
    March 11, 2024

    > void hal_tim_IC_CaptureCallback(TIM_HandleTypeDef *htim)

    The correct callback function is HAL_TIM_IC_CaptureCallback. Function names are case sensitive.

    The "position" variable should probably be defined as volatile if it will be accessed in the main thread.

    If that doesn't work, ensure the pin assignment is correct and ensure the signal is making its way to your board.

    MG1Author
    Visitor II
    March 11, 2024

    Thank you team,
    I change all things as you say, 
    But still i face issue about it.

    MG1_0-1710161566700.png

    I change the Phase value but still it is show same value "2". in both variable,
    and position value is not updating. Can you please help out.

    MG1Author
    Visitor II
    March 12, 2024

    Good afternoon community,
    I did not get any response from your side of my above query.
    I have changed all things as you said in last response.
    Please taking care of it.
    Thank you.

    Super User
    March 12, 2024

    I would recheck your wiring. Use a logic analyzer to verify the signals are as you think they are. I can't do this part for you.

    (Note that waiting 24 hours for a response should be acceptable on a forum that provides free assistance. Be patient and appreciative for best results, not needy.)