nRF Connect SDK library is sending the incorrect address to a sensor.

I using a BMI323 sensor with address 0x68 on the I2C bus and a custom-made nRF52832 dev kit. when I tried to send some commands to the sensor via I2C, it didn't work.

here is the code (the code is kinda big so I just posted the important parts:

// variable that contains all I2C configurations
static const struct i2c_dt_spec bmi323 = I2C_DT_SPEC_GET(DT_NODELABEL(bmi323));

/*!
 * @brief This internal API reads I2C function map to COINES platform
 */
static BMI3_INTF_RET_TYPE bmi3_i2c_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, void *intf_ptr)
{
    uint8_t device_addr = *(uint8_t*)intf_ptr;

    (void)intf_ptr;

    // burst read from the sensor
    i2c_burst_read_dt(&bmi323, reg_addr, reg_data, len);

    // although the best behaviour is to return one of the error codes defined in 'bmi3_defs.h" 
    // we will just return BMI3_INTF_RET_SUCCESS always for now
    return BMI3_INTF_RET_SUCCESS;
}

/*!
 * @brief This internal API writes I2C function map to COINES platform
 */
static BMI3_INTF_RET_TYPE bmi3_i2c_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t len, void *intf_ptr)
{
    uint8_t device_addr = *(uint8_t*)intf_ptr;

    (void)intf_ptr;

    // burst write from the sensor
    i2c_burst_write_dt(&bmi323, reg_addr, reg_data, len);

    // although the best behaviour is to return one of the error codes defined in 'bmi3_defs.h" 
    // we will just return BMI3_INTF_RET_SUCCESS always for now
    return BMI3_INTF_RET_SUCCESS;

}

here is the '.overlay' file:

// To get started, press Ctrl+Space to bring up the completion menu and view the available nodes.

// You can also use the buttons in the sidebar to perform actions on nodes.
// Actions currently available include:

// * Enabling / disabling the node
// * Adding the bus to a bus
// * Removing the node
// * Connecting ADC channels

// For more help, browse the DeviceTree documentation at https://docs.zephyrproject.org/latest/guides/dts/index.html
// You can also visit the nRF DeviceTree extension documentation at https://docs.nordicsemi.com/bundle/nrf-connect-vscode/page/guides/ncs_configure_app.html#devicetree-support-in-the-extension

&i2c0 {
	status = "okay";
	pinctrl-0 = <&i2c0_default>;
	pinctrl-names = "default";

    bmi323: bmi323@68{
        compatible = "i2c-device";
        reg = <0x68>;
        label="bmi323";
    };
};

&gpiote {
	status = "okay";
};

&pinctrl {
	i2c0_default: i2c0_default {
		group1 {
			psels = <NRF_PSEL(TWIM_SCL, 0, 8)>, <NRF_PSEL(TWIM_SDA, 0, 7)>;
		};
	};
};

I grabbed my logic analyzer and noticed the following on the I2C bus:

even though the address is specified to be 0x68 in the '.overlay' file, the actual address sent is '0xD0' where 

0xD0 = 0x68 << 1;

I don't know. Is it a bug, or am I doing something wrong?

Parents Reply Children
No Data
Related