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.

TMS320F28335 and i2c problem

Other Parts Discussed in Thread: TMS320F28335

Hi every body

I wrote a program with TMS320F28335 and use I2C but I2C didn't work.

I didn't use FIFO and I didn't enable FIFO.

I checked the sample program(Example_2833xI2C_eeprom.pjt) but I don't know where is my mistake?

my program is:

void I2C_init()
{
    asm(" Eallow");
    *PCLKCR0|=0x0010;
    I2caRegs.I2CMDR.all=0;
    I2caRegs.I2CPSC.bit.IPSC=14;
    I2caRegs.I2CCLKH=30;
    I2caRegs.I2CCLKL=30;
    I2caRegs.I2CSAR=0x52;
    I2caRegs.I2CMDR.bit.IRS=1;   

    GpioCtrlRegs.GPBPUD.bit.GPIO32 = 0;    // Enable pull-up for GPIO32 (SDAA)
    GpioCtrlRegs.GPBPUD.bit.GPIO33 = 0;       // Enable pull-up for GPIO33 (SCLA)
    GpioCtrlRegs.GPBQSEL1.bit.GPIO32 = 3;  // Asynch input GPIO32 (SDAA)
    GpioCtrlRegs.GPBQSEL1.bit.GPIO33 = 3;  // Asynch input GPIO33 (SCLA)
    GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 1;   // Configure GPIO32 for SDAA operation
    GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 1;   // Configure GPIO33 for SCLA operation

    asm(" edis");
       
}

////////////////////////////////////////////////////////////////

void I2C_Write(unsigned int *buf,unsigned int num)
{
    unsigned int i;
    I2caRegs.I2CMDR.bit.MST=1;
    I2caRegs.I2CSAR=0x52;
    I2caRegs.I2CCNT=num;   
    I2caRegs.I2CMDR.bit.TRX=1;
       
    for(i=0;i<60000;i++)
        ;
       
    while(I2caRegs.I2CSTR.bit.BB!=0);
    I2caRegs.I2CMDR.bit.STT=1;
    I2caRegs.I2CMDR.bit.STP=1;   
   
    for(i=0;i<num;i++)
    {
        while(I2caRegs.I2CSTR.bit.XRDY==0);
        I2caRegs.I2CDXR=buf[i];
    }

}

///////////////////////////////////////////////////////

void I2C_Read(unsigned int *buf,unsigned int num)
{
    unsigned int i;
    I2caRegs.I2CSAR=0x52;
    I2caRegs.I2CCNT=2;   
    I2caRegs.I2CMDR.bit.TRX=1;   
    I2caRegs.I2CMDR.bit.MST=1;
    for(i=0;i<60000;i++)
        ;

    while(I2caRegs.I2CSTR.bit.BB!=0);
    /*I2caRegs.I2CMDR.bit.STT=1;

    for(i=0;i<2;i++)
    {
        while(I2caRegs.I2CSTR.bit.XRDY==0);
        I2caRegs.I2CDXR=buf[i];
    }
    for(i=0;i<60000;i++)
        ;     
    I2caRegs.I2CMDR.bit.MST=1;
    I2caRegs.I2CSAR=0x5A;                  //for read operation
    I2caRegs.I2CMDR.bit.TRX=0;
    I2caRegs.I2CCNT=num;   
    I2caRegs.I2CMDR.bit.STT=1;
    I2caRegs.I2CMDR.bit.STP=1; 

    for(i=0;i<num;i++)
    {
        while(I2caRegs.I2CSTR.bit.RRDY==0);
        buf[i]=I2caRegs.I2CDRR;
    }   
}

///////////////////////////////////////

but it dosen't work.

please help me.

with best regards,

Ali Karbasi