ncs 2.3.0 i2c pins open drain configurations

Hi All!

Hope you all are doing well!

I am using nrf52833DK, NCS version 2.3.0, and VSCODE studio as an IDE. I am integrating the tlv493D sensor with nrf52833.

The issue I am facing is that 

I have two sets of sensors available , address of both are 0x5E

1)shield2go  tlv493D 

2)adafruit   tlv493D 

My code is working fine with only 

  1)shield2go  tlv493D. but when I interface 

  2)adafruit   tlv493D .NOT WORKING. I used Oscilscope the sensor is not sending ack against the address.

Both sensors pins are pulled up by 3v

* I wrote the same code in Arduino ide for esp32 and it's working for both sensors.

  1. can anybody tell me how to set the i2c pins as an open drain? because this is the only option left. 
  2. If you go through the 3 oscilloscope images then the 8th bit is high (for read ) from esp32 but low from nrf52833 (should be high for read but still reading )
  3. is it any option to send 8th bit as high (read)

My code is as follows 

.overlay 

&i2c0 {  
    mysensor: mysensor@5e{
        compatible = "i2c-device";
        reg = < 0x5e>;
	    status = "okay";
        label = "MYSENSOR";
		
	
	   
    };

	pinctrl-0 = <&i2c0_default_alt>;     // for custom board scl = 0.02 & Sda  = 0.29 , plz uncomment 
    pinctrl-1 = <&i2c0_sleep_alt>;
    pinctrl-names = "default", "sleep";


	clock-frequency = <400000>;

};


&pinctrl {
    

    uart0_default_alt: uart0_default_alt {
		group1 {
			psels = <NRF_PSEL(UART_TX, 1, 9)>,
				<NRF_PSEL(UART_RTS, 0, 4)>;  //5
		};
		group2 {
			psels = <NRF_PSEL(UART_RX, 0, 3)>,
				<NRF_PSEL(UART_CTS, 0, 7)>;
			bias-pull-up;
		};
	};

	uart0_sleep_alt: uart0_sleep_alt {
		group1 {
			psels = <NRF_PSEL(UART_TX, 1, 9)>,
				<NRF_PSEL(UART_RX, 0, 3)>,
				<NRF_PSEL(UART_RTS, 0, 4)>,  //5
				<NRF_PSEL(UART_CTS, 0, 7)>;
			low-power-enable;
		};

	};

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


main.c

	if(!device_is_ready(dev_i2c.bus)){	

		printf("i2c_dev not ready\n");
		return;


	}


	ret = i2c_burst_read_dt(&dev_i2c,0x00,rbuffer,10);   // read 1st 10 bytes and store it in rbuffer

    for(int i=0; i<10; i++){
    printf("Readbuffer 0x%x\n",rbuffer[i]);

	}

esp32 communication with adafruit tlv493d sensor

esp32 communication with shield2go tlv493d sensor

nrf52833 communication with shiled2go tlv493d sensor

Parents
  • Hi,

    can anybody tell me how to set the i2c pins as an open drain? because this is the only option left. 

    The alternative is to configure the pins to S0D1 which mean that it will be standard drive on logic low and disconnected (effectively floating) when it's logic high. The TWIM pins are configured during the initialization of the driver here, you can use the same nrfx gpio functions to re-configure them. However, note that the pins are configured like this for a reason, I can't guarantee that this will work without any issues if configured S0D1, as I haven't tested it myself,

    • If you go through the 3 oscilloscope images then the 8th bit is high (for read ) from esp32 but low from nrf52833 (should be high for read but still reading )
    • is it any option to send 8th bit as high (read)

    Could you double check the return value from the i2c_burst_read_dt() and see if it returns an error code? I agree that accordingly to the specification, a read operation should have the 8th bit as high,

    regards

    Jared

Reply
  • Hi,

    can anybody tell me how to set the i2c pins as an open drain? because this is the only option left. 

    The alternative is to configure the pins to S0D1 which mean that it will be standard drive on logic low and disconnected (effectively floating) when it's logic high. The TWIM pins are configured during the initialization of the driver here, you can use the same nrfx gpio functions to re-configure them. However, note that the pins are configured like this for a reason, I can't guarantee that this will work without any issues if configured S0D1, as I haven't tested it myself,

    • If you go through the 3 oscilloscope images then the 8th bit is high (for read ) from esp32 but low from nrf52833 (should be high for read but still reading )
    • is it any option to send 8th bit as high (read)

    Could you double check the return value from the i2c_burst_read_dt() and see if it returns an error code? I agree that accordingly to the specification, a read operation should have the 8th bit as high,

    regards

    Jared

Children
Related