I2C on VF61/WinCE 7 - writing instead reading PCF

Hello,

when I read first time after start from PCF8574, it not only read, but it first writes 0 to PCF, then read it.

Is it bug in library or am i doing it wrong?

if (_i2c != null)
            {
                byte[] _buffer = new byte[_length];
                IntPtr _pnt = Marshal.AllocHGlobal(Marshal.SizeOf(_buffer));
                if (i2c_vyb.VybI2c_Read(_i2c, _pnt, _length) == i2c.I2C_RW_FAILURE)
                    return null;
                Marshal.Copy(_pnt, _buffer, 0, (int)_length);

                Marshal.FreeHGlobal(_pnt);
                _pnt = IntPtr.Zero;

                return _buffer;
            }
            else
                return null;

Thanks
Jakub

Hi Jakub,

Did you set “RegisterAddrSize” to 0 through I2c_SetConfigInt function?
I2c_SetConfigInt(i2c, L"RegisterAddrSize", 0, StoreVolatile); // No Register address to send function

For more information, please refer our “Toradex_CE_Libraries.chm” document.

Hello,

I set first time after init :

if (!i2c_vyb.VybI2c_SetConfigInt(_i2c, "BitRateHz", 100000, TdxCommon.ParamStorageType.StoreToRegistry)) return false;
            if (!i2c_vyb.VybI2c_SetConfigInt(_i2c, "Timeout", 2000, TdxCommon.ParamStorageType.StoreToRegistry)) return false;
            if (!i2c_vyb.VybI2c_SetConfigInt(_i2c, "SlaveAddrSize", 7, TdxCommon.ParamStorageType.StoreToRegistry)) return false;

            if (!i2c_vyb.VybI2c_SetConfigInt(_i2c, "SlaveAddr", _address, TdxCommon.ParamStorageType.StoreToRegistry)) return false;
            if (!i2c_vyb.VybI2c_SetConfigInt(_i2c, "RegisterAddr", 0, TdxCommon.ParamStorageType.StoreToRegistry)) return false;
            if (!i2c_vyb.VybI2c_SetConfigInt(_i2c, "RegisterAddrSize", 0, TdxCommon.ParamStorageType.StoreToRegistry)) return false;