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 afternoon

    By driver API's, do you mean this function.

         struct i2c_msg *DevFnc ;
         DevFnc->buf = &devSelCode;
         DevFnc->len = 8;
         DevFnc->flags = 1;

         i2c_nrfx_twim_transfer(i2c_dev,DevFnc,1, 0x53 );
    If so, are there any samples where I can see the use of this.
    Kind regards,
    Hassan
  • Yes, this is our function to start a TWI transfer. However, in general, we recommend to use the Zephyr's driver APIs when possible (https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/hardware/peripherals/i2c.html). You can have a look at the i2c_fujitsu_fram driver sample in the Zephyr tree for an example of how this API can be used.

    Kind regards,

    Vidar

  • 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;
    		};
    	};
    
    };

Related