IMU sensor on DWM3001CDK

Hello.

I need to read IMU data from LIS2DH12 of nrf 52833 which is in DWM3001CDK. But nothing I do initializes sensor... i always receive

<err> lis2dh: Failed to read chip id.

I tried everything on internet, almost every sample, every solution to similiar problem etc... nothing.. at this point im starting to think HW is at fault...

	int err_code = 0;

	const nrfx_twim_config_t twi_config = {
		.scl_pin                = 36,
		.sda_pin                = 24,
		.frequency          = NRF_TWIM_FREQ_100K,
		.interrupt_priority = 0,
		.hold_bus_uninit     = false
	 };

	//err_code = nrfx_twim_init(&m_twi, &twi_config, NULL, NULL);

	nrfx_twim_enable(&m_twi);
	k_sleep(K_MSEC(10));
	uint8_t who_am_i = 5;
	uint8_t who_am_i2 = 6;
	nrfx_twim_xfer_desc_t data = NRFX_TWIM_XFER_DESC(NRFX_TWIM_XFER_RX, 0x19, &who_am_i, 1, &who_am_i2, 1);
	err_code = nrfx_twim_xfer(&m_twi, &data, 0);
	k_sleep(K_MSEC(10));

	LOG_ERR("IMU %d - %X - %X", err_code, who_am_i, who_am_i2);

	k_sleep(K_MSEC(10));

	//const struct device *const sensor = DEVICE_DT_GET_ANY(DT_NODELABEL(lis2dh12));
	const struct device *const sensor = DEVICE_DT_GET(DT_INST(0, st_lis2dh));


	if (sensor == NULL) {
		printf("No device found\n");
		return;
	}
	if (!device_is_ready(sensor)) {
		printf("Device %s is not ready\n", sensor->name);
		return;
	}

this is some code i tried to initialize or interface with device... it appears to me that I2C bus is alright and working but LIS2D itself is not working...

My configuration

CONFIG_I2C=y
CONFIG_SENSOR=y
CONFIG_LIS2DH=y
CONFIG_LIS2DH_ODR_RUNTIME=y
CONFIG_LIS2DH_TRIGGER_GLOBAL_THREAD=y
CONFIG_CBPRINTF_FP_SUPPORT=y

&i2c0 {
	compatible = "nordic,nrf-twim";
	status = "okay";
	clock-frequency = <I2C_BITRATE_FAST>;
	pinctrl-0=<&i2c0_default>;
	pinctrl-1=<&i2c0_sleep>;
	pinctrl-names = "default", "sleep";
	/* embedded LIS2DH accelerometer  */
	lis2dh12: lis2dh12@19 {
		compatible = "st,lis2dh12", "st,lis2dh";
		status = "okay";
		reg = <0x19>;
		irq-gpios = <&gpio0 16 0x0>;
	};
};

Is there anything else i should be doing ? From what I read for past few days there isnt... or atleast none of the samples did anything more

Parents
  • Hi,

    <err> lis2dh: Failed to read chip id.

    In these cases it is a good idea to get a trace from I2C lines with a logic analyzer og oscilloscope to see what happens on the lines. Such as "Is the nRF sending anything?" and "Is the external chip sending anything?".

    Can you get some measurements?

    Regards,
    Sigurd Hellesvik

  • Hello,

    I definitely cant, but maybe I know some people who could measure it. I'll try to contact them...

    In meantime.. cant you think of something else ? Slight smile

    There is one small detail I forgot to mention : that lis2dh error is shown as first line in log... it appears to me as it happens during some boot sequence ? even before initialization code of my program

  • Braxatoris said:
    In meantime.. cant you think of something else ? Slight smile

    I got an idea.

    An I2C sniffer sample. So I2C devices has a limited range of IDs, so you can easily just test every possible address in a couple of seconds. If the I2C device is actually connected and powered correctly, this should find it.

    Here is a kinda old example: https://github.com/crfosse/ncs_projects/tree/main/peripheral_zephyr/i2c. You maybe have to make some changes to it, but the sample is simple so it should not be too hard I hope.

  • Im really sorry it took me so long to reply. I was offsite for while so I couldnt tend to this topic...

    After few changes I was able to compile and flash your I2C Sniffer... this is output :

    SEGGER J-Link V7.94e - Real time terminal output
    SEGGER J-Link (unknown) V1.0, SN=760197898
    Process: JLinkExe
    *** Booting nRF Connect SDK v2.7.0-5cb85570ca43 ***
    *** Using Zephyr OS v3.6.99-100befc70c74 ***
    The I2C scanner started
    Value of NRF_TWIM2->PSEL.SCL : 31 
    Value of NRF_TWIM2->PSEL.SDA : 27 
    Value of NRF_TWIM2->FREQUENCY: 67108864 
    26738688 -> 100k
    error -5 
    error -5

    There were only -5 errors after this... but what is curious is those pin numbers... my dtsi config is 

        i2c0_default: i2c0_default {
    		group1 {
    			psels = <NRF_PSEL(TWIM_SDA, 0, 24)>,
    					<NRF_PSEL(TWIM_SCL, 1, 4)>;
    		};
    	};
    
    	i2c0_sleep: i2c0_sleep {
    		group1 {
    			psels = <NRF_PSEL(TWIM_SDA, 0, 24)>,
    					<NRF_PSEL(TWIM_SCL, 1, 4)>;
    			low-power-enable;
    		};
    	};

    Where 

    27 and 31 came from ?!

Reply
  • Im really sorry it took me so long to reply. I was offsite for while so I couldnt tend to this topic...

    After few changes I was able to compile and flash your I2C Sniffer... this is output :

    SEGGER J-Link V7.94e - Real time terminal output
    SEGGER J-Link (unknown) V1.0, SN=760197898
    Process: JLinkExe
    *** Booting nRF Connect SDK v2.7.0-5cb85570ca43 ***
    *** Using Zephyr OS v3.6.99-100befc70c74 ***
    The I2C scanner started
    Value of NRF_TWIM2->PSEL.SCL : 31 
    Value of NRF_TWIM2->PSEL.SDA : 27 
    Value of NRF_TWIM2->FREQUENCY: 67108864 
    26738688 -> 100k
    error -5 
    error -5

    There were only -5 errors after this... but what is curious is those pin numbers... my dtsi config is 

        i2c0_default: i2c0_default {
    		group1 {
    			psels = <NRF_PSEL(TWIM_SDA, 0, 24)>,
    					<NRF_PSEL(TWIM_SCL, 1, 4)>;
    		};
    	};
    
    	i2c0_sleep: i2c0_sleep {
    		group1 {
    			psels = <NRF_PSEL(TWIM_SDA, 0, 24)>,
    					<NRF_PSEL(TWIM_SCL, 1, 4)>;
    			low-power-enable;
    		};
    	};

    Where 

    27 and 31 came from ?!

Children
Related