Pull down SDA pin i2c

Good day

I am developing on the nrf9160dk with a tag reader using i2c and am wanting to know if there is a function to pull down the SDA or SCL pins during operation in order to wake up the slave device.

Thank you in advance.

Kind regards,

Hassan

Parents Reply Children
  • Good day,

    I've attempted using these functions and APIs and when I test the board with the multimeter, pin 30 and 31 (my i2c2 pins) get zero voltage output.  Do the pins start the output in the prj file or when a write/read sequence is initiated?

    Kind regards,

    Hassan

  • My code is as follows:

    main.c
    
    #include 	<zephyr/zephyr.h>
    #include 	<drivers/i2c.h>
    #include	<stdio.h>
    #include 	<nrfx_twim.h>
    #include 	<C:\nordicsemi\v2.1.1\modules\hal\nordic\nrfx\hal\nrf_gpio.h>
    #include 	<hal/nrf_twim.h>
    
    
    
    
    
    /** I2C address to be used for ST25DV Data accesses. */
    #define ST25DV_ADDR_DATA_I2C                 0x53
    /** I2C address to be used for ST25DV System accesses. */
    #define ST25DV_ADDR_SYST_I2C                 0x57
    
    
    void Delay(int n)
    {
       int c, d;
       
       for (c = 1; c <= n; c++)
           for (d = 1; d <= n; d++)
           {}
           
       return 0;
    }
    
    
    
    void main(void)
    {   
    	// *************START************* //  
    	
    
      const struct device * i2c_dev;
       i2c_dev = DEVICE_DT_GET(DT_NODELABEL(i2c2));
      if (i2c_dev == NULL) {
    		printk("Unable to bind !\n");
    		return;
    	 }
    
    	 //************** DEVICE SELECT CODE**************//
    
    	const uint8_t devSelCode[8] = {1, 0, 1, 0, 0, 1, 1, 0};
    	 
    	int err1 = i2c_write(i2c_dev,devSelCode,8,ST25DV_ADDR_DATA_I2C);
    	printk("Device select msg: %d", err1);
    
         
    	 
    	
    }
    
    
    
    prj
    
    
    CONFIG_STDOUT_CONSOLE=y
    CONFIG_PRINTK=y
    
    CONFIG_I2C=y
    
    # CONFIG_LOG=y

    Is there possibly something wrong in my configuration that I am not seeing an output in my specified i2c2 pins?  Thank you for your help!

  • It seems like you don't have external pull-ups on the SDA and SCL lines as you measure 0 V on both . In that case, you will need to enable the internal pull-up resistors by adding the bias-pull-up property to your pin assignment in the device tree.

     &pinctrl {
    	i2c2_default: i2c2_default {
    		group1 {
    			psels = <NRF_PSEL(TWIM_SDA, 0, 30)>,
    				<NRF_PSEL(TWIM_SCL, 0, 31)>;
    				bias-pull-up;
    		};
    	};
    
    	i2c2_sleep: i2c2_sleep {
    		group1 {
    			psels = <NRF_PSEL(TWIM_SDA, 0, 30)>,
    				<NRF_PSEL(TWIM_SCL, 0, 31)>;
    			low-power-enable;
    		};
    	};
    
    };

  • HI

    This has helped!  Am now seeing an output when the program starts as well as the drop of output on the SDA line when writing to the i2c2 .  However, the write function still returning an error value.  Other than the slave address or device function code being incorrect, are there any other reasons for the function to fail?

  • Hi,

    Can you turn on logging to see what the error is?

Related