LIS2DH12 device is not ready issue

Hi,

I have added .overlay file as below mentioned 

&spi0 {
    status = "okay";   
    acc_lis2dh_spi: lis2dh@0 {
        compatible = "st,lis2dh";
        reg = <0>;
        spi-max-frequency = <10000000>;
        irq-gpios = <&gpio1 1 2>;
        label = "LIS2DH";
    };
};

And i have added my prj.config file as mentioned below.

CONFIG_STDOUT_CONSOLE=y
CONFIG_SPI=y
CONFIG_SENSOR=y
CONFIG_CBPRINTF_FP_SUPPORT=y
CONFIG_LIS2DH=y
CONFIG_LIS2DH_TRIGGER_GLOBAL_THREAD=y
CONFIG_PRINTK=y

And I am facing issue is
Device LIS2DH is not ready with nrf52840dk.

So, can you please, help me with it.

Thanks & Regards,

Shaik Jareena.

Parents
  • Hi,

    Where do you specify the SPI pins such as SCLK, CS, MOSI, MISO?

    regards

    Jared 

  • Hi,

    I have added this pins like below mentioned and can you please, find this below.

    &spi1 {
        status = "okay";
        compatible = "nordic,nrf-spi";
        sck-pin = <0x23>;
        mosi-pin = <0x24>;
        miso-pin = <0x25>;
        cs-gpios = <&gpio1 1 GPIO_ACTIVE_LOW>;
        
        acc_lis2dh_spi: lis2dh@0 {
            compatible = "st,lis2dh";
            reg = <0>;
            spi-max-frequency = <10000000>;
            irq-gpios = <&gpio1 2 1>;
            label = "LIS2DH";
        };
    };
    And after this also, I am facing same issue device is not ready issue.
    Thanks & Regards,
    Shaik Jareena.
  • Hi,

    I forgot to mention that when I am adding like this below 

    &spi1 {
        status = "okay";
        compatible = "nordic,nrf-spi";
        sck-pin = <0x23>;
        mosi-pin = <0x24>;
        miso-pin = <0x25>;
        cs-gpios = <&gpio1 1 GPIO_ACTIVE_LOW>;
        
        acc_lis2dh_spi: lis2dh@0 {
            compatible = "st,lis2dh";
            reg = <0>;
            spi-max-frequency = <10000000>;
            irq-gpios = <&gpio1 2 1>;
            label = "LIS2DH";
        };
    };

    I am facing cmake errors and i am not able to build even 

    [{
    	"resource": "/c:/ncs/v2.5.1/zephyr/cmake/modules/dts.cmake",
    	"owner": "nrf-connect",
    	"severity": 8,
    	"message": "CMake Error at C:/ncs/v2.5.1/zephyr/cmake/modules/dts.cmake:279 (message):",
    	"source": "cmake",
    	"startLineNumber": 279,
    	"startColumn": 1,
    	"endLineNumber": 279,
    	"endColumn": 2147483647
    }]

    So, If i solve this only I can build my lis2dh12 application. So, can you please provide the correct .overlay file for nrf52840.

    Your help is more Appreciable.

    Thanks & Regards,

    Shaik Jareena.

  • What build error do you get?

    regards

    Jared 

  • Hi,

    I am facing below mentioned errors. Can you please, help me with it.

    Building lis2dh
    C:\Windows\system32\cmd.exe /d /s /c "west build --build-dir c:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build c:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh"

    [0/1] Re-running CMake...
    Loading Zephyr default modules (Zephyr base (cached)).
    -- Application: C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh
    -- CMake version: 3.20.5
    -- Cache files will be written to: C:/ncs/v2.5.1/zephyr/.cache
    -- Zephyr version: 3.4.99 (C:/ncs/v2.5.1/zephyr)
    -- Found west (found suitable version "1.1.0", minimum required is "0.14.0")
    -- Board: nrf52840dk_nrf52840
    -- Found host-tools: zephyr 0.16.1 (C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.16.1 (C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk)
    -- Found BOARD.dts: C:/ncs/v2.5.1/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
    -- Found devicetree overlay: C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/nrf52840dk_nrf52840.overlay
    -- Found devicetree overlay: nrf52840dk_nrf52840.overlay
    devicetree error: 'sck-pin' appears in /soc/spi@40004000 in C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/zephyr/zephyr.dts.pre, but is not declared in 'properties:' in C:/ncs/v2.5.1/zephyr/dts/bindings\spi\nordic,nrf-spi.yaml
    -- In: C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/zephyr, command: C:/ncs/toolchains/c57af46cb7/opt/bin/python.exe;C:/ncs/v2.5.1/zephyr/scripts/dts/gen_defines.py;--dts;C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/zephyr/zephyr.dts.pre;--dtc-flags;'-Wno-unique_unit_address_if_enabled';--bindings-dirs;C:/ncs/v2.5.1/nrf/dts/bindings;C:/ncs/v2.5.1/zephyr/dts/bindings;--header-out;C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/zephyr/include/generated/devicetree_generated.h.new;--dts-out;C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/zephyr/zephyr.dts.new;--edt-pickle-out;C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/zephyr/edt.pickle;--vendor-prefixes;C:/ncs/v2.5.1/nrf/dts/bindings/vendor-prefixes.txt;--vendor-prefixes;C:/ncs/v2.5.1/zephyr/dts/bindings/vendor-prefixes.txt
    CMake Error at C:/ncs/v2.5.1/zephyr/cmake/modules/dts.cmake:279 (message):
    gen_defines.py failed with return code: 1
    Call Stack (most recent call first):
    C:/ncs/v2.5.1/zephyr/cmake/modules/zephyr_default.cmake:129 (include)
    C:/ncs/v2.5.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
    C:/ncs/v2.5.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:97 (include_boilerplate)
    CMakeLists.txt:8 (find_package)


    -- Configuring incomplete, errors occurred!
    See also "C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/CMakeFiles/CMakeOutput.log".
    See also "C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/CMakeFiles/CMakeError.log".
    ninja: error: rebuilding 'build.ninja': subcommand failed
    FAILED: build.ninja
    C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.exe --regenerate-during-build -SC:\ncs\v2.5.1\zephyr\samples\sensor\lis2dh -BC:\ncs\v2.5.1\zephyr\samples\sensor\lis2dh\build
    FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.EXE' --build 'c:\ncs\v2.5.1\zephyr\samples\sensor\lis2dh\build'

    * The terminal process terminated with exit code: 1.
    * Terminal will be reused by tasks, press any key to close it.

    * Executing task: nRF Connect: Build [clean]: lis2dh/build (active)

    Building lis2dh
    C:\Windows\system32\cmd.exe /d /s /c "west build -t clean --build-dir c:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build"

    -- west build: running target clean
    [0/1] Re-running CMake...
    Loading Zephyr default modules (Zephyr base (cached)).
    -- Application: C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh
    -- CMake version: 3.20.5
    -- Cache files will be written to: C:/ncs/v2.5.1/zephyr/.cache
    -- Zephyr version: 3.4.99 (C:/ncs/v2.5.1/zephyr)
    -- Found west (found suitable version "1.1.0", minimum required is "0.14.0")
    -- Board: nrf52840dk_nrf52840
    -- Found host-tools: zephyr 0.16.1 (C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.16.1 (C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk)
    -- Found BOARD.dts: C:/ncs/v2.5.1/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
    -- Found devicetree overlay: C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/nrf52840dk_nrf52840.overlay
    -- Found devicetree overlay: nrf52840dk_nrf52840.overlay
    devicetree error: 'sck-pin' appears in /soc/spi@40004000 in C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/zephyr/zephyr.dts.pre, but is not declared in 'properties:' in C:/ncs/v2.5.1/zephyr/dts/bindings\spi\nordic,nrf-spi.yaml
    -- In: C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/zephyr, command: C:/ncs/toolchains/c57af46cb7/opt/bin/python.exe;C:/ncs/v2.5.1/zephyr/scripts/dts/gen_defines.py;--dts;C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/zephyr/zephyr.dts.pre;--dtc-flags;'-Wno-unique_unit_address_if_enabled';--bindings-dirs;C:/ncs/v2.5.1/nrf/dts/bindings;C:/ncs/v2.5.1/zephyr/dts/bindings;--header-out;C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/zephyr/include/generated/devicetree_generated.h.new;--dts-out;C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/zephyr/zephyr.dts.new;--edt-pickle-out;C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/zephyr/edt.pickle;--vendor-prefixes;C:/ncs/v2.5.1/nrf/dts/bindings/vendor-prefixes.txt;--vendor-prefixes;C:/ncs/v2.5.1/zephyr/dts/bindings/vendor-prefixes.txt
    CMake Error at C:/ncs/v2.5.1/zephyr/cmake/modules/dts.cmake:279 (message):
    gen_defines.py failed with return code: 1
    Call Stack (most recent call first):
    C:/ncs/v2.5.1/zephyr/cmake/modules/zephyr_default.cmake:129 (include)
    C:/ncs/v2.5.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
    C:/ncs/v2.5.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:97 (include_boilerplate)
    CMakeLists.txt:8 (find_package)


    -- Configuring incomplete, errors occurred!
    See also "C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/CMakeFiles/CMakeOutput.log".
    See also "C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/CMakeFiles/CMakeError.log".
    FAILED: build.ninja
    C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.exe --regenerate-during-build -SC:\ncs\v2.5.1\zephyr\samples\sensor\lis2dh -BC:\ncs\v2.5.1\zephyr\samples\sensor\lis2dh\build
    ninja: error: rebuilding 'build.ninja': subcommand failed
    FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.EXE' --build 'c:\ncs\v2.5.1\zephyr\samples\sensor\lis2dh\build' --target clean

    * The terminal process terminated with exit code: 1.
    * Terminal will be reused by tasks, press any key to close it.

    * Executing task: nRF Connect: Build: lis2dh/build (active)

    Building lis2dh
    C:\Windows\system32\cmd.exe /d /s /c "west build --build-dir c:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build c:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh"

    [0/1] Re-running CMake...
    Loading Zephyr default modules (Zephyr base (cached)).
    -- Application: C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh
    -- CMake version: 3.20.5
    -- Cache files will be written to: C:/ncs/v2.5.1/zephyr/.cache
    -- Zephyr version: 3.4.99 (C:/ncs/v2.5.1/zephyr)
    -- Found west (found suitable version "1.1.0", minimum required is "0.14.0")
    -- Board: nrf52840dk_nrf52840
    -- Found host-tools: zephyr 0.16.1 (C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.16.1 (C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk)
    -- Found BOARD.dts: C:/ncs/v2.5.1/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
    -- Found devicetree overlay: C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/nrf52840dk_nrf52840.overlay
    -- Found devicetree overlay: nrf52840dk_nrf52840.overlay
    devicetree error: 'sck-pin' appears in /soc/spi@40004000 in C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/zephyr/zephyr.dts.pre, but is not declared in 'properties:' in C:/ncs/v2.5.1/zephyr/dts/bindings\spi\nordic,nrf-spi.yaml
    -- In: C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/zephyr, command: C:/ncs/toolchains/c57af46cb7/opt/bin/python.exe;C:/ncs/v2.5.1/zephyr/scripts/dts/gen_defines.py;--dts;C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/zephyr/zephyr.dts.pre;--dtc-flags;'-Wno-unique_unit_address_if_enabled';--bindings-dirs;C:/ncs/v2.5.1/nrf/dts/bindings;C:/ncs/v2.5.1/zephyr/dts/bindings;--header-out;C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/zephyr/include/generated/devicetree_generated.h.new;--dts-out;C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/zephyr/zephyr.dts.new;--edt-pickle-out;C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/zephyr/edt.pickle;--vendor-prefixes;C:/ncs/v2.5.1/nrf/dts/bindings/vendor-prefixes.txt;--vendor-prefixes;C:/ncs/v2.5.1/zephyr/dts/bindings/vendor-prefixes.txt
    CMake Error at C:/ncs/v2.5.1/zephyr/cmake/modules/dts.cmake:279 (message):
    gen_defines.py failed with return code: 1
    Call Stack (most recent call first):
    C:/ncs/v2.5.1/zephyr/cmake/modules/zephyr_default.cmake:129 (include)
    C:/ncs/v2.5.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
    C:/ncs/v2.5.1/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:97 (include_boilerplate)
    CMakeLists.txt:8 (find_package)


    -- Configuring incomplete, errors occurred!
    See also "C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/CMakeFiles/CMakeOutput.log".
    See also "C:/ncs/v2.5.1/zephyr/samples/sensor/lis2dh/build/CMakeFiles/CMakeError.log".
    FAILED: build.ninja
    C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.exe --regenerate-during-build -SC:\ncs\v2.5.1\zephyr\samples\sensor\lis2dh -BC:\ncs\v2.5.1\zephyr\samples\sensor\lis2dh\build
    ninja: error: rebuilding 'build.ninja': subcommand failed
    FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.EXE' --build 'c:\ncs\v2.5.1\zephyr\samples\sensor\lis2dh\build'

    * The terminal process terminated with exit code: 1.
    * Terminal will be reused by tasks, press any key to close it.

    Thanks & Regards,

    Shaik Jareena.

  • Hi,

    You have to use pin ctrl when you add the pins, for example in the JESD216 sample:

    And the board file for nrf52840dk_nrf52840-pinctrl.dtsi

    regards

    Jared

  • Hi,

    Thank you for your response, I have one doubt about pin connections now I have to provide the pin connections according to the LIS2DH12 and nRF52840 pins. So, I have to change the pins If I am using JES2D16 reference sample but I do not have schematic of LIS2DH12+nRF52840 pin connections, I searched for it in Nordic website but i did not find it.

    If you have schematic of LIS2DH12+nRF52840 pin connections schematic, can you please, share with me.

    Thanks & Regards,

    Shaik Jareena.

Reply
  • Hi,

    Thank you for your response, I have one doubt about pin connections now I have to provide the pin connections according to the LIS2DH12 and nRF52840 pins. So, I have to change the pins If I am using JES2D16 reference sample but I do not have schematic of LIS2DH12+nRF52840 pin connections, I searched for it in Nordic website but i did not find it.

    If you have schematic of LIS2DH12+nRF52840 pin connections schematic, can you please, share with me.

    Thanks & Regards,

    Shaik Jareena.

Children
  • Hi,

    I provided the previous sample so that you can see how you should setup miso, sclk, and mosi using pinctrl. The CS pin is setup as a node by itself in the SPI node structure. I'm not sure what schematic you're asking for. The LIS2DH12 is not embedded on the nRF52840 DK. What pins have you physically connected the LIS2DH12 to the nRF52840 on?

    regards

    Jared 

  • Hi,

    I am connecting the pins as below mentioned in .overlay file, can you please, find this below.

    8306.nrf52840dk_nrf52840.overlay

    Can you please, find connections between LIS2DH12 sensor and nRF52840 module connections.

    LIS2DH12 JP2 header pins------------------------->nRF52840 pins

    JP1.1 PIN(VDD)------------------------------------------------->VDD

    JP2.22PIN(SDO)------------------------------------------------>P0.20

    JP2.21PIN(SDI)-------------------------------------------------->P0.21

    JP2.20PIN(SCL)------------------------------------------------->P0.19

    JP2.19PIN(CS)--------------------------------------------------->P1.12

    JP2.14PIN(INT1)------------------------------------------------->P1.02

    JP2.13PIN(GND)------------------------------------------------->GND

    After giving connections like this, I am getting this error as mentioned below marked in red color.

    So, can you please help me with this, Your help is more appreciable.

    Thanks & Regards,

    Shaik Jareena.

  • Hi,

    If you probe the SCLK, and then restart you program. Do you see any activity on the SCLK pin when the system initialize? Sometimes the driver tries to initialize the slave during init, if the slave doesn't respond then it might result in your error message,

    regards

    Jared 

  • Hi,

    I am getting this waveforms without connecting any pins and after connecting by pressing the reset button i am getting one clock like this below.

    i think it will not work by connecting my spi SCLK, MISO, MOSI and CS pins are p1.15,p1.14,p1.13 and p1.12 pins as per my schematic these are configured in spi3 in .dts file by using these pins and p1.02 as interrupt pin i have configures then also it is showing device is not ready only pin configurations I am suspecting because if hardware fault of sensor then it will show device is not found but device lis2dh12 gets found but not ready. So, in my .overlay file configuration only I am suspecting.

    I got one thing here any GPIO pin can be used for spi and interrupt pin and it is based on your board configuration only nrf52840dk.So, can you please, suggest which pins i need to configure for spi and Interrupt pin except QSPI pins.

    If any mistakes did you find in my .overlay file can you please, suggest.

    If possible can you please share i2c .overlay file by this I can know my sensor is working.

    Thanks & Regards,

    Shaik Jareena.

  • Hi,

    Jareena said:

    I am getting this waveforms without connecting any pins and after connecting by pressing the reset button i am getting one clock like this below.

    That doesn't look like a SCLK signal. 

    One easy way to see if the overlay has been applied correctly is to build your application and open the Devicetree GUI. You should then be able to see that the SPI node has been assigned to the specified pins. For example, when I build the SPIM nonblocking sample, and open the devicetree GUI, I see this:

    Can you try the same and confirm?

    regards

    Jared 

Related