This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

I2C communication problems TMS320F28035

Other Parts Discussed in Thread: DAC8574

Hi,

I have some problems to comunicate with my digital pot in I2C (Microchip MCP4552).

I work with a custom board, I can already comunicate with an I2C FRAM (FM24V10-G) and an I2C DAC (TI DAC8574)

First what I want to do is initiate the pot by setting the pot to the minimum. To do that I have to write $00 in the data byte

This is the code :

Uint8 i2cPOT_WriteData(Uint8 UI8_I2CAddress, Uint8 UI8_Mem_Address, Uint8 UI8_CmdOp,  Uint16 UI16_PotCmd){

                      Uint8 UI8_Cmd_Byte = (UI8_Mem_Address << 4);

                      UI8_Cmd_Byte |= (UI8_CmdOp << 2);

                      UI8_Cmd_Byte |= (UI16_PotCmd >> 8);

 

                     // Wait until the STP bit is cleared from any previous master communication.

                     // Clearing of this bit by the module is delayed until after the SCD bit is

                     // set. If this bit is not checked prior to initiating a new message, the

                     // I2C could get confused.

                     if (I2caRegs.I2CMDR.bit.STP == 1)

                     {

                        return I2C_STP_NOT_READY_ERROR;

                     }

 

                     // Setup slave address

                     I2caRegs.I2CSAR = UI8_I2CAddress;

 

                     // Check if bus busy

                     if (I2caRegs.I2CSTR.bit.BB == 1)

                     {

                        return I2C_BUS_BUSY_ERROR;

                     }

 

                     // Setup number of bytes to send

                     // MsgBuffer + Address

 

                     I2caRegs.I2CCNT = 2;

 

                     // Setup data to send

                     I2caRegs.I2CDXR = UI8_Cmd_Byte;

           I2caRegs.I2CDXR = ((Uint8)(UI16_PotCmd & 0xFF));

                     uiI2CState = NOT_READY;

 

                     // Send start as master transmitter

                     I2caRegs.I2CMDR.all = 0x6E20;

                     return I2C_SUCCESS;

}

This is what I have ! As you can see the TMS320 write only 2 bytes and no stop bit !! What I'm doing wrong ?

Thank you for your help.

Regards, Nicolas

  • Someone can help me please !

  • Hello Nicolas,

    I am not sure this is your case, but I think you may concern too.

    In my case when I tried to write I2C EEPROM, I needed to put delay 5ms after writing, if not the EEPROM will not be written (but when I debugged it step by step, it was written properly).

    So I looked again the datasheet of the EEPROM and found out that it needed 5ms write cycle time.

    I looked the datasheet of your digital pot and i saw that it had many minimum/maximum times that you should be concerned about (for example: Tbuf)

    Maybe you can play a little bit about the time and see whether this is the case.

    Even if it isn't, I wish you to be able to solve it soon.

    Best regards,

    Maria

  • Am trying to read MPU9150 sensors values through I2c by using TMS320F28035piccolo [GPIO28 and GPIO29],my problem is  I don't see the activity on SCL line however. As the pin was initially high, as soon as the code is run, the SCL goes low and stays low. It's not pulsing at all. I'm not seeing SDATA doing any activity either. It stays as it is, high.

    So this code is what I come with

    //**************I2c initialization

    void I2CA_Init(void)
    {
    I2caRegs.I2CMDR.all = 0x0000;

    I2caRegs.I2CSAR = 0x68;

    I2caRegs.I2CPSC.all = 6;

    I2caRegs.I2CCLKL = 10; 

    I2caRegs.I2CCLKH = 5; 

    I2caRegs.I2CIER.all = 0x3E; 

    I2caRegs.I2CMDR.all = 0x0020; 

    I2caRegs.I2CFFTX.all = 0x6000; 

    I2caRegs.I2CFFRX.all = 0x2040; 

    return;
    }

    //************WRITE FUNCTION

    void writeRegisterWithPiccolo(char reg,char write_data,char stop_bit)
    {

    while(I2caRegs.I2CMDR.bit.STP == 1) { //// wait until the STP bit is cleared from any previous master communication
    }

    while (I2caRegs.I2CSTR.bit.BB == 1) { // wait until bus not busy
    }

    // Setup slave address
    I2caRegs.I2CSAR = MPU9150_I2C_ADDR;

    // Setup number of bytes to send
    I2caRegs.I2CCNT = 2;

    // Setup data to send
    I2caRegs.I2CDXR = reg; 

    I2caRegs.I2CDXR = write_data; 


    if(stop_bit == 'y') // if there should be a stop bit at the end of transmission, then

    {
    while(I2caRegs.I2CMDR.all != 0x6E20){
    I2caRegs.I2CMDR.all = 0x6E20; // send start as master transmitter, w/ stop condition once all bytes have been sent
    }

    while(I2caRegs.I2CSTR.bit.SCD != 1) {} // wait until stop condition is detected

    I2caRegs.I2CSTR.bit.SCD = 1; // clear stop condition detected bit in I2C status register

    }

    else // if there should not be a stop condition at end of transmission (master retains control of bus), then

    {
    while(I2caRegs.I2CMDR.all != 0x2620){
    I2caRegs.I2CMDR.all = 0x2620; // start condition, master mode, TX mode
    }

    while(I2caRegs.I2CSTR.bit.ARDY != 1) {} // wait for I2C registers to finish working

    I2caRegs.I2CSTR.bit.ARDY = 1; // clear ARDY bit in I2C status register
    }

    }

    //***************READ FUNCTION

     unsigned short readRegisterWithPiccolo(unsigned char reg)

    {

    while(I2caRegs.I2CMDR.bit.STP == 1) { //// wait until the STP bit is cleared from any previous master communication
    }

    I2caRegs.I2CSAR = MPU9150_I2C_ADDR;

    // Check if bus busy
    while (I2caRegs.I2CSTR.bit.BB == 1){ // wait until bus not busy
    }

    I2caRegs.I2CCNT = 1;
    I2caRegs.I2CDXR = reg;

    while(I2caRegs.I2CMDR.all != 0x2620)
    {
    I2caRegs.I2CMDR.all = 0x2620; // Send data to setup MEMS address
    }
    I2caRegs.I2CCNT = 2; // Setup how many bytes to expect

    while(I2caRegs.I2CMDR.all != 0x2C20)
    {
    I2caRegs.I2CMDR.all = 0x2C20; // 0x2C20 --Send restart as master receiver
    }


    return I2caRegs.I2CDRR;
    }

    PLEASE help me