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.

AIC3256 Setup I2C

Hi,

I'm a little bit lost setting up my AIC3256 from my MCU. Any help would be greatly appreciated. I'm loading the program over I2C.  I'm not sure if I'm loading my application the wrong way, or if I'm missing out on some other things that I need to do. 

To simplify things, I have made an extremely simple application in PPS containing a Tone generator, a splitter and a stereo output. This program generates a tone to J4 jack on the AIC3254EVM-U . I'm now having problems getting this to work on my board. 
I have generated register tables from PPS, base_main_Rate44_pps_driver.h. If I have understood it correctly, this file contains all initialization settings for the AIC3256 and my PPS-application. 

I found an  example posted by J Arbona, in this forum, how to write the driver file with SPI, and modified it for I2C. Changed the register addresses to 8-bit addresses, otherwise basically the same. It felt quite straight forward. 

I have tested my I2C with an E2PROM and both writing and reading works fine. I don't get any errors, timeout or NAKS while I'm writing my application to the AIC3256 on my board. 

After I have written all the data from the three registers (REG_Section_program, miniDSP_A_reg_values and miniDSP_D_reg_values), I here a low click-sound in my headphones which are connected to my board. But no tone like on the EVM. 

Am I missing out on some steps here? Do I need to configure anything else except for the base_main_Rate44_pps_driver  to get the tone to work? 

I'm loading the application with the function below. The DSP_A and DSP_D regs are loaded with the same function but without the switch. I call the function with the total length of each Register. 

//Johnny

/**
* @brief Writes the complete application register setup
* to the AIC3256 module.
*
* @param none
* @retval none
*/
static int ifcAIC3256_WriteApp(const reg_value *data,
const reg_value *DSP_A_data,
const reg_value *DSP_D_data,
unsigned int length_data,
unsigned int length_DSP_A,
unsigned int length_DSP_D)
{
int tx_length = 0;
int bytes_written = 0;
int match = 0;
int z = 0;
for (int i = 0; i < length_data; i++)
{
switch (data[i].reg_off)
{
case 254: // Delay case
DebugPrintLine("Delay: ");
DebugPrintU32(data[i].reg_val);

modSysTick_Delay(data[i].reg_val);
break;

case 255: // miniDSP code case
if (data[i].reg_val == 0x00)
{
DebugPrintLine("DSP_A");
dsp_a_bytes = ifcAIC3256_WriteDSPReg(DSP_A_data, length_DSP_A);
DebugPrintLine("End_DSP_A");
}
else
{
if (data[i].reg_val == 0x01)
{
DebugPrintLine("DSP_D");
dsp_d_bytes = ifcAIC3256_WriteDSPReg(DSP_D_data, length_DSP_D);
DebugPrintLine("End_DSP_D");
}
}
break;

default:
rx_reg_buf[0] = (data[i].reg_off);
tx_reg_buf[tx_length++] = (data[i].reg_off);
tx_reg_buf[tx_length++] = (data[i].reg_val);
bytes_written++;
// Determine if register is contiguous
while ((data[i].reg_off + 1 == data[i + 1].reg_off) && ((i + 1) < length_data))
{
tx_reg_buf[tx_length++] = (data[++i].reg_val);
bytes_written++;
}

modI2C_WriteI2C2(tx_reg_buf, tx_length);
tx_length = 0;
}
}
return bytes_written;
}

  • Hi Johnny,

    I suggest you verify:

    1) If code is working properly.

    2) If register settings correspond to the setting in your board.

    For #1, I suggest you use an I2C sniffer tool to cross-check that the data sent matches the data received.

    For #2, Are there any major changes in your board with respect to AIC3256EVM-U circuit? Is master clock active and is I2S provided to the AIC3256? I2S must be active either internally or externally so if you don't connect I2S to another chip, then you need to configure the AIC3256 with BCLK and WCLK as outputs and configure the BDIV divider accordingly.

    Regards,

    J-

  • Hello J,

    Thank you for the fast reply. I have made some progress, but I'm still having problems with the configurations. I do not have the I2S signals connected. 

    My Hardware:
    The board I'm testing out is actually another AIC3256EVM-U, with  the TAS1020 and the E2PROM removed. My MCU Application is currently running from a PIC18 Evaluation board. I have connected the I2C bus, the reset signal and GND to the stripped  AIC3256EVM-U. I'm using an external function generator to generate 11.289MHz to MCKL. 

    1) Code verification
    I verified the firmware by loading the same application to the unmodified AIC3256EVM-U via PPS and to the modified board via I2C from my PIC. I connected the MCKL, WCLK and BCLK from the unmodified AIC3256EVM-U, to the other board, and I got a tone out to my headphones.
    An interesting thing, when MCKL was connected, it was actually enough to just touch the BCLK for a short instant and the Tone began to sound and remained after removing the BCLK connection. 

    I have configured the BCLK and WCLK as outputs and tried to set up the divider settings. I'm using the Coded Clock configuration, not the PLL.  But I'm only getting a lot of white noise to my headphones. I have verified the MCLK, BCLK and WCLK with an Oscilloscope and they have the same frequencies as the unmodified EVM.   

    My clock configurations are as follows:

    Codec Input Clock -> MCLK 11,2896MHz
    DAC_CLK = 2,8 MHz
    ADC_CLK = 2,8 MHz 
    DAC_MOD_CLK = 44,1 kHz 
    DAC_FS_CLK = 44,1 kHz 
    ADC_MOD_CLK = 44,1 kHz  
    ADC_FS_CLK = 44,1 kHz   

    At the moment my setup looks like following:

    1: I reset the circuit

    2: I write the complete (unmodified) register settings in the pps_driver.h

    3: I write the following sequence

    { 0x00, 0x00},   // Page 0
    { 0x21, 0x00},   // Audio Interface Settings Page 0, Reg 32
    { 0x1B, 0x0C},  // Audio Interface Settings - WCLK & BCLK = Outputs
    {0x0B, 0x84},    // NDAC divider - ON, Value 4
    {0x0C, 0xC0},   // MDAC divider - ON, Value 64
    {0x12, 0x84},    // NADC - ON, Value 4
    {0x13, 0xC0},   // MADC - ON, Value 64
    {0x0D, 0x00},   // DSOR Value 1
    {0x0E, 0x01},   //
    {0x14, 0x01},   // AOSR, Value 1
    {0x1D, 0x14},   // Audio Interface settings reg 3, also tried 0
    // {0x19, 0x00}, 
    // {0x20, 0x00},
    { 0x1E, 0x81},   // BCLK ON, divider 1
    { 0x1A, 0x81},   // CLKOUT M divider ON, Value 1

    Am I doing anything wrong here or am I missing to configure something?

    Best regards 

    Johnny

  • Johnny,

    Those clock divider values are out of spec. If you want 44.1kHz out of 11.2896MHz MCLK, then configure the device as follows:

    1) Do not modify PPS clock settings. Leave them as-is and add the lines below at the end of the code.

    { 0x00, 0x00}, // Page 0
    { 0x1B, 0x0C}, // Audio Interface Settings - WCLK & BCLK = Outputs
    { 0x1D, 0x01}, // BDIV_CLKIN = DAC_MOD_CLK
    { 0x1E, 0x81}, // BCLK ON, divider 1

    Regards,

    J-

  • Thanks J, that did the trick! Didn't work the first times, the tone was really off in frequency and amplitude. But after I loaded a different PPS-program it worked perfectly.

    I have some problems with another thing, trying to change volume on a volume controller. But I just can't get it to work. I have logged a change of volume in PPS and converted the data transactions but without the read commands. Just trying to write anything, in this log:  0X00822400. I've also tried to recreate an I2C-scriptfile for PPS, but I'm still not able to do it. Is there anything missing from the PPS-log below?

    Component interface 1: Coeff=0x09
    DSPCoefBlockStartAddress: 0x09
    DSPCoefBlockStartLength: 0x01
    I2CPage: 0x2C 
    I2CRegister: 0x2C 

    Logged this from PPS:

    //Check to make sure swap happened
    R0X0, 0X2C
    //Volume_1 : Volume Level
    W0X2C, 0X0, 0X82, 0X24, 0X0
    //Unknown
    R0X0, 0X2C
    //Unknown
    W0X0, 0X0
    //Unknown
    R0X7F, 0X0
    //Setting Page: 0x2c
    W0X0, 0X2C
    //Read device data for swap
    R0X1, 0X4
    //Swapping DAC buffer
    W0X1, 0X5
    //Check to make sure swap happened
    R0X1, 0X6
    //Volume_1 : Volume Level
    W0X2C, 0X0, 0X82, 0X24, 0X0

    My Command:

    00,2C,  // Select page
    2C,00,  // Write data  
    2D,82,
    2E,24,
    2F,00,
    01,05, 
    FE,10, // Delay 0x10 ms 
    2C,00,
    2D,82,
    2E,24,
    2F,00,

    Best regards,

    Johnny

  • Hi Johnny,

    It seems that you are sending the right commands. One thing you can check is to read the buffer switch flag to see if it really cleared or not. More details are here: http://www.ti.com/lit/pdf/slaa425.

    Thanks,

    J-

  • I got it to work now. 
    I accidentally reconfigured the I2C CLK to an output at a later stage in the initialization of my application.   
    Strangely enough the I2C module didn't complain or throw any errors, but it obviously didn't function as intended.  

    Thanks, 
    /Johnny 

  • Hi Johnny,

    Glad you got it working! Let me know if you have any other questions.

    Regards,

    J-