nrf52840dk PCA10056 I2C Issues with Audio codec

Hello,

I am currently having some trouble with the I2C communication between my nrf52840dk and the NAU88C22 codec. Although there are times when communication seems to work, it often fails.

To resolve the issue, I have already tried using both the nrf connect sdk and micropython. Interestingly, I have successfully used the same NAU88C22 hardware and micropython software with an ESP32 without any issues.

Currently, I have connected GND, 5V, P0.26, and P0.27 to the NAU88C22 hardware. However, I am not sure if there is anything else that needs to be configured. Additionally, I am wondering if the nrf52840dk pins are 3.3V compatible.

Any help or advice you can offer would be greatly appreciated. Thank you in advance.

Micropython:

def Nau88C22_write__(reg, data):
    write_buf = bytearray(2)
    write_buf[0] = ((reg << 1) & 0xFE) + (data >> 8)
    write_buf[1] = data & 0xFF

    ret = i.writeto(0x1A, write_buf)

i = machine.I2C(0, scl=machine.Pin(27), sda=machine.Pin(26))

nrf connect sdk (based on https://github.com/zephyrproject-rtos/zephyr/tree/main/samples/drivers/i2s/echo):

void Nau88C22_write(uint8_t reg, uint16_t data) {
	const struct device * i2c_dev = DEVICE_DT_GET(WM8731_I2C_NODE);

	uint8_t write_buf[2] = {((reg << 1) & 0xFE) + (data >> 8), data & 0xFF};

	int ret;

	ret = i2c_reg_write_byte(i2c_dev, 0x1A,
					write_buf[0], write_buf[1]);

	if (ret != 0) {
		printf("Fail!\n");
	} else {
		printf("Success!\n");
	}
}

board overlay:

&pinctrl {
	i2c0_default_alt: i2c0_default_alt {
		group1 {
			psels = <NRF_PSEL(TWIM_SDA, 0, 26)>,
				<NRF_PSEL(TWIM_SCL, 0, 27)>;
		};
	};

	i2c0_sleep_alt: i2c0_sleep_alt {
		group1 {
			psels = <NRF_PSEL(TWIM_SDA, 0, 26)>,
				<NRF_PSEL(TWIM_SCL, 0, 27)>;
			low-power-enable;
		};
	};

	i2s0_default_alt: i2s0_default_alt {
		group1 {
			psels = <NRF_PSEL(I2S_SCK_M, 1, 15)>,
				<NRF_PSEL(I2S_LRCK_M, 1, 12)>,
				<NRF_PSEL(I2S_SDOUT, 1, 13)>,
				<NRF_PSEL(I2S_SDIN, 1, 14)>;
		};
	};
};

&i2c0 {
	status = "okay";
	pinctrl-0 = <&i2c0_default_alt>;
	pinctrl-1 = <&i2c0_sleep_alt>;
	pinctrl-names = "default", "sleep";

	wm8731: wm8731@1a {
		compatible = "wolfson,wm8731";
		reg = <0x1a>;
	};
};

i2s_rxtx: &i2s0 {
	status = "okay";
	pinctrl-0 = <&i2s0_default_alt>;
	pinctrl-names = "default";
};

Related