This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

i2c3 on nRF5340 not working

I have attached a sensor board to the nRF5340DK board

I'm using zephyr 1.6.0 on macOS

I ran an I2C scan example using I2C1 peripheral and it works fine

found 5 I2C slave address

this is the main.c I used

#include <errno.h>
#include <zephyr.h>
#include <sys/printk.h>
#include <device.h>
#include <drivers/i2c.h>


void main(void)
{
	const struct device *i2c_dev;
	int i;

	i2c_dev = device_get_binding("I2C_1");
	if (!i2c_dev) {
		printk("I2C: Device driver not found.\n");
		return;
	} else {
		printk("I2C: Device driver found !!!!!!.\n");
	}

	for ( i = 4; i < 0x77; i++) {
		struct i2c_msg msgs[1];
		/* Send the address to read from */
		msgs[0].buf = NULL;
		msgs[0].len = 0;
		msgs[0].flags = I2C_MSG_WRITE | I2C_MSG_STOP;
		printk("0x%2x not found FOUND\n", i);
		if (i2c_transfer(i2c_dev, &msgs[0], 1, i) == 0) {
			printk("0x%2x FOUND\n", i);
		}
	}
}
this the nrf5340dk_nrf5340_cpuapp.overlay file
&i2c1 {
	compatible = "nordic,nrf-twim";
	sda-pin = <8>;
	scl-pin = <7>;
	status = "okay";
};
and this the prj.conf file 
CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_I2C=y
 
Now, I tested with I2C3 (I'm thinking of using UART1 for GSM)
so I changed the nrf5340dk_nrf5340_cpuapp.overlay file to 
&i2c3 {
	compatible = "nordic,nrf-twim";
	sda-pin = <8>;
	scl-pin = <7>;
	status = "okay";
};
then I changed  i2c_dev = device_get_binding("I2C_1"); -----> i2c_dev = device_get_binding("I2C_3"); in the main.c

but it doesn't work: the I2C device driver was found but it doesn't find any I2C slave address
I changed also the proj.conf file
CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y
CONFIG_I2C=y
CONFIG_NRFX_TWIM=y
CONFIG_NRFX_TWIM0=y
CONFIG_NRFX_TWIM3=y
but I got the same error 
the I2C device driver was found but it doesn't find any I2C slave address

this the generated dts file 
4555.zephyr.dts

what could be the problem with this behavior?
Parents Reply Children
No Data
Related