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:

/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 {
compatible = "nordic,nrf-qdec";
reg = <0x0 1>;
interrupts = <18 NRF_DEFAULT_IRQ_PRIORITY>;
pinctrl-0 = <&qdec0_default>;
led-pre = <0>;
steps = <24>;
interrupt-parent = <&nvic>;
};
};

&pinctrl {
qdec0_default: qdec0_default{
group1{
psels = <NRF_PSEL(QDEC_A, 0, 30)>,
<NRF_PSEL(QDEC_B, 0, 29)>;
};
};
};

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 Reply
  • I cannot add it as it needs dependencies that cannot be added:

    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)
    

    I put the errors as comments

Children
  • Try adding this in the overlay:

    &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)>,
    					<NRF_PSEL(QDEC_B, 0, 29)>;
    		};
    	};
    };

  • Now I get:

    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'

  • 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`.

Related