QDEC sample code from zephyr is not running on nrf52840dk

I am using a rotary encoder with nrf52840dk and I am confused about how to run sample QDEC code from zephyr/sample/sensor/qdec on nrf52840dk.

I got this error when i tried to directly build the code for nrf52840

I tried to add an overlay file to add qdec0 in this project. It was compulsory to add reg and interrupts parameters. 

&{/} {
    qdec0: qdec0{
        compatible="nordic,nrf-qdec";
        a-pin = <38>;
        b-pin = <39>;
        enable-pin = <32>;
        led-pin = <13>;
        led-pre = <0>;
        steps = <20>;
        reg = <0x000f8000 0x00008000>;
        interrupts = <&gpio0>;
    };
    
    aliases {
        qdec0=&qdec;
    };
};

 C

Parents
  • Hello,

    qdec0 is not set in aliases. There is no 'qdec' as subnode in the device tree. 

    Thanks.

    Best Regards,

    Kazi Afroza Sultana

  • Hii, thanks for replying........I tried it, but i still got an error,

    -- Found BOARD.dts: /home/akashi/zephyrproject/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
    -- Found devicetree overlay: /home/akashi/zephyrproject/zephyr/samples/sensor/qdec/boards/nrf52840dk_nrf52840.overlay
    devicetree error: Label 'qdec0' appears on /[email protected] and on /soc/[email protected]
    -- In: /home/akashi/zephyrproject/zephyr/samples/sensor/qdec/build/zephyr, command: /home/akashi/ncs/toolchains/v2.1.1/usr/local/bin/python3.8;/home/akashi/zephyrproject/zephyr/scripts/dts/gen_defines.py;--dts;/home/akashi/zephyrproject/zephyr/samples/sensor/qdec/build/zephyr/zephyr.dts.pre;--dtc-flags;'-Wno-unique_unit_address_if_enabled';--bindings-dirs;/home/akashi/zephyrproject/zephyr/dts/bindings;--header-out;/home/akashi/zephyrproject/zephyr/samples/sensor/qdec/build/zephyr/include/generated/devicetree_generated.h.new;--dts-out;/home/akashi/zephyrproject/zephyr/samples/sensor/qdec/build/zephyr/zephyr.dts.new;--edt-pickle-out;/home/akashi/zephyrproject/zephyr/samples/sensor/qdec/build/zephyr/edt.pickle;--vendor-prefixes;/home/akashi/zephyrproject/zephyr/dts/bindings/vendor-prefixes.txt
    CMake Error at /home/akashi/zephyrproject/zephyr/cmake/modules/dts.cmake:231 (message):
      gen_defines.py failed with return code: 1
    Call Stack (most recent call first):
      /home/akashi/zephyrproject/zephyr/cmake/modules/zephyr_default.cmake:108 (include)
      /home/akashi/zephyrproject/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
      /home/akashi/zephyrproject/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
      CMakeLists.txt:4 (find_package)
    
    
    -- Configuring incomplete, errors occurred!
    FATAL ERROR: command exited with status 1: /home/akashi/ncs/toolchains/v2.1.1/usr/local/bin/cmake -DWEST_PYTHON=/home/akashi/ncs/toolchains/v2.1.1/usr/local/bin/python3.8 -B/home/akashi/zephyrproject/zephyr/samples/sensor/qdec/build -GNinja -DBOARD=nrf52840dk_nrf52840 -DNCS_TOOLCHAIN_VERSION:STRING=NONE -DCONF_FILE:STRING=/home/akashi/zephyrproject/zephyr/samples/sensor/qdec/prj.conf -DDTC_OVERLAY_FILE:STRING=/home/akashi/zephyrproject/zephyr/samples/sensor/qdec/boards/nrf52840dk_nrf52840.overlay -DBOARD_ROOT:STRING=/home/akashi/zephyrproject/zephyr/samples/sensor/qdec -S/home/akashi/zephyrproject/zephyr/samples/sensor/qdec

    i did some research online and then tried implementing this

    &{/}{
        aliases {
            qdec0=&qdec;
        };
    };
    
    &qdec {
        status = "okay";
        a-pin = < 38 >;
        b-pin = < 39 >;
        enable-pin = < 32 >;
        led-pin = < 13 >;
        led-pre = < 0 >;
        steps = < 20 >;
    };

    Now i'm getting this error

  • Hello,

    You have to add  pinctrl qdec node in the device tree. You need to add this in device tree:

    pinctrl-0 = <&qdec_default>;
        pinctrl-1 = <&qdec_sleep>;
        pinctrl-names = "default", "sleep";

    then,

    https://github.com/nrfconnect/sdk-nrf/blob/main/boards/arm/nrf52840gmouse_nrf52840/nrf52840gmouse_nrf52840-pinctrl.dtsi#L70 

    sdk-nrf/nrf52840gmouse_nrf52840.dts at main · nrfconnect/sdk-nrf (github.com) 

Reply Children
No Data
Related