NCS SDK 2.7.0 uses I2C(SCL P0.10, SDA P0.09 ) failed

1. dts config file, I2C_SDA is configed GPIO P0.09/NFC1I2C_SCL is configed GPIO P0.10/NFC1, months ago, I'm using the old SDK, I also found that these pins configed as I2C function can not work, now the NCS SDK has the same problem, Could you help to check why?

&i2c0 {
	status = "okay";
	pinctrl-0 = <&i2c0_default>;
	pinctrl-names = "default";
	clock-frequency = <I2C_BITRATE_FAST>;
	is31fl3235a_part1: is31fl3235a_part1@78 {
		compatible = "i2c-device";
		reg = <0x78>;
		status = "okay";
	};
	is31fl3235a_part2: is31fl3235a_part2@7B {
		compatible = "i2c-device";
		reg = <0x7B>;
		status = "okay";
	};
};

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

2. Driver code

#define IS31FL3235A_REG_SHUTDOWN 0x00
#define IS31FL3235A_REG_GBL_CTL 0x4A
#define IS31FL3235A_REG_OUT_FREQ 0x4B
#define IS31FL3235A_REG_RST 0x4F

#define MCU1_NODE DT_NODELABEL(is31fl3235a_part1)
#define MCU2_NODE DT_NODELABEL(is31fl3235a_part2)

static const struct i2c_dt_spec mcu1_i2c = I2C_DT_SPEC_GET(MCU1_NODE);
static const struct i2c_dt_spec mcu2_i2c = I2C_DT_SPEC_GET(MCU2_NODE);

int is31fl3235a_init() {
    int err;
    if (!device_is_ready(mcu1_i2c.bus)) {
        LOG_ERR("I2C bus %s is not ready!\n\r", mcu1_i2c.bus->name);
        return -1;
    }
    if (!device_is_ready(mcu2_i2c.bus)) {
        LOG_ERR("I2C bus %s is not ready!\n\r", mcu2_i2c.bus->name);
        return -1;
    }
    uint8_t config[2] = {IS31FL3235A_REG_SHUTDOWN, 0x01};
    err = i2c_write(mcu1_i2c.bus, config, sizeof(config), 0x78);
    if (err < 0) {
        LOG_ERR("Could not write to I2C device %s\n\r", "mcu1");
        return -1;
    }
    err = i2c_write(mcu2_i2c.bus, config, sizeof(config), 0x7B);
    if (err < 0) {
        LOG_ERR("Could not write to I2C device %s\n\r", "mcu2");
        return -1;
    }

    return 0;
}

When running, I got the below exception

SEGGER J-Link V7.94e - Real time terminal output
SEGGER J-Link V9.6, SN=69650869
Process: JLink.exe
[00:00:00.501,007] <err> PHOENIX_IS31Fl3235A: Could not write to I2C device mcu1

  • I got same error, below is the schematic about I2C, It's 

    &pinctrl {
    	i2c0_default: i2c0_default {
    		group1 {
    			psels = <NRF_PSEL(TWIM_SCL, 0, 10)>, <NRF_PSEL(TWIM_SDA, 0, 9)>;
    			bias-pull-up;
    		};
    	};
    
    	spi1_default: spi1_default {
    		group1 {
    			psels = <NRF_PSEL(SPIM_MISO, 0, 14)>,
    					<NRF_PSEL(SPIM_MOSI, 0, 15)>,
    					<NRF_PSEL(SPIM_SCK, 0, 17)>;
    		};
    	};
    };

    Another project, I uses P0.07 & P0.08, I2C works properly

    &i2c0 {
    	status = "okay";
    	pinctrl-0 = <&i2c0_default>;
    	pinctrl-names = "default";
    	clock-frequency = <I2C_BITRATE_STANDARD>;
    	max77734:max77734@48 {
    		compatible = "i2c-device";
    		reg = <0x48>;
    	};
    };
    
    &pinctrl {
    	i2c0_default: i2c0_default {
    		group1 {
    			psels = <NRF_PSEL(TWIM_SCL, 0, 7)>, <NRF_PSEL(TWIM_SDA, 0, 8)>;
    		};
    	};
    };

  • Hi,

    I see. If you use the exact same configuration that worked on another board just with different pins, that should work here as well not that you have configures the NFC pins to function as GPIOs.. Can you measure the SDA and SCL lines with a logic analyzer so that we see the signals (if there is any clock and data, and if so, what it looks like)?

Related