ee_hobby posted on 2019-5-17 07:12:37

Why software i2c time configuration 0 is still working?

Hardware: Ginkgo I2C adapterSoftware:GPIO control I2C mode example
http://www.viewtool.com/demo/Ginkgo/App_Examples/VC_USB_I2C_AT24C02_SCTL.zip
Issue:
    //Config timing,Unit of time for microseconds (us)
    I2C_TimeConfig.tSU_STA = 5;
    I2C_TimeConfig.tHD_STA = 4;
    I2C_TimeConfig.tLOW = 5;
    I2C_TimeConfig.tHIGH = 5;
    I2C_TimeConfig.tSU_DAT = 1;
    I2C_TimeConfig.tSU_STO = 4;
    I2C_TimeConfig.tBuf = 5;
    ret = VII_TimeConfig(VII_USBI2C, 0, 0, &I2C_TimeConfig);

Above timing parameters is working,but if set all to 0, it is still working, what's difference?

vtguru posted on 2019-5-17 07:18:22

Software simulated (GPIO) I2C using timing configuration parameters to control each individual timing requirement in I2C protocol.
Below is one example of software I2C function:
    // An I2C output byte is bits 7-0 (MSB to LSB). Shift one bit at a time to
    // the SDATA output, and then clock the data to the I2C Slave device.   
    // Send 8 bits out the port   
    for(ibit = 0; ibit < 8; ibit++) {
      if (data & shiftData) {

swi2c_sda_high(Channel);
      } else {

swi2c_sda_low(Channel);
      }
      swi2c_udelay(swi2c_time.tSU_DAT);    // tSU, Min:4.7us

      swi2c_scl_high(Channel);
      swi2c_udelay(swi2c_time.tHIGH);    // tHIGH, Min:4.0us
      
swi2c_scl_low(Channel);
      swi2c_udelay(swi2c_time.tLOW);    // tLOW, Min:4.7us
    }

above content is doing bit writing;
swi2c_udelay: us delay function


So it's function calling delay, even delay parameter is 0 , still take some time to run this function.
For all of I2C timing configuration, it is relatively configuration, not accurate as hardware.


Page: [1]
View full: Why software i2c time configuration 0 is still working?