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.

TLV320AIC3254 Reg Write problems

Other Parts Discussed in Thread: CC3200

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;
}

  • Hi, Dav,

    A possible reason could be that the reserved registers are being written. Writing on a reserved register won't have any effect on the value. The read value would be different than the written value. Have you verified that you're writing on R/W registers?

    Best regards,
    Luis Fernando Rodríguez S.
  • Hi Luis Fernando,

    Thanks for your help.  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;
    }


    As you have said, in the reserved registers the read value is unexpected, but there are other registers (that are not reserved), where the read value is different to the write value (like 4th, 5th or 6th register in Page 0, this is MDAC and DAC OSR registers).

    On the other hand betwen write and read operations, the function wait (MAP_UtilsDelay(27000)) without check any flag. Why? There will be some register flag to replace this active waiting?

  • Hi, Dav,

    Could you post this question on the SimpleLink™ WiFi CC31xx/CC32xx Forum? They may help you with your questions about your write function. 

    Please let me know if you have specific questions about the audio converters. I will be glad to help you.

    Best regards,
    Luis Fernando Rodríguez S.

  • Hi, Luis Fernando

    Ok, I'm going to post it in that forum. Thanks for your help.