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

    Glad to hear that were making progress! Are you able to do some debugging to see what function exactly it is that returns error -5 here? This error points to an input/output error, and often occurs if the nRF52833 isn't able to connect to the sensor it's trying to communicate with. Can you confirm that the two I.E. are connected to the same voltage net?

    Best regards,

    Simon

Reply
  • Hi

    Glad to hear that were making progress! Are you able to do some debugging to see what function exactly it is that returns error -5 here? This error points to an input/output error, and often occurs if the nRF52833 isn't able to connect to the sensor it's trying to communicate with. Can you confirm that the two I.E. are connected to the same voltage net?

    Best regards,

    Simon

Children
  • as for source of -5 error it is this IF

     


    as for connection to same voltage net... I'm not that capable in HW to confirm this, but thing is that this sensor is part of DWM3001C module.
    it is connected internally in module from factory and should be good... i have many modules and all behave same..
    I dont think there would be HW problem in all of these
  • At long last finally.... I managed to get it working... everything started working... i2c and LIS2DH12 itself too...

    Thanks   and   for your help.

    For other after me with same problem... my solution in the end was to fix bad PINCTRL config... I was missing line in my i2c0_default -> bias-pull-up;

    Fixed it looks like this 

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

Related