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.

eeprom writiand reading problem with c2000 TMS320F28027 controller

Other Parts Discussed in Thread: TMS320F28027, CONTROLSUITE

Hi friend ,

I have return eeprom interface with c2000  TMS320F28027 through i2c . I have problem in read and write please any one help me

this is my code...

    while(I2caRegs.I2CSTR.bit.XRDY == 0){};
    I2caRegs.I2CDXR = *txBuf_pu8;

}

void i2cRead(Uint16 memAddr_u16, unsigned char *rxBuf_pu8, Uint32 rxDataLen_u32)
{
    Uint32 i = 0;
    I2caRegs.I2CSAR = I2C_SLAVE_ADDR;             //Set slave address
    I2caRegs.I2CCNT = 2;                         //Set count to 2 address bytes
    I2caRegs.I2CDXR =((memAddr_u16 >> 8) & 0xFF);            //Send eeprom high address
    I2caRegs.I2CMDR.bit.TRX = 1;                 //Set to Transmit mode
    I2caRegs.I2CMDR.bit.MST = 1;                 //Set to Master mode
    I2caRegs.I2CMDR.bit.FREE = 1;                //Run in FREE mode
    I2caRegs.I2CMDR.bit.STP = 0;                 //Dont release the bus after Tx
    I2caRegs.I2CMDR.bit.STT = 1;                 //Send the start bit, transmission will follow
    
    while(I2caRegs.I2CSTR.bit.XRDY == 0){};         //Do nothing till data is shifted out
    I2caRegs.I2CDXR = ( memAddr_u16 & 0xFF );              //Send eeprom low address
    I2caRegs.I2CCNT = rxDataLen_u32;                //read 5 bytes from eeprom
    I2caRegs.I2CMDR.bit.TRX = 0;                 //Set to Recieve mode
    I2caRegs.I2CMDR.bit.MST = 1;                 //Set to Master mode
    I2caRegs.I2CMDR.bit.FREE = 1;                //Run in FREE mode
    I2caRegs.I2CMDR.bit.STP = 1;                 //Stop when internal counter becomes 0
    I2caRegs.I2CMDR.bit.STT = 1; //Repeated start, Reception will follow
    for(i = 0; i < rxDataLen_u32; i++)
    
        while(I2caRegs.I2CSTR.bit.RRDY == 0){};     //I2CDRR not ready to read?
        *rxBuf_pu8 = I2caRegs.I2CDRR;
        rxBuf_pu8++;
    }
}


void main(void)
{
       Uint16 address = 0x0005;
       unsigned char txdata = 'H';
       unsigned char rxdata = 0;

       InitSysCtrl();
       InitI2CGpio();
       DINT;
       InitPieCtrl();
       IER = 0x0000;
       IFR = 0x0000;
       InitPieVectTable();
       i2cInit();
       EINT;

       i2cWrite( address, &txdata, 1);

       while(1)
       {
           i2cRead( address, &rxdata, 1);
       }
}