#I2C connection issue

1 messages · Page 1 of 1 (latest)

graceful lintel
#

this is more of a zephyr question than anything else but I thought I would ask to see if anyone had any ideas. I have a board that is using a xiao nrf52840 with a adxl345 hooked up to the i2c pins. in the device tree I am able to create the device and then find said device in a c file. but when I try to actually use that device it gives me a communication error which implies to me that the device tree is not set up correctly. I am able to connect to the adxl345 in a normal arudino script so I know it is not a wiring problem. I also know the adxl345 is at address 53. so that shoudl be good as well. other than that I am unsure. I will paste it below to see if anyone has any ideas. again I know this isn' the exact right place to put this but I am at a loss.

&i2c0_default {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 4)>,
<NRF_PSEL(TWIM_SCL, 0, 5)>;
};
};

&i2c0_sleep {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 4)>,
<NRF_PSEL(TWIM_SCL, 0, 5)>;
low-power-enable;
};
};

&i2c1 {
pinctrl-0 = <&i2c0_default>;
compatible = "nordic,nrf-twi";
reg = <0x40003000 0x1000>;
status = "okay";
clock-frequency = <I2C_BITRATE_STANDARD>;

adxl345: adxl345@53 {
    compatible = "adi,adxl345";
    reg = <0x53>;  /* Device address on I2C bus */
};

};

shut skiff
#

Why are you setting the reg on the i2c node?

#

At most you'd maybe want to set the compatible

#

You need to set the pinctrl names too

#

Or it won't set up the pins.

graceful lintel
#

awesome, I will try that out and let you know what happens. Thank you for the quick response

#

That seems to have gotten me further than I was. my logs from my c file trying to run the part is now printing

[00:00:00.305,267] <err> i2c_nrfx_twi: Error 0x0BAE0001 occurred for message 0
[00:00:00.305,297] <err> ADXL345: Read PART ID failed: 0xfffffffb

This might start extending to being my code's problem over a zephyr configuration issue

graceful lintel
#

Ok, I figured out the cause of that error. and I am back to having the original error. below is my updated device tree

#

&i2c0_default {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 4)>,
<NRF_PSEL(TWIM_SCL, 0, 5)>;
};
};

&i2c0_sleep {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 4)>,
<NRF_PSEL(TWIM_SCL, 0, 5)>;
low-power-enable;
};
};

&i2c0 {
pinctrl-0 = <&i2c0_default>;
pinctrl-1 = <&i2c0_sleep>;
pinctrl-names = "default", "sleep";
compatible = "nordic,nrf-twi";
status = "okay";
clock-frequency = <I2C_BITRATE_STANDARD>;

adxl345: adxl345@53 {
    compatible = "adi,adxl345";
    reg = <0x53>;  /* Device address on I2C bus */
};

};

shut skiff
#

And what is the specific error you're getting