Part Number:TMS320C5535
Hello,
we use C55 CSL on the C5535 DSP and write/read the AIC3254 audio codec via chip support I2C functions. Writing works fine. Reading also works, but after several seconds the I2C bus hangs up. The I2C_Read() function returns CSL_I2C_NACK_ERR and CLK line stays low. When calling I2C_Read() again afterwards, CSL_I2C_BUS_BUSY_ERR is returned.
CSL_Status I2CBus_Init(Uint32 i2cInClk)
{
CSL_I2cSetup i2cSetup;
CSL_Status result;
// I2C hardware initialization
result = I2C_init(CSL_I2C0);
if (result != CSL_SOK)
{
return result;
}
// I2C setup
i2cSetup.addrMode = CSL_I2C_ADDR_7BIT;
i2cSetup.bitCount = CSL_I2C_BC_8BITS;
i2cSetup.loopBack = CSL_I2C_LOOPBACK_DISABLE;
i2cSetup.freeMode = CSL_I2C_FREEMODE_ENABLE;
i2cSetup.repeatMode = CSL_I2C_REPEATMODE_DISABLE;
i2cSetup.ownAddr = I2C_OWN_ADDR;
i2cSetup.sysInputClk = i2cInClk;
i2cSetup.i2cBusFreq = I2C_BUS_FREQ;
result = I2C_setup(&i2cSetup);
if (result != CSL_SOK)
{
return (result);
}
return CSL_SOK;
}
status = AIC3254_Read((Uint16) 0, (Uint16*) &value);
if (status != CSL_SOK)
{
printf("ERROR; %d\n", status);
}
CSL_Status AIC3254_Read(Uint16 regAddr, Uint16 *data)
{
return (I2C_Read(I2C_CODEC_ADDR, regAddr, data));
}
CSL_Status I2C_Read(Uint16 slaveAddr, Uint16 regAddr, Uint16 *data)
{
volatile Uint16 looper;
CSL_Status status = CSL_ESYS_FAIL;
Uint16 readCount = 1;
Uint16 readBuff[1];
Uint16 startStop = ((CSL_I2C_START) | (CSL_I2C_STOP));
regAddr = (regAddr & 0x00FF);
// read the data
status = I2C_read(readBuff, readCount, slaveAddr, ®Addr, 1, TRUE,
startStop, CSL_I2C_MAX_TIMEOUT>>4, FALSE);
if (status != CSL_SOK)
{
return status;
}
*data = readBuff[0];
for (looper = 0; looper < CSL_I2C_MAX_TIMEOUT>>4; looper++)
{
;
}
return status;
}
It seems as if the codec doesn't send the ack. How can we recover from this situation, so that the I2C bus can be used again?
Thanks in advance and have a nice day
Marc