Hi,
I have a OMAPL137 connected to an FRAM (FM24CL16B) which is a non-volatile ram over an I2C interface.
With my code, I am always able to write one byte less than what i have planned. The last byte gets stuck somehow ...... Below is the code ...
void i2c0_write (Uint16 addr,Uint8* data, Uint16 len)
{
Uint16 i;
I2C0_ICMDR = ICMDR_STT // Set for Master Write
| ICMDR_TRX
| ICMDR_MST
| ICMDR_IRS;
I2C0_ICSAR &= 0xF8; //Clear last three bits which represent address
I2C0_ICSAR |= (addr & 0x0700)>>8; //Last three bits of slaveID contains FRAM address
I2C0_ICCNT = len+1; //for sending FRAM address
EVMOMAPL137_wait( 10 ); // Short delay
I2C0_ICDXR = (Uint8)(addr & 0x00FF);
do
{
} while ( ( I2C0_ICSTR & ICSTR_ICXRDY ) == 0 );// Wait for Tx Ready
for ( i = 0 ; i < len ; i++ )
{
I2C0_ICDXR = data[i]; // Write
do
{
} while ( ( I2C0_ICSTR & ICSTR_ICXRDY ) == 0 );// Wait for Tx Ready
}
I2C0_ICMDR |= ICMDR_STP; // disable
}
Int16 testI2C()
{
Uint8 p[]={0xCA,0xCA,0x0E};
Uint16 ad=0x0123;
i2c0init(50);
i2c0_write(ad,p,3);
return 0;
}
Any help would be appreciated ... thanks,
AQ