Hi everybody
In the wifi_audio_app, I'm using the AudioCodecRegWrite function to program codec registers. As you can see, this function read the registers after write it, and I can observe that some registers (not protected) the read value is different than the write value (like 4th, 5th or 6th register in Page 0, this is MDAC and DAC OSR registers). Why?
I read values written into the write function, with the next code:
//******************************************************************************
//
// 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;
LOG_MSG("[AudioCodecRegWrite] Reg %.2x\r\n",ucData[0]);
LOG_MSG("[AudioCodecRegWrite] Desired value = %.2x\r\n",val[1]);
LOG_MSG("[AudioCodecRegWrite] Written value = %.2x\r\n\r\n",val[0]);
LOG_FLUSH();
return 0;
}
On the other hand, the function uses a delay betwen write and read operation. It will be possible use a control register flag instead of the active waiting?