Skip to main content
Visitor II
May 29, 2024
Question

Use rotary encoder on stm32mp157

  • May 29, 2024
  • 1 reply
  • 726 views

 

I'm doing a project, that I need a rotary encoder working on cortex-a7 core of stm32mp157.

I met problem, my rotary encoder can not work. 

This is what I have done:

1. In kernel menuconfig I have config: use rotary encoder as a build-in module;

2. Write dts, and I am sure these gpio not been use anywhere:

    rotary@3 {
        compatible = "rotary-encoder";
        gpios = <&gpioa 0 GPIO_ACTIVE_LOW>, <&gpiog 3 GPIO_ACTIVE_LOW>;
        linux,axis = <6>;
        rotary-encoder,encoding = "gray";
        rotary-encoder,relative-axis;
        status = "okay";
    };
 
In dmesg I can see my roary is started
Jason007_1-1716992523494.png

In /proc/device-tree, I can see the device node

Jason007_1-1716992931386.png

In evtest nothing output, when I turn the knob of encoder.
Jason007_0-1716992396373.png

 

what is the problem, I need your help, thank you!

1 reply

PatrickF
Technical Moderator
May 31, 2024

HI @Jason007 

 

Did you have GPIOs pull-ups on the board ?

Maybe try if internal pull-up is ok by using

(GPIO_ACTIVE_LOW | GPIO_PULL_UP)

 

Alternatively (could reach higher count rate), you could use TIM or LPTIM for this (still need pull-ups).
See https://wiki.stmicroelectronics.cn/stm32mpu/wiki/How_to_use_the_IIO_user_space_interface#How_to_use_the_quadrature_encoder_with_the_sysfs_interface

(need to chose input pins according to Timers inputs possible muxing).

 

Regards,

 

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.NEW ! Sidekick STM32 AI agent, see here