i2c communication not working in ncs but working on nrf5 sdk

I have tried all the configs on device tree to make the sensor work reliably, but it fails. Like I have LSM6DSOX as IMU and it works for sometime and then On power on reset , device starts to show as not ready 

device_is_ready(lsm_i2c.bus) this fails.

Providing config files and schematic of the SDA and SCL line-

&i2c0 {
    lsm6dsox: lsm6dsox@6A {
		compatible = "st,lsm6dso";
		reg = <0x6A>;
    };
	stc3117: stc3117@70 {
		compatible = "i2c-device";
		reg = <0x70>;
	};
	mlx60732: mlx60732@3A {
		compatible = "i2c-device";
		reg = <0x3A>;
	};
};

&i2c1 {
	status = "okay";
	maxm86161: maxm86161@62 {
		compatible = "i2c-device";
		reg = <0x62>;
	};
};

And this is pin ctrl config for the same -

/*
 * Copyright (c) 2022 Nordic Semiconductor
 * SPDX-License-Identifier: Apache-2.0
 */

&pinctrl {
	uart0_default: uart0_default {
		group1 {
			psels = <NRF_PSEL(UART_TX, 0, 6)>,
				<NRF_PSEL(UART_RTS, 0, 5)>;
		};
		group2 {
			psels = <NRF_PSEL(UART_RX, 0, 8)>,
				<NRF_PSEL(UART_CTS, 0, 7)>;
			bias-pull-up;
		};
	};

	uart0_sleep: uart0_sleep {
		group1 {
			psels = <NRF_PSEL(UART_TX, 0, 6)>,
				<NRF_PSEL(UART_RX, 0, 8)>,
				<NRF_PSEL(UART_RTS, 0, 5)>,
				<NRF_PSEL(UART_CTS, 0, 7)>;
			low-power-enable;
		};
	};

	uart1_default: uart1_default {
		group1 {
			psels = <NRF_PSEL(UART_RX, 1, 1)>;
			bias-pull-up;
		};
		group2 {
			psels = <NRF_PSEL(UART_TX, 1, 2)>;
		};
	};

	uart1_sleep: uart1_sleep {
		group1 {
			psels = <NRF_PSEL(UART_RX, 1, 1)>,
				<NRF_PSEL(UART_TX, 1, 2)>;
			low-power-enable;
		};
	};

	i2c0_default: i2c0_default {
		group1 {
			psels = <NRF_PSEL(TWIM_SDA, 0, 27)>,
				<NRF_PSEL(TWIM_SCL, 0, 26)>;
			bias-disable;	
		};
	};

	i2c0_sleep: i2c0_sleep {
		group1 {
			psels = <NRF_PSEL(TWIM_SDA, 0, 27)>,
				<NRF_PSEL(TWIM_SCL, 0, 26)>;
			bias-disable;	
			low-power-enable;
		};
	};

	i2c1_default: i2c1_default {
		group1 {
			psels = <NRF_PSEL(TWIM_SDA, 0, 25)>,
				<NRF_PSEL(TWIM_SCL, 0, 24)>;
			bias-disable;	
		};
	};

	i2c1_sleep: i2c1_sleep {
		group1 {
			psels = <NRF_PSEL(TWIM_SDA, 0, 25)>,
				<NRF_PSEL(TWIM_SCL, 0, 24)>;
			bias-disable;
			low-power-enable;
		};
	};

	pwm0_default: pwm0_default {
		group1 {
			psels = <NRF_PSEL(PWM_OUT0, 0, 13)>;
			nordic,invert;
		};
	};

	pwm0_sleep: pwm0_sleep {
		group1 {
			psels = <NRF_PSEL(PWM_OUT0, 0, 13)>;
			low-power-enable;
		};
	};

	spi0_default: spi0_default {
		group1 {
			psels = <NRF_PSEL(SPIM_SCK, 0, 27)>,
				<NRF_PSEL(SPIM_MOSI, 0, 26)>,
				<NRF_PSEL(SPIM_MISO, 0, 29)>;
		};
	};

	spi0_sleep: spi0_sleep {
		group1 {
			psels = <NRF_PSEL(SPIM_SCK, 0, 27)>,
				<NRF_PSEL(SPIM_MOSI, 0, 26)>,
				<NRF_PSEL(SPIM_MISO, 0, 29)>;
			low-power-enable;
		};
	};

	spi1_default: spi1_default {
		group1 {
			psels = <NRF_PSEL(SPIM_SCK, 0, 31)>,
				<NRF_PSEL(SPIM_MOSI, 0, 30)>,
				<NRF_PSEL(SPIM_MISO, 1, 8)>;
		};
	};

	spi1_sleep: spi1_sleep {
		group1 {
			psels = <NRF_PSEL(SPIM_SCK, 0, 31)>,
				<NRF_PSEL(SPIM_MOSI, 0, 30)>,
				<NRF_PSEL(SPIM_MISO, 1, 8)>;
			low-power-enable;
		};
	};

	spi2_default: spi2_default {
		group1 {
			psels = <NRF_PSEL(SPIM_SCK, 0, 19)>,
				<NRF_PSEL(SPIM_MOSI, 0, 20)>,
				<NRF_PSEL(SPIM_MISO, 0, 21)>;
		};
	};

	spi2_sleep: spi2_sleep {
		group1 {
			psels = <NRF_PSEL(SPIM_SCK, 0, 19)>,
				<NRF_PSEL(SPIM_MOSI, 0, 20)>,
				<NRF_PSEL(SPIM_MISO, 0, 21)>;
			low-power-enable;
		};
	};

	qspi_default: qspi_default {
		group1 {
			psels = <NRF_PSEL(QSPI_SCK, 0, 19)>,
				<NRF_PSEL(QSPI_IO0, 0, 20)>,
				<NRF_PSEL(QSPI_IO1, 0, 21)>,
				<NRF_PSEL(QSPI_IO2, 0, 22)>,
				<NRF_PSEL(QSPI_IO3, 0, 23)>,
				<NRF_PSEL(QSPI_CSN, 0, 17)>;
		};
	};

	qspi_sleep: qspi_sleep {
		group1 {
			psels = <NRF_PSEL(QSPI_SCK, 0, 19)>,
				<NRF_PSEL(QSPI_IO0, 0, 20)>,
				<NRF_PSEL(QSPI_IO1, 0, 21)>,
				<NRF_PSEL(QSPI_IO2, 0, 22)>,
				<NRF_PSEL(QSPI_IO3, 0, 23)>;
			low-power-enable;
		};
		group2 {
			psels = <NRF_PSEL(QSPI_CSN, 0, 17)>;
			low-power-enable;
			bias-pull-up;
		};
	};

	spi3_default: spi3_default {
		group1 {
			psels = <NRF_PSEL(SPIM_SCK, 1, 15)>,
				<NRF_PSEL(SPIM_MISO, 1, 14)>,
				<NRF_PSEL(SPIM_MOSI, 1, 13)>;
		};
	};

	spi3_sleep: spi3_sleep {
		group1 {
			psels = <NRF_PSEL(SPIM_SCK, 1, 15)>,
				<NRF_PSEL(SPIM_MISO, 1, 14)>,
				<NRF_PSEL(SPIM_MOSI, 1, 13)>;
			low-power-enable;
		};
	};

};

Strangely there is one more sensor on the same line and that sensor is working properly with this configuration. I have been using the same sensor and same hardware which was working on nrf5 SDK and recently ported the project to NCS 2.2.0.

Please help in resolving this

Parents Reply
  • Thanks for the overview, I think I understand the issue better now.

    I suggest that we try to make LSM6DSOX work alone first, and then move on from there.

    Set CONFIG_SENSOR_LOG_LEVEL_DBG and see if we get any useful information from that.

    Also, if you want, try to debug the file zephyr\drivers\sensor\lsm6dso\lsm6dso.c, and see if you can see what happens there.

    Do you have oscillosocope or logic analyzator traces from the I2C lines? Maybe that could give some hints.

Children
Related