I am using the AudioCodecRegWrite function, used with the tl320aic3254 audio codec (wifi_audio_app in CC3200 Audio BoosterPack). This function reads register value after write it. I use it, and it fails a lot of times because read value is different of write value. So, maybe I'm doing something wrong.. Which will be the mistake?
Thanks.
Below, you can see the function.
//******************************************************************************
//
// Writes to specfied register
// ulRegAddr - Register Address
// ucRegValue - 8 bit Register Value
//
//******************************************************************************
static unsigned long AudioCodecRegWrite(unsigned char ulRegAddr,unsigned char ucRegValue)
{
unsigned char ucData[2];
ucData[0] = (unsigned char)ulRegAddr;
ucData[1] = ucRegValue;
val[1]=ucData[1];
#if 0
if(I2C_IF_ReadFrom(0x44,&ucRegAddr, 1, &ucRegData[0], 2) != 0)
return -1;
#endif
J=I2C_IF_Write(CODEC_I2C_SLAVE_ADDR, ucData, 2, 1);
if(J !=0)
return (1U<<31);
MAP_UtilsDelay(27000);
J=I2C_IF_ReadFrom(CODEC_I2C_SLAVE_ADDR, &ucData[0], 1,&val[0],1);
if(J !=0)
return (1U<<31);
if(val[0] != val[1])
++I;
return 0;
}