MCP4725 DAC Setting High-Speed Mode

Hello,

I’m developing an application that talks with two MCP4725 DACS.

The DACs are on the same bus and they have different address 0x60 and 0x61.

The communication is fine, I can write normally to each DAC, the problem is I cannot reach an high speed rate of write commands. The best I have is 2000 writes per second in total.

I’ve tryied to set the Standard (100 kbps) and the Fast (400 kbps) Modes but nothing changes, the rate is the same.

Could you help me?

Here is the code I use:

For the initialization:

public MCP4725(uint Address)
        {
            bool bResult = false;
            i2cHandle = i2c.I2c_Init("I2C1");                                                   ///< get handle to I2C device
            if (i2cHandle == IntPtr.Zero)
            {
                Program.cGlobals.cLogging.LogMessage("MCP4725 --> Error in I2c_Init()");
            }
            if (!i2c.I2c_Open(i2cHandle))                                                       ///< open I2c for communication
            {
                Program.cGlobals.cLogging.LogMessage("MCP4725 --> Error: I2C Open");
            }
            bResult = i2c.I2c_SetConfigInt(i2cHandle, "BitRateHz", 100000, TdxCommon.ParamStorageType.StoreVolatile); ///< Configuring I2C channel with appropriate settings
            bResult = i2c.I2c_SetConfigInt(i2cHandle, "SlaveAddrSize", 7, TdxCommon.ParamStorageType.StoreVolatile);

            DeviceAddress = Address;

            bResult = i2c.I2c_SetConfigInt(i2cHandle, "SlaveAddr", DeviceAddress, TdxCommon.ParamStorageType.StoreToRegistry);
            bResult = i2c.I2c_SetConfigInt(i2cHandle, "RegisterAddrSize", 0, TdxCommon.ParamStorageType.StoreToRegistry);

            bStarted = false;
        }

For the Write Command:

public void WriteRegister(int iValue)
        {
            if (bReverse)
                iValue = MAX_VALUE - iValue;

            //Modalità non fast
            //uint bufferLenght = 3;
            //Byte[] DataToWrite = new Byte[bufferLenght];
            //DataToWrite[0] = MCP4726_CMD_WRITEDAC;           // cmd to update the DAC
            //DataToWrite[1] = (byte)(iValue >> 4);            // the 8 most significant bits... (D11.D10.D9.D8.D7.D6.D5.D4)
            //DataToWrite[2] = (byte)((iValue & 15) << 4);     // the 4 least significant bits... (D3.D2.D1.D0)    

            //Modalità fast
            uint bufferLenght = 2;
            Byte[] DataToWrite = new Byte[bufferLenght];
            DataToWrite[0] = (byte)((iValue & 3840) >> 8);
            DataToWrite[1] = (byte)(iValue & 255);
            try
            {
                unsafe
                {
                    fixed (byte* for_Casting_Intptr_to_Byte = DataToWrite)
                    {
                        returnValue = i2c.I2c_Write(i2cHandle, (IntPtr)for_Casting_Intptr_to_Byte, bufferLenght);
                        if (returnValue == 0)
                            throw new Exception();                                            ///< If Write operation returns 0
                    }
                }
            }
            catch (Exception ex)
            {
                Program.cGlobals.cLogging.LogMessage("Scrittura Configurazione Fallita - Codice Errore: " + ex.Message);
            }
        }

Thanks in advance for your support.

The pull-up resistors are both 4.7 KOhm

Dear @emmettbrown,

Could you share detailed hardware and software details?
WinCE version?
WinCE release version?
Toradex CE libraries version?
carrier board details?

Could you try to test with Toradex CE libraries (2.3b4555 | 2019-01-07 | 7.93 MB) because we solved an i2c speed bug on that release and let us know the result?

Is that I2c communication always works on 100Kbps and 400KHz not working?

There are different I2c speed standards are available: standard mode: 100 kbit/s, full speed: 400 kbit/s, fast mode:1 mbit/s, high speed: 3.2 Mbit/s. Let us know which speed mode you are trying?

Our toradex CE libraries support 100KHz or 400KHz mode only.

The WinCE Version is Windows CE8 Ver. 1.3

The libraries are the toradexcelibraries_2.2-20180516

I’ve tested the latest version of the libraries the toradexcelibraries_2.3b4555-20190107 and it’s working correctly now.

The problem was that the 400kbit/s didn’t work before the library update.

Thank you so much.

The WinCE Version is Windows CE8 Ver. 1.3

The libraries are the toradexcelibraries_2.2-20180516

I’ve tested the latest version of the libraries the toradexcelibraries_2.3b4555-20190107 and it’s working correctly now.

The problem was that the 400kbit/s didn’t work before the library update.

Thank you so much.