Issues with nrf52dk I2C with BMA400

Hello Nordic Forum,

Thank you in advance for your help.

I have a BMA400 accelerometer break out board which I am able to connect and get to work with arduino.

I am now trying to connect to nrf52DK. SDA is connected to P0.26 and SCL is connected to P0.27. The sensor module is getting supply voltage and ground from the nrf52DK.

This is my overlay file. The address of the I2C device is 0x14.


&i2c0 {
status = "okay";
pinctrl-0 = <&i2c0_default>;
pinctrl-1 = <&i2c0_sleep>;
pinctrl-names = "default", "sleep";
bma4xx: bma4xx@14{
compatible = "bosch,bma4xx";
status = "okay";
reg = < 0x14 >;
};

clock-frequency = <I2C_BITRATE_STANDARD>;
};

&pinctrl {
/omit-if-no-ref/ i2c0_default: i2c0_default {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 26)>, <NRF_PSEL(TWIM_SCL, 0, 27)>;
};
};
};

I am able to successfully connect since device_is_ready is ok

int main(void)
{
static const struct i2c_dt_spec dev_i2c = I2C_DT_SPEC_GET(I2C_NODE);

if (!device_is_ready(dev_i2c.bus)) {
printk("I2C bus %s is not ready!\n", dev_i2c.bus->name);
return -1;
}

However any further operation of read / write fails silently. I tried to perform the operations in burst mode with the same result

uint8_t chip_id;
// Read from the chip ID register

int ret = i2c_reg_read_byte(&dev_i2c, 0x14, 0x00, &chip_id); // Fails inside the method

int err = i2c_reg_write_byte_dt(&dev_i2c, 0x7E, 0xB6); // returns -5

 I am not sure what's going on and how to debug this. Any ideas?

Parents Reply Children
Related