LSM6DSL is failing on custom board with NRF5340soc

Hi ,

I am trying to integrate LSM6DSL to BL5340 module(laird connectivity) through SPI but I am getting failed on initialization. I am noob to NRF so could someone please help to resolve it.

Thanks in advance

/{
alaises{
imusensor         = &imu_sensor;
};
};

&spi4 {
    compatible = "nordic,nrf-spim";
    status = "okay";
    pinctrl-0 = <&spi4_default>;
    pinctrl-1 = <&spi4_sleep>;
    pinctrl-names = "default","sleep";
    cs-gpios = <&gpio0 11 0>;
    /* IMU Sensor 6 Axis: ST LSM6DSL */
	imu_sensor: lsm6dsl@0 {       
		compatible = "st,lsm6dsl";
        status = "okay";
		reg = <0>; 
		irq-gpios = <&gpio0 2 GPIO_ACTIVE_LOW>;
		spi-max-frequency = <10000000>;
	};
};

/* The devicetree node identifier for the "imusensor" alias. */
#define IMU_SENSOR	DT_ALIAS(imusensor)

static const struct device *const imu_dev = DEVICE_DT_GET(IMU_SENSOR);

void imu_init(void) {

	LOG_DBG("%s ", imu_dev->name);

    /* Check if device is initialized correctly. */
	if (!device_is_ready(imu_dev)) {
        /* Not ready, do not use */
		LOG_DBG("IMU device init fail.");
        return;
	}
    
    LOG_DBG("%s IMU Sensor found", imu_dev->name);
}

Parents Reply Children
  • Hi,

    Thanks for the response. Here I attached the thinks needed.

    Which version of NCS are you using?

    I am using NCS V2.5.2 

    When you say it fails, which error do you get?

    /* Check if device is initialized correctly. */
    	if (!device_is_ready(imu_dev)) {
            /* Not ready, do not use */
    		LOG_DBG("IMU device init fail.");
            return;
    	}

    device_is_ready is getting failed 

    Please also provide the prj.conf

    # ------------------------SPI--------------
    CONFIG_SPI=y
    # ---------------------------For IMU LSM6DSL----------------
    CONFIG_SENSOR=y
    CONFIG_LSM6DSL=y
    

  • Thanks

    Could you try the lsm6dsl sample just to see if it works as expected? You can also try to add 

    CONFIG_LSM6DSL_TRIGGER_GLOBAL_THREAD=y and 
    # Enable GPIO
    CONFIG_GPIO=y
    As I don't see anything wrong, can you draw me the wiring? 
    Regards
    Runar
  • Thanks for the input,

    I followed the example but still ended up on same error

    Thanks 

    S.M

  • Hello,

    I suggest to connect a logic analyzer to the spi pins and irq, to see what data is actually sent/received. Just to check if it looks okey (clock toggle as expected, chip select go low, data on miso/mosi etc). Maybe some of the pins are not connected or setup correctly, maybe the sensor is not working/powered as expected.

    I notice you are using gpio port0 pin2, which overlap with nfc, so make sure you do the following in the overlay file:

    &uicr {
        nfct-pins-as-gpios;
    };

    Also, it's spelled aliases, in case that can be part of the problem.

    Kenneth

  • Hi,

    I suggest to connect a logic analyzer to the spi pins and irq, to see what data is actually sent/received. Just to check if it looks okey (clock toggle as expected, chip select go low, data on miso/mosi etc). Maybe some of the pins are not connected or setup correctly, maybe the sensor is not working/powered as expected.

    sorry that provisions are not available in our board

    I notice you are using gpio port0 pin2, which overlap with nfc, so make sure you do the following in the overlay file:

    &uicr {
        nfct-pins-as-gpios;
    };

    Thanks for the input I tried but facing same error

    Also, it's spelled aliases, in case that can be part of the problem.

    Sorry that's my typo mistake in overlay it was fine

    Thanks

    S.M

Related