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

    Sigurd is unavailable, so I have been asked to take over this ticket. Sorry about the delayed response here. So, the I2C sniffer reports 27 and 31 as the pins used here, which are the default pins set in the nRF52833 DK board files if I'm not mistaken, so I think there's something wrong with how you've set up the SDA/SCL pins in your application here.

    Please refer to the I2C exercise in the DevAcademy course here to see how to set up I2C pins as intended in your project. https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/lessons/lesson-6-serial-com-i2c/topic/exercise-1-6-2/ 

    Best regards,

    Simon

  • Hello Simon,

    thanks for your reply.

    But I dont know what to tell you :) I posted my config here in previous posts... and it is pretty simple... I really dont know what should i do differently... pinctrl should be correctly set, sensor in DTS file should be correctly set, when i changed pins in pinctrl it changed in zephyr.dts file so board def is correctly included in build process... and yet, I always get 31 and 27.. 

    And ofc, I dont have 52833 DK, Im testing it on DWM3001CDK ...

    Im including whole I2C Sniffer project as I built it and flashed it... please, can you tell me if I did something wrong ?

    As for I2C exercise, again... I compared things I did and what is shown in exercise, and as far as I can tell, I did everything same... 

    Only thing I tried to do in Sniffer project is to get device spec as in exercise... and that didnt work at all... Zephyr crashed when i did get device through DT_NODELABEL(lis2dh12)

    Sniffer works because label is put in i2c0 node, not lis2dh12 itself... if i move it to lis2dh12, it will fail to bind...i2c_sniffer_braxatoris.zip

Reply
  • Hello Simon,

    thanks for your reply.

    But I dont know what to tell you :) I posted my config here in previous posts... and it is pretty simple... I really dont know what should i do differently... pinctrl should be correctly set, sensor in DTS file should be correctly set, when i changed pins in pinctrl it changed in zephyr.dts file so board def is correctly included in build process... and yet, I always get 31 and 27.. 

    And ofc, I dont have 52833 DK, Im testing it on DWM3001CDK ...

    Im including whole I2C Sniffer project as I built it and flashed it... please, can you tell me if I did something wrong ?

    As for I2C exercise, again... I compared things I did and what is shown in exercise, and as far as I can tell, I did everything same... 

    Only thing I tried to do in Sniffer project is to get device spec as in exercise... and that didnt work at all... Zephyr crashed when i did get device through DT_NODELABEL(lis2dh12)

    Sniffer works because label is put in i2c0 node, not lis2dh12 itself... if i move it to lis2dh12, it will fail to bind...i2c_sniffer_braxatoris.zip

Children
No Data
Related