TWI/I2C no communication with Sensor Devices

Hello,

my first Post here, so i hope i do it correctly.

I have the following Problem with the Configuration and Communication over TWI/I2C.

The Voltage of the TWI/I2C Bus is not 3.3V.

Reference Mesurment with a RPI and ESP32 for the same Sensor Hardware. I can say it's not a hardware fault.


I use as Hardwarebase the nRF52833-DK.

As Development runtime Zephyr with the nRF connect SDK V2.0.0 in Visual Studio Code.

As Test-Project to find the Problem, i use the follwing Code and Settings:

The used Overlay for I2C

&i2c0 {
	compatible = "nordic,nrf-twim";
	status = "okay";
	pinctrl-0 = <&i2c0_default>;
	pinctrl-1 = <&i2c0_sleep>;
	pinctrl-names = "default", "sleep";
	clock-frequency = <100000>;
	/*adxl372@53 {
		compatible = "adi,adxl372";
		reg = <0x53>;
		int1-gpios = <&gpio0 54 GPIO_ACTIVE_HIGH>;
		label = "ADXL372";
	};*/
    /*pca9536@41 {
        compatible = "ti,pca9536";
        reg = <0x41>;
        label = "PCA9536";
    };
	gyro_adc@40 {
		compatible = "i2c-device";
		reg = < 0x40 >;
		label = "gyro";
	};
	bq35100@55 {
		compatible = "i2c-device";
		reg = < 0x55 >;
		label = "bms";
	};*/
};

and run it with this Project Configuration

CONFIG_STDOUT_CONSOLE=y
CONFIG_PRINTK=y

CONFIG_NEWLIB_LIBC=y
CONFIG_CPLUSPLUS=y
CONFIG_STD_CPP17=y
CONFIG_LIB_CPLUSPLUS=y
#CONFIG_RTTI=y
CONFIG_THREAD_ANALYZER=y
CONFIG_DEBUG=y
CONFIG_NEWLIB_LIBC_MIN_REQUIRED_HEAP_SIZE=2048

CONFIG_I2C=y
CONFIG_I2C_NRFX=y
CONFIG_I2C_GPIO=y
CONFIG_NRFX_TWI0=y

Source-Code (main.cpp):

/*
 * Copyright (c) 2015 Intel Corporation
 *
 * SPDX-License-Identifier: Apache-2.0
 */

#include <zephyr.h>
#include <sys/printk.h>

#include <device.h>
#include <devicetree.h>
#include <drivers/gpio.h>
#include <drivers/i2c.h>

#define FRAM_I2C_ADDR 41

#define MY_TWIM DT_NODELABEL(i2c0)

void main(void)
{
	const struct device *i2c_dev = DEVICE_DT_GET(DT_NODELABEL(i2c0));
	uint8_t cmp_data[16];
	uint8_t data[16];
	uint8_t w_data[16];
	uint8_t r_data[16];
	int i, ret;
	int rc1, rc2, rc3, rc4;
	rc1 = rc2 = rc3 = rc4 = -999;

	//Initalisierung Speicehr Bereiche
	for (i = 0; i < 16; ++i)
	{ data[i] = w_data[i] =  r_data[i] = 0; }

	while (1)
	{
		if (!device_is_ready(i2c_dev))
		{ printk("I2C: Device is not ready.\n"); return; }	
		else
		{ printk("I2C: is ready.\n"); break; }
	}

	uint32_t dev_config = I2C_SPEED_SET(I2C_SPEED_STANDARD) | I2C_MODE_MASTER;

	if (i2c_configure(i2c_dev, dev_config))
	{ printk("Configure Fault\n"); }
	else
	{
		printk("Configure Done\n");
		/*printk("I2C Master: Slave ADDR: 0x%x SCL: %d, SDA: %d, CLK(Hz): %u\n\n",
          DT_REG_ADDR(DT_NODELABEL(i2c_dev)), 
          DT_PROP(MY_TWIM, pinctrl-0),
          DT_PROP(MY_TWIM, pinctrl-1),
          DT_PROP(MY_TWIM, clock_frequency));*/
	}

	k_sleep(K_MSEC(1));

	//Auslesen Config ist nicht Implementiert Fehler -88 ENOSYS
	//uint32_t dev_config_tmp;
	//rc1 = i2c_get_config(i2c_dev, &dev_config_tmp);
	//if (rc1 != 0) {
	//	printk("I2C get_config failed\n");
	//}
	//if (dev_config != dev_config_tmp) {
	//	printk("I2C get_config returned invalid config\n");
	//}

	uint8_t reg_to_read = 3;

	w_data[0] = reg_to_read;

	uint8_t wr_addr[2];
	/* FRAM address */
	wr_addr[0] = reg_to_read;
	wr_addr[1] = 0x00;
	struct i2c_msg msgs[2];
	/* Send the address to read from */
	msgs[0].buf = wr_addr;
	msgs[0].len = 2U;
	msgs[0].flags = I2C_MSG_WRITE;

	/* Read from device. STOP after this. */
	msgs[1].buf = data;
	msgs[1].len = 1;
	msgs[1].flags = I2C_MSG_READ | I2C_MSG_STOP;

	rc1 = i2c_write(i2c_dev, &wr_addr[0], 1, (uint16_t)FRAM_I2C_ADDR);
	rc2 = i2c_read(i2c_dev, &data[0], 1, (uint16_t)FRAM_I2C_ADDR);
	rc3 = i2c_write_read(i2c_dev, (uint16_t)FRAM_I2C_ADDR, &w_data[0], 1, &r_data[0], 1);
	rc4 = i2c_transfer(i2c_dev, &msgs[0], 2, (uint16_t)FRAM_I2C_ADDR);
	//read_byte(i2c_dev, 0x00, &data[0], FRAM_I2C_ADDR);
	if (rc1 == 0 || rc2 == 0 || rc3 == 0 || rc4 == 0)
	{ 
		printk("all read. \n");
		printk("Value write data: %d \n", w_data);
		printk("Value read data: %d \n", r_data);
	}
	else
	{ printk("read fault \n"); }
	
	return;
}

NRF-Terminal Output:

Connected via Serial Port with settings COM3 115200 8n1 rtscts:off

*** Booting Zephyr OS build v3.0.99-ncs1  ***
I2C: is ready.
Configure Done
read fault
*** Booting Zephyr OS build v3.0.99-ncs1  ***
I2C: is ready.
Configure Done
read fault
[00:00:09.736,724] <err> i2c_nrfx_twim: Error 0x0BAE0001 occurred for message 0
[00:00:09.736,938] <err> i2c_nrfx_twim: Error 0x0BAE0001 occurred for message 0
[00:00:09.737,121] <err> i2c_nrfx_twim: Error 0x0BAE0001 occurred for message 0
[00:00:09.737,304] <err> i2c_nrfx_twim: Error 0x0BAE0001 occurred for message 0


The Project-Copy:

I2C-Test.zip

Thanks for Help

  • Hello,

    aftercross check with the Project Partner, with a little correction of the code change:

    NRFX_TWIM_XFER_DESC_RX
    to
    NRFX_TWIM_XFER_DESC_TX

    shows the Bus clients. (See Log)

    Connected via Serial Port with settings COM3 115200 8n1 rtscts:off
    
    *** Booting Zephyr OS build v3.0.99-ncs1  ***
    [00:00:00.380,523] <inf> app: Hello World! nrf52833dk_nrf52833
    [00:00:00.380,706] <err> app: err 0bae0001, addr 00
    [00:00:00.390,930] <err> app: err 0bae0001, addr 01
    [00:00:00.401,184] <err> app: err 0bae0001, addr 02
    [00:00:00.411,437] <err> app: err 0bae0001, addr 03
    [00:00:00.421,661] <err> app: err 0bae0001, addr 04
    [00:00:00.431,884] <err> app: err 0bae0001, addr 05
    [00:00:00.442,108] <err> app: err 0bae0001, addr 06
    [00:00:00.452,331] <err> app: err 0bae0001, addr 07
    [00:00:00.462,554] <err> app: err 0bae0001, addr 08
    [00:00:00.472,778] <err> app: err 0bae0001, addr 09
    [00:00:00.483,001] <err> app: err 0bae0001, addr 0a
    [00:00:00.493,225] <err> app: err 0bae0001, addr 0b
    [00:00:00.503,448] <err> app: err 0bae0001, addr 0c
    [00:00:00.513,702] <err> app: err 0bae0001, addr 0d
    [00:00:00.523,925] <err> app: err 0bae0001, addr 0e
    [00:00:00.534,149] <err> app: err 0bae0001, addr 0f
    [00:00:00.544,372] <err> app: err 0bae0001, addr 10
    [00:00:00.554,595] <err> app: err 0bae0001, addr 11
    [00:00:00.564,819] <err> app: err 0bae0001, addr 12
    [00:00:00.575,042] <err> app: err 0bae0001, addr 13
    [00:00:00.585,266] <err> app: err 0bae0001, addr 14
    [00:00:00.595,489] <err> app: err 0bae0001, addr 15
    [00:00:00.605,712] <err> app: err 0bae0001, addr 16
    [00:00:00.615,936] <err> app: err 0bae0001, addr 17
    [00:00:00.626,159] <err> app: err 0bae0001, addr 18
    [00:00:00.636,413] <err> app: err 0bae0001, addr 19
    [00:00:00.646,667] <err> app: err 0bae0001, addr 1a
    [00:00:00.656,890] <err> app: err 0bae0001, addr 1b
    [00:00:00.667,114] <err> app: err 0bae0001, addr 1c
    [00:00:00.677,337] <err> app: err 0bae0001, addr 1d
    [00:00:00.687,561] <err> app: err 0bae0001, addr 1e
    [00:00:00.697,784] <err> app: err 0bae0001, addr 1f
    [00:00:00.708,007] <err> app: err 0bae0001, addr 20
    [00:00:00.718,231] <err> app: err 0bae0001, addr 21
    [00:00:00.728,454] <err> app: err 0bae0001, addr 22
    [00:00:00.738,677] <err> app: err 0bae0001, addr 23
    [00:00:00.748,931] <err> app: err 0bae0001, addr 24
    [00:00:00.759,155] <err> app: err 0bae0001, addr 25
    [00:00:00.769,378] <err> app: err 0bae0001, addr 26
    [00:00:00.779,602] <err> app: err 0bae0001, addr 27
    [00:00:00.789,825] <err> app: err 0bae0001, addr 28
    [00:00:00.800,048] <err> app: err 0bae0001, addr 29
    [00:00:00.810,272] <err> app: err 0bae0001, addr 2a
    [00:00:00.820,495] <err> app: err 0bae0001, addr 2b
    [00:00:00.830,718] <err> app: err 0bae0001, addr 2c
    [00:00:00.840,942] <err> app: err 0bae0001, addr 2d
    [00:00:00.851,165] <err> app: err 0bae0001, addr 2e
    [00:00:00.861,389] <err> app: err 0bae0001, addr 2f
    [00:00:00.871,643] <err> app: err 0bae0001, addr 30
    [00:00:00.881,896] <err> app: err 0bae0001, addr 31
    [00:00:00.892,120] <err> app: err 0bae0001, addr 32
    [00:00:00.902,343] <err> app: err 0bae0001, addr 33
    [00:00:00.912,567] <err> app: err 0bae0001, addr 34
    [00:00:00.922,790] <err> app: err 0bae0001, addr 35
    [00:00:00.933,013] <err> app: err 0bae0001, addr 36
    [00:00:00.943,237] <err> app: err 0bae0001, addr 37
    [00:00:00.953,460] <err> app: err 0bae0001, addr 38
    [00:00:00.963,684] <err> app: err 0bae0001, addr 39
    [00:00:00.973,907] <err> app: err 0bae0001, addr 3a
    [00:00:00.984,161] <err> app: err 0bae0001, addr 3b
    [00:00:00.994,384] <err> app: err 0bae0001, addr 3c
    [00:00:01.004,608] <err> app: err 0bae0001, addr 3d
    [00:00:01.014,831] <err> app: err 0bae0001, addr 3e
    [00:00:01.025,054] <err> app: err 0bae0001, addr 3f
    [00:00:01.035,278] <err> app: err 0bae0001, addr 40
    [00:00:01.045,593] <inf> app: err 0bad0000, addr 41 FOUND DEVICE
    [00:00:01.055,847] <err> app: err 0bae0001, addr 42
    [00:00:01.066,070] <err> app: err 0bae0001, addr 43
    [00:00:01.076,293] <err> app: err 0bae0001, addr 44
    [00:00:01.086,517] <err> app: err 0bae0001, addr 45
    [00:00:01.096,740] <err> app: err 0bae0001, addr 46
    [00:00:01.106,994] <err> app: err 0bae0001, addr 47
    [00:00:01.117,248] <err> app: err 0bae0001, addr 48
    [00:00:01.127,471] <err> app: err 0bae0001, addr 49
    [00:00:01.137,695] <err> app: err 0bae0001, addr 4a
    [00:00:01.147,918] <err> app: err 0bae0001, addr 4b
    [00:00:01.158,142] <err> app: err 0bae0001, addr 4c
    [00:00:01.168,365] <err> app: err 0bae0001, addr 4d
    [00:00:01.178,588] <err> app: err 0bae0001, addr 4e
    [00:00:01.188,812] <err> app: err 0bae0001, addr 4f
    [00:00:01.199,035] <err> app: err 0bae0001, addr 50
    [00:00:01.209,259] <err> app: err 0bae0001, addr 51
    [00:00:01.219,512] <err> app: err 0bae0001, addr 52
    [00:00:01.229,736] <err> app: err 0bae0001, addr 53
    [00:00:01.239,959] <err> app: err 0bae0001, addr 54
    [00:00:01.250,183] <err> app: err 0bae0001, addr 55
    [00:00:01.260,406] <err> app: err 0bae0001, addr 56
    [00:00:01.270,629] <err> app: err 0bae0001, addr 57
    [00:00:01.280,853] <err> app: err 0bae0001, addr 58
    [00:00:01.291,076] <err> app: err 0bae0001, addr 59
    [00:00:01.301,300] <err> app: err 0bae0001, addr 5a
    [00:00:01.311,523] <err> app: err 0bae0001, addr 5b
    [00:00:01.321,746] <err> app: err 0bae0001, addr 5c
    [00:00:01.331,970] <err> app: err 0bae0001, addr 5d
    [00:00:01.342,224] <err> app: err 0bae0001, addr 5e
    [00:00:01.352,478] <err> app: err 0bae0001, addr 5f
    [00:00:01.362,701] <err> app: err 0bae0001, addr 60
    [00:00:01.372,924] <err> app: err 0bae0001, addr 61
    [00:00:01.383,148] <err> app: err 0bae0001, addr 62
    [00:00:01.393,371] <err> app: err 0bae0001, addr 63
    [00:00:01.403,594] <err> app: err 0bae0001, addr 64
    [00:00:01.413,818] <err> app: err 0bae0001, addr 65
    [00:00:01.424,041] <err> app: err 0bae0001, addr 66
    [00:00:01.434,265] <err> app: err 0bae0001, addr 67
    [00:00:01.444,488] <err> app: err 0bae0001, addr 68
    [00:00:01.454,742] <err> app: err 0bae0001, addr 69
    [00:00:01.464,965] <err> app: err 0bae0001, addr 6a
    [00:00:01.475,189] <err> app: err 0bae0001, addr 6b
    [00:00:01.485,412] <err> app: err 0bae0001, addr 6c
    [00:00:01.495,635] <err> app: err 0bae0001, addr 6d
    [00:00:01.505,859] <err> app: err 0bae0001, addr 6e
    [00:00:01.516,082] <err> app: err 0bae0001, addr 6f
    [00:00:01.526,306] <err> app: err 0bae0001, addr 70
    [00:00:01.536,529] <err> app: err 0bae0001, addr 71
    [00:00:01.546,752] <err> app: err 0bae0001, addr 72
    [00:00:01.556,976] <err> app: err 0bae0001, addr 73
    [00:00:01.567,199] <err> app: err 0bae0001, addr 74
    [00:00:01.577,453] <err> app: err 0bae0001, addr 75
    [00:00:01.587,707] <err> app: err 0bae0001, addr 76
    [00:00:01.597,930] <err> app: err 0bae0001, addr 77
    [00:00:01.608,154] <err> app: err 0bae0001, addr 78
    [00:00:01.618,377] <err> app: err 0bae0001, addr 79
    [00:00:01.628,601] <err> app: err 0bae0001, addr 7a
    [00:00:01.638,824] <err> app: err 0bae0001, addr 7b
    [00:00:01.649,047] <err> app: err 0bae0001, addr 7c
    [00:00:01.659,271] <err> app: err 0bae0001, addr 7d
    [00:00:01.669,494] <err> app: err 0bae0001, addr 7e
    [00:00:01.679,565] <inf> app: 1 sec passed
    *** Booting Zephyr OS build v3.0.99-ncs1  ***
    [00:00:00.402,435] <inf> app: Hello World! nrf52833dk_nrf52833
    [00:00:04.348,449] <err> app: err 0bae0001, addr 00
    [00:00:05.266,479] <err> app: err 0bae0001, addr 01
    [00:00:05.503,601] <err> app: err 0bae0001, addr 02
    [00:00:05.847,442] <err> app: err 0bae0001, addr 03
    [00:00:06.003,204] <err> app: err 0bae0001, addr 04
    [00:00:06.157,562] <err> app: err 0bae0001, addr 05
    [00:00:06.379,119] <err> app: err 0bae0001, addr 06
    [00:00:08.792,266] <err> app: err 0bae0001, addr 07
    [00:00:08.802,490] <err> app: err 0bae0001, addr 08
    [00:00:08.812,713] <err> app: err 0bae0001, addr 09
    [00:00:08.822,937] <err> app: err 0bae0001, addr 0a
    [00:00:08.833,160] <err> app: err 0bae0001, addr 0b
    [00:00:08.843,383] <err> app: err 0bae0001, addr 0c
    [00:00:08.853,607] <err> app: err 0bae0001, addr 0d
    [00:00:08.863,861] <err> app: err 0bae0001, addr 0e
    [00:00:08.874,114] <err> app: err 0bae0001, addr 0f
    [00:00:08.884,338] <err> app: err 0bae0001, addr 10
    [00:00:08.894,561] <err> app: err 0bae0001, addr 11
    [00:00:08.904,785] <err> app: err 0bae0001, addr 12
    [00:00:08.915,008] <err> app: err 0bae0001, addr 13
    [00:00:08.925,231] <err> app: err 0bae0001, addr 14
    [00:00:08.935,455] <err> app: err 0bae0001, addr 15
    [00:00:08.945,678] <err> app: err 0bae0001, addr 16
    [00:00:08.955,902] <err> app: err 0bae0001, addr 17
    [00:00:08.966,125] <err> app: err 0bae0001, addr 18
    [00:00:08.976,348] <err> app: err 0bae0001, addr 19
    [00:00:08.986,572] <err> app: err 0bae0001, addr 1a
    [00:00:08.996,795] <err> app: err 0bae0001, addr 1b
    [00:00:09.007,019] <err> app: err 0bae0001, addr 1c
    [00:00:09.017,242] <err> app: err 0bae0001, addr 1d
    [00:00:09.027,465] <err> app: err 0bae0001, addr 1e
    [00:00:09.037,689] <err> app: err 0bae0001, addr 1f
    [00:00:09.047,912] <err> app: err 0bae0001, addr 20
    [00:00:09.058,135] <err> app: err 0bae0001, addr 21
    [00:00:09.068,359] <err> app: err 0bae0001, addr 22
    [00:00:09.078,582] <err> app: err 0bae0001, addr 23
    [00:00:09.088,806] <err> app: err 0bae0001, addr 24
    [00:00:09.099,060] <err> app: err 0bae0001, addr 25
    [00:00:09.109,313] <err> app: err 0bae0001, addr 26
    [00:00:09.119,537] <err> app: err 0bae0001, addr 27
    [00:00:09.129,760] <err> app: err 0bae0001, addr 28
    [00:00:09.139,984] <err> app: err 0bae0001, addr 29
    [00:00:09.150,207] <err> app: err 0bae0001, addr 2a
    [00:00:09.160,430] <err> app: err 0bae0001, addr 2b
    [00:00:09.170,654] <err> app: err 0bae0001, addr 2c
    [00:00:09.180,877] <err> app: err 0bae0001, addr 2d
    [00:00:09.191,101] <err> app: err 0bae0001, addr 2e
    [00:00:09.201,324] <err> app: err 0bae0001, addr 2f
    [00:00:09.211,547] <err> app: err 0bae0001, addr 30
    [00:00:09.221,771] <err> app: err 0bae0001, addr 31
    [00:00:09.231,994] <err> app: err 0bae0001, addr 32
    [00:00:09.242,218] <err> app: err 0bae0001, addr 33
    [00:00:09.252,441] <err> app: err 0bae0001, addr 34
    [00:00:09.262,664] <err> app: err 0bae0001, addr 35
    [00:00:09.272,888] <err> app: err 0bae0001, addr 36
    [00:00:09.283,111] <err> app: err 0bae0001, addr 37
    [00:00:09.293,334] <err> app: err 0bae0001, addr 38
    [00:00:09.303,558] <err> app: err 0bae0001, addr 39
    [00:00:09.313,781] <err> app: err 0bae0001, addr 3a
    [00:00:09.324,005] <err> app: err 0bae0001, addr 3b
    [00:00:09.334,259] <err> app: err 0bae0001, addr 3c
    [00:00:09.344,512] <err> app: err 0bae0001, addr 3d
    [00:00:09.354,736] <err> app: err 0bae0001, addr 3e
    [00:00:09.364,959] <err> app: err 0bae0001, addr 3f
    [00:00:09.375,183] <err> app: err 0bae0001, addr 40
    [00:00:09.385,498] <inf> app: err 0bad0000, addr 41 FOUND DEVICE
    [00:00:09.395,751] <err> app: err 0bae0001, addr 42
    [00:00:09.405,975] <err> app: err 0bae0001, addr 43
    [00:00:09.416,198] <err> app: err 0bae0001, addr 44
    [00:00:09.426,422] <err> app: err 0bae0001, addr 45
    [00:00:09.436,645] <err> app: err 0bae0001, addr 46
    [00:00:09.446,868] <err> app: err 0bae0001, addr 47
    [00:00:09.457,092] <err> app: err 0bae0001, addr 48
    [00:00:09.467,315] <err> app: err 0bae0001, addr 49
    [00:00:09.477,539] <err> app: err 0bae0001, addr 4a
    [00:00:09.487,762] <err> app: err 0bae0001, addr 4b
    [00:00:09.497,985] <err> app: err 0bae0001, addr 4c
    [00:00:09.508,209] <err> app: err 0bae0001, addr 4d
    [00:00:09.518,432] <err> app: err 0bae0001, addr 4e
    [00:00:09.528,656] <err> app: err 0bae0001, addr 4f
    [00:00:09.538,879] <err> app: err 0bae0001, addr 50
    [00:00:09.549,102] <err> app: err 0bae0001, addr 51
    [00:00:09.559,326] <err> app: err 0bae0001, addr 52
    [00:00:09.569,580] <err> app: err 0bae0001, addr 53
    [00:00:09.579,833] <err> app: err 0bae0001, addr 54
    [00:00:09.590,057] <err> app: err 0bae0001, addr 55
    [00:00:09.600,280] <err> app: err 0bae0001, addr 56
    [00:00:09.610,504] <err> app: err 0bae0001, addr 57
    [00:00:09.620,727] <err> app: err 0bae0001, addr 58
    [00:00:09.630,950] <err> app: err 0bae0001, addr 59
    [00:00:09.641,174] <err> app: err 0bae0001, addr 5a
    [00:00:09.651,397] <err> app: err 0bae0001, addr 5b
    [00:00:09.661,621] <err> app: err 0bae0001, addr 5c
    [00:00:09.671,844] <err> app: err 0bae0001, addr 5d
    [00:00:09.682,067] <err> app: err 0bae0001, addr 5e
    [00:00:09.692,291] <err> app: err 0bae0001, addr 5f
    [00:00:09.702,514] <err> app: err 0bae0001, addr 60
    [00:00:09.712,738] <err> app: err 0bae0001, addr 61
    [00:00:09.722,961] <err> app: err 0bae0001, addr 62
    [00:00:09.733,184] <err> app: err 0bae0001, addr 63
    [00:00:09.743,408] <err> app: err 0bae0001, addr 64
    [00:00:09.753,631] <err> app: err 0bae0001, addr 65
    [00:00:09.763,854] <err> app: err 0bae0001, addr 66
    [00:00:09.774,078] <err> app: err 0bae0001, addr 67
    [00:00:09.784,301] <err> app: err 0bae0001, addr 68
    [00:00:09.794,525] <err> app: err 0bae0001, addr 69
    [00:00:09.804,779] <err> app: err 0bae0001, addr 6a
    [00:00:09.815,032] <err> app: err 0bae0001, addr 6b
    [00:00:09.825,256] <err> app: err 0bae0001, addr 6c
    [00:00:09.835,479] <err> app: err 0bae0001, addr 6d
    [00:00:09.845,703] <err> app: err 0bae0001, addr 6e
    [00:00:09.855,926] <err> app: err 0bae0001, addr 6f
    [00:00:09.866,149] <err> app: err 0bae0001, addr 70
    [00:00:09.876,373] <err> app: err 0bae0001, addr 71
    [00:00:09.886,596] <err> app: err 0bae0001, addr 72
    [00:00:09.896,820] <err> app: err 0bae0001, addr 73
    [00:00:09.907,043] <err> app: err 0bae0001, addr 74
    [00:00:09.917,266] <err> app: err 0bae0001, addr 75
    [00:00:09.927,490] <err> app: err 0bae0001, addr 76
    [00:00:09.937,713] <err> app: err 0bae0001, addr 77
    [00:00:09.947,937] <err> app: err 0bae0001, addr 78
    [00:00:09.958,160] <err> app: err 0bae0001, addr 79
    [00:00:09.968,383] <err> app: err 0bae0001, addr 7a
    [00:00:09.978,607] <err> app: err 0bae0001, addr 7b
    [00:00:09.988,830] <err> app: err 0bae0001, addr 7c
    [00:00:09.999,053] <err> app: err 0bae0001, addr 7d
    [00:00:10.009,277] <err> app: err 0bae0001, addr 7e
    [00:00:18.722,747] <inf> app: 1 sec passed

    Best regards

    Björn

  • Hello Björn,

    So when you are able to write to the device on addr. 0x41, does the voltage look correct on the oscilloscope?

    BR,
    Edvin

  • Hallo Edvin,

    now i get the oscilloscope measurment and now the voltages looks good.

    Programcode write:

    osciloscope

    programcode read:

    osciloscope

    The Read Value of the register 3 of the PCA9536, that is used for write/read, has the value: 255 (0xFF, 0xb1111 1111). This is correct or a not configured PCA9536.

    I have a still question, what is the reason that the manual configured twim work and the automated configuration over the I2C-API don't work.

  • Hello,

    I am not sure exactly why it doesn't work, but it suggests that there are some issues in the configuration that you were using. 

    In your snippets from your original post:

    	gyro_adc@40 {
    		compatible = "i2c-device";
    		reg = < 0x40 >;
    		label = "gyro";
    	};
    	bq35100@55 {
    		compatible = "i2c-device";
    		reg = < 0x55 >;
    		label = "bms";
    	};*/

    I see that you are setting the addresses and labels, but what does "i2c-device" refer to? It is not something that is part of NCS by default, I think. Something that may cause the voltage to drop like that is if the devices are configured with wrong pull resistors. Did you set pull-down somewhere in the "i2C-device" settings?

    BR,

    Edvin

  • Hello Edvin,

    The compatile "i2c-device" is a generic-description this is usesd in every I2C-Driver, in the most cases at the second or third layer of the driver.

    I can't see any option in the pin-control section of the Overlay-file for I2C to set the resistors. at the UART i see the option to pull up the PIN (Section copy from the sample Project):

    &pinctrl {
    	i2c0_default: i2c0_default {
    		group1 {
    			psels = <NRF_PSEL(TWIM_SDA, 0, 26)>,
    				<NRF_PSEL(TWIM_SCL, 0, 27)>;
    		};
    	};
    
    	i2c0_sleep: i2c0_sleep {
    		group1 {
    			psels = <NRF_PSEL(TWIM_SDA, 0, 26)>,
    				<NRF_PSEL(TWIM_SCL, 0, 27)>;
    			low-power-enable;
    		};
    	};
    
    	uart0_default: uart0_default {
    		group1 {
    			psels = <NRF_PSEL(UART_TX, 0, 6)>,
    				<NRF_PSEL(UART_RTS, 0, 5)>;
    		};
    		group2 {
    			psels = <NRF_PSEL(UART_RX, 0, 8)>,
    				<NRF_PSEL(UART_CTS, 0, 7)>;
    			bias-pull-up;
    		};
    	};

    Best regards Björn

Related