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 Children
  • That fixed the issue!

    However now I get another error related to pin controls:

    /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;
    	};
    };
    
    &qdec {
    	status = "okay";
    	led-pre = <0>;
    	steps = <24>;
    	pinctrl-0 = <&qdec_default>;
    };
    
    &pinctrl {
    	qdec_default: qdec_default {
    		group1 {
    			psels = <NRF_PSEL(QDEC_A, 0, 30)>,
    					<NRF_PSEL(QDEC_B, 0, 29)>;
    		};
    	};
    };

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

  • Try setting this in prj.conf

    CONFIG_QDEC_NRFX=y

  • 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

  • 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'

Related