Lower I2C speed than 100k?

Hi, I was wondering if it was possible to use a lower i2c speed than the standard options? We are running into some reliability issues with our i2c bus on one of our instruments, and think that we would be able to improve this by slowing down the line. Is this possible?

Dear @Brian.Kelly

The T30 hardware can easily be configured to use slower speeds.

  • There is existing binary software (e.g. the RTCSync) which uses hard-coded bit rates. To use a different bit rate this one needs to be rebuilt.
  • For your own software I need more information what kind of software you use to access the i2c.

Finally, did you measure the i2c signals with an oscilloscope? If the speed is the issue, you should easily see that the rising edges are too slow and never reach 3.3V.
If you have the option of changing the hardware, I strongly expect replacing the two pull-up resistors on the SCL and SDA signals with lower values (e.g. 1kΩ) should be enough to stabilize your i2c communication, without adjusting the bit rate.

Regards, Andy

Hi Andy,

We’ve had success using i2c on other instruments, but on this particular application we have a very long bus, which I think is the main contributing factor to the unreliability. I don’t think that changing the hardware is going to be the best solution for us, as that may have implications for the devices on the bus.

We are using the “TdxAllLibrariesDll” version 2.3.0.4527 library for Windows Compact 2013. Is there a configuration setting through this DLL that we can set to lower the speed, or possibly a registry value?

Thank you,
Brian Kelly

Dear @Brian.Kelly

Please refer to the I2c_Demo application which comes in the library download package

Try to call the I2c_SetConfigInt() function as below:

I2c_SetConfigInt(i2c, L"BitRateHz", 400000,  StoreVolatile);  // Set I2C speed to 400KHz

I had a quick look at the source code and didn’t find any limitation to the standard bitrates (100kHz, 400kHz). So I would expect you can configure lower frequencies here.
However, I didn’t test it.
I would appreciate if you post here. whether it worked for you.

Regards, Andy

Hey Andy,

I tried this and I can’t get the i2c speed to change at all, even to 400k. Below is a slightly simplified version of our bus initialization code:

            _handle = TdxNativeMethods.i2c.I2c_Init(Index);
            if (_handle == IntPtr.Zero)
                throw new System.IO.IOException("Unable to initialize I2C");
            if (!TdxNativeMethods.i2c.I2c_Open(_handle))
                throw new System.IO.IOException("Unable to open I2C");

            // Here is where we should be setting the speed
            if (!TdxNativeMethods.i2c.I2c_SetConfigInt(_handle, "BitRateHz", i2cSpeed, TdxNativeMethods.TdxCommon.ParamStorageType.StoreVolatile))
                    throw new Exception("Failed to set BitRateHz");

            if(!TdxNativeMethods.i2c.I2c_SetConfigInt(_handle, "Timeout", 1, TdxNativeMethods.TdxCommon.ParamStorageType.StoreVolatile))
                throw new Exception("Failed to set timeout");
            if(!TdxNativeMethods.i2c.I2c_SetConfigInt(_handle, "SlaveAddrSize", 7, TdxNativeMethods.TdxCommon.ParamStorageType.StoreVolatile))
                throw new Exception("Failed to set SlaveAddrSize");
            if (!TdxNativeMethods.i2c.I2c_SetConfigInt(_handle, "RegisterAddrSize", 8, TdxNativeMethods.TdxCommon.ParamStorageType.StoreVolatile))
                throw new Exception("Failed to set RegisterAddrSize");

I’m not getting an exception that says we can’t set the BitRateHz, so it appears to be succeeding, but when I look at the line with a scope, the timing doesn’t change. Any ideas?

Dear @Brian.Kelly,

Thank you for your test results.

We have a Dotnet demo application (\libdemos\dotnet\I2cDemo) in the library release package. Could you quickly test with that application and let us know the result.