This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Migrating from nrf5_SDK to nrf connect sdk

Hello,

I am migrating code from nrf5_SDK_17.0.2 to nrf connect sdk v1.6.1. The board i am using is nrf52dk(nrf52832) connected with adafruit LSM6DSO.

Everything works fine on nrf5_SDK which based on modified example twi_sensor. But when I run lsm6dso example from zephyr\samples\sensor\lsm6dso, it says

Cannot set sampling frequency for accelerometer. -134

I have tried manually write register to i2c address like what I does on nrf5_SDK but hard fault occurs.

    //uint8_t buf[2] = {0x10, 0x10};
    //int ret = i2c_write(dev, buf, 1, 0x10);
    int ret = i2c_reg_write_byte(dev, 0x6a, 0x10, 0x10);
    if (ret < 0){
        printf("cannot i2c_burst_write");
    }else {
        printf("custom i2c_burst_write");
    }

Any help would be appreciated.

prj.conf

CONFIG_STDOUT_CONSOLE=y
CONFIG_I2C=y
CONFIG_SENSOR=y
CONFIG_LSM6DSO=y
CONFIG_LSM6DSO_TRIGGER_NONE=y
CONFIG_CBPRINTF_FP_SUPPORT=y

modified part of nrf52dk_nrf52832.dts

arduino_i2c: &i2c0 {
	compatible = "nordic,nrf-twi";
	status = "okay";
	sda-pin = <26>;
	scl-pin = <27>;

	lsm6dso@6a {
		compatible = "st,lsm6dso";
		label = "LSM6DSO";
		reg = <0x6a>;
	};
};

  • kclauah said:
    What does Error I/O means?

    EIO can basically mean anything ;-) Unfortunately this does not help too much, but the error often occurs when there are configuration mismatches.

    kclauah said:
    The oscilloscope does not even triggered with command i2c_write_read(data->i2c_master, config->i2c_addr,
                     &REG_ADDR_CALIB_COEFF_0, 1, &raw_coef, 18); and return -EIO

    I assume you are referring to this function?

    Can you please provide me with the content of ../zephyr/samples/sensor/dps310/<your build folder>/zephyr/zephyr.dts?

    Thanks and regards,

    Markus

  • Hello Markus,

    "... but the error often occurs when there are configuration mismatches."

    I don't think so because I can get the chip ID correctly. Which means

    1. The device is working.

    2. The connection is correct(pin, I2C address, power...)

    3. The initialization code is correct because it is written by manufacturer(tested both ST and Infineon).

    I still cannot understand why I2C driver does not try to write on SDA pin and directly jump to error code.

  • Can you give me a suggestion on how to create a new sensor driver? Because everything works fine on nRF5_SDK.

    Thank you.

  • Hello,

    kclauah said:
    I still cannot understand why I2C driver does not try to write on SDA pin and directly jump to error code.

    This is really hard to tell without any more input from your application. But normally Zephyr throws an EIO if the devicetree configuration is not completely correct.

    Unfortunately, I’m not able to test this on my side, since I do not have a DPS310 available. But I have tested the BME680 sample with my Thingy:91 and that works fine. Now, the sample does not use exactly the same I2C API as for the DPS310, so I can not exclude that their might be an issue with the sample itself.

    kclauah said:
    Can you give me a suggestion on how to create a new sensor driver? Because everything works fine on nRF5_SDK.

    My approach would have been to get the provided Zephyr sample to work with your board and sensor first, before taking any further steps.

    Regards,

    Markus

  • Hello Markus,

    I think I found the root cause.

    https://github.com/zephyrproject-rtos/zephyr/issues/35550#issuecomment-847745043

    And the suggestion from @anangl works for me.

    How can I report a bug here?

Related