QDEC device tree issue

Hello,

I'm trying to run the QDEC example I find in the nRF Connect SDK.

I'm having issues in setting up the device tree:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/dts-v1/;
#include <nordic/nrf52833_qiaa.dtsi>
/ {
model = "Nordic nRF52833 Dongle NRF52833";
compatible = "nordic,nrf52833-dongle-nrf52833";
chosen {
zephyr,console = &uart0;
zephyr,shell-uart = &uart0;
zephyr,uart-mcumgr = &uart0;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
nordic,nrf-qdec = &qdec0;
};
aliases {
qdec0 = &qdec;
};
nrf-qdec@0 {
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The problem is that qdec0 is not found from the C code, even though it is present as an alias in the device tree file:

What is wrong with my device tree?

Thanks

Parents
  • That fixed the issue!

    However now I get another error related to pin controls:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /dts-v1/;
    #include <nordic/nrf52833_qiaa.dtsi>
    / {
    model = "Nordic nRF52833 Dongle NRF52833";
    compatible = "nordic,nrf52833-dongle-nrf52833";
    chosen {
    zephyr,console = &uart0;
    zephyr,shell-uart = &uart0;
    zephyr,uart-mcumgr = &uart0;
    zephyr,sram = &sram0;
    zephyr,flash = &flash0;
    nordic,nrf-qdec = &qdec0;
    };
    aliases {
    qdec0 = &qdec;
    };
    };
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    There is no syntax error in the .dts file, what is the issue?

Reply
  • That fixed the issue!

    However now I get another error related to pin controls:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /dts-v1/;
    #include <nordic/nrf52833_qiaa.dtsi>
    / {
    model = "Nordic nRF52833 Dongle NRF52833";
    compatible = "nordic,nrf52833-dongle-nrf52833";
    chosen {
    zephyr,console = &uart0;
    zephyr,shell-uart = &uart0;
    zephyr,uart-mcumgr = &uart0;
    zephyr,sram = &sram0;
    zephyr,flash = &flash0;
    nordic,nrf-qdec = &qdec0;
    };
    aliases {
    qdec0 = &qdec;
    };
    };
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    There is no syntax error in the .dts file, what is the issue?

Children
  • Try setting this in prj.conf

    CONFIG_QDEC_NRFX=y

  • I cannot add it as it needs dependencies that cannot be added:

    Fullscreen
    1
    2
    3
    4
    5
    6
    CONFIG_SENSOR=y
    CONFIG_PRINTK=y
    CONFIG_QDEC_NRFX=y # Missing dependencies: DT_HAS_NORDIC_NRF_QDEC_ENABLED && HAS_HW_NRF_QDEC0
    CONFIG_DT_HAS_NORDIC_NRF_QDEC_ENABLED=y # Symbol CONFIG_DT_HAS_NORDIC_NRF_QDEC_ENABLED cannot be set (has no prompt)
    CONFIG_HAS_HW_NRF_QDEC0=y # CONFIG_HAS_HW_NRF_QDEC0 cannot be set (has no prompt)
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    I put the errors as comments

  • Try adding this in the overlay:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    &qdec {
    status = "okay";
    led-pre = <0>;
    enable-pin = <4>;
    steps = <24>;
    pinctrl-0 = <&qdec_default>;
    pinctrl-1 = <&qdec_sleep>;
    pinctrl-names = "default", "sleep";
    };
    &pinctrl {
    qdec_default: qdec_default {
    group1 {
    psels = <NRF_PSEL(QDEC_A, 0, 30)>,
    <NRF_PSEL(QDEC_B, 0, 29)>;
    };
    };
    qdec_sleep: qdec_sleep {
    group1 {
    psels = <NRF_PSEL(QDEC_A, 0, 30)>,
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Now I get:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    vers__sensor__qdec_nrfx.a(qdec_nrfx.c.obj): in function `pinctrl_apply_state':
    C:/ncs/v2.4.2/zephyr/include/zephyr/drivers/pinctrl.h:348: undefined reference to `pinctrl_lookup_state'
    c:/ncs/toolchains/31f4403e35/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: zephyr/drivers/sensor/qdec_nrfx/libdrivers__sensor__qdec_nrfx.a(qdec_nrfx.c.obj): in function `pinctrl_apply_state_direct':
    C:/ncs/v2.4.2/zephyr/include/zephyr/drivers/pinctrl.h:329: undefined reference to `pinctrl_configure_pins'
    collect2.exe: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\31f4403e35\opt\bin\cmake.EXE' --build 'c:\F_drive\Ste\DEV\optical_mouse\FW\working_examples\qdec_1\build'
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Fixed.

    The last error message I posted was a clear indication that some source code was missing, in this case related to pin controls.

    Indeed I had to put `CONFIG_PINCTRL=y` into `proj.conf`.