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.

TLV320AIC3105: Programming the codec for most basic passthrough operation

Part Number: TLV320AIC3105
Other Parts Discussed in Thread: TLV320AIC3104,

Hello, 

There is a document called TLV320AIC3104 Programming Made Easy SLAA403 which I'm using as a reference. It has a startup script listed at the end of the document. I'm trying to refer to that to get the 3105 up and running. 

I'm starting with a simple example... I figured, let me "Power up Left and Right DAC’s" which is page 0x00 register 0x25 (37). I'm doing a hardware reset (pull reset low for, then go high). And then I'm doing a software reset (write to the reset register). 

// hardware reset
  pinMode(RESET_PIN,OUTPUT); 
  digitalWrite(RESET_PIN,HIGH);delay(50); //not reset
  digitalWrite(RESET_PIN,LOW);delay(100);  //reset
    Serial.println("-----this should fail-----");
    writeRegister(wires, dev, Page_00, 0x01, 0b10000000); 
    Serial.println("-----now turning it back on-----");
  digitalWrite(RESET_PIN,HIGH);delay(50);//not reset
    Serial.println("-----Hardware reset complete-----");



	// reset to defaults                    
	writeRegister(wires, dev, Page_00, 0x01, 0b10000000); // Reset Module | 0b00010001 | 0x11
  	writeRegister(wires, dev, Page_00, 0x01, 0b00000000); // Reset Module | 0b00010001 | 0x11
    if (debugToSerialTLV320AIC3105) Serial.println("-- Software Reset Complete ---");
  // wait for device to initialize
	delay(50);  

  //TEST SIMPLE DAC ENABLE/DISABLE. 
  writeRegister(wires, dev, Page_00, 37, 0b1110000);delay(50); // 
  writeRegister(wires, dev, Page_00, 38, 0b00010100);delay(50); //
    writeRegister(wires, dev, Page_00, 40, 0b11010101);delay(50); // 
dumpAllRegisters(wires, dev);

But when I run the code the result doesn't "stick" is there something that I must do first in order to make the I2C settings stick when writing to them?

---Starting ----
Debugging to serial
AudioControlTLV320AIC3105::enableTLV320AIC3105
-----this should fail-----
controlTLV320AIC3105: Received Error During goToPage(): Error = 2
failed to transmit address
controlTLV320AIC3105: INFO: Read Page.  Page: 0 Reg: 1.  Failed to go to read page.  Could not go there.
Write:	 Wire:0	 TLV320AIC3105:24	 P0_R1	 P0x00_R0x1	 0x80	 128	 0b10000000
controlTLV320AIC3105: Received Error During goToPage(): Error = 2
failed to transmit address
controlTLV320AIC3105: Received Error During writePage(): Error = 2
-----now turning it back on-----
-----Hardware reset complete-----
Read:	 Wire:0	 TLV320AIC3105:24	 P0_R1	 P0x00_R0x1	 0x0	 0	 0b0
Write:	 Wire:0	 TLV320AIC3105:24	 P0_R1	 P0x00_R0x1	 0x80	 128	 0b10000000
Read:	 Wire:0	 TLV320AIC3105:24	 P0_R1	 P0x00_R0x1	 0x0	 0	 0b0

Read:	 Wire:0	 TLV320AIC3105:24	 P0_R1	 P0x00_R0x1	 0x0	 0	 0b0
Write:	 Wire:0	 TLV320AIC3105:24	 P0_R1	 P0x00_R0x1	 0x0	 0	 0b0
Read:	 Wire:0	 TLV320AIC3105:24	 P0_R1	 P0x00_R0x1	 0x0	 0	 0b0

-- Software Reset Complete ---
Read:	 Wire:0	 TLV320AIC3105:24	 P0_R37	 P0x00_R0x25	 0x0	 0	 0b0
Write:	 Wire:0	 TLV320AIC3105:24	 P0_R37	 P0x00_R0x25	 0x70	 112	 0b1110000
Read:	 Wire:0	 TLV320AIC3105:24	 P0_R37	 P0x00_R0x25	 0x0	 0	 0b0

Read:	 Wire:0	 TLV320AIC3105:24	 P0_R38	 P0x00_R0x26	 0x0	 0	 0b0
Write:	 Wire:0	 TLV320AIC3105:24	 P0_R38	 P0x00_R0x26	 0x14	 20	 0b10100
Read:	 Wire:0	 TLV320AIC3105:24	 P0_R38	 P0x00_R0x26	 0x0	 0	 0b0

Read:	 Wire:0	 TLV320AIC3105:24	 P0_R40	 P0x00_R0x28	 0x0	 0	 0b0
Write:	 Wire:0	 TLV320AIC3105:24	 P0_R40	 P0x00_R0x28	 0xD5	 213	 0b11010101
Read:	 Wire:0	 TLV320AIC3105:24	 P0_R40	 P0x00_R0x28	 0x0	 0	 0b0

What are the basic steps to initializing the codec? Sorry for the basic question here, I've been toying with this for a few days and I'm looking for some help to hopefully get this moving. Thank you!

  • Hello Jay,

    Thanks for reaching out, we are happy to help. 

    The basic start-up sequency is (1) power on supplies. Once all supplies are stable (2) perform as software reset of the CODEC. After this, the device is able to be configured over I2C. The CODEC GUI has an initialization script that may be a useful resource. 

    Usually, the issue of register writes not "sticking" is due to the device not receiving a valid I2C read/write. Please probe SDA and SDL to make sure the bus has valid I2C read/writes from the host controller. You can also read a register that has a non 0 initial value like Page 0/Register 58 (default 0x06) to make sure the I2C is working properly.

    If possible, please also share the host controller and Operating System that is being used.

    Let me know the results.

    Best,
    Andrew

  • Good morning, 

    My project has a Teensy 4.1 running the TLV320AIC3105. I've done a lot of testing and I can confirm that I2S is stable, and the I2C is controlling the device. 

    The CODEC GUI has an initialization script that may be a useful resource

    That sounds like exactly what I need. I'm going to attempt to install and use this, I've used the GUI before for other projects. Can I get to it without the EVM? Can you send me a copy of the script?

    Jay

  • Hello Jay,

    Yes, you can run the GUI without the EVM by selecting "DEMO" when prompted. Select the desired presets in the "Preset configuration" tab and select "Load" script. Then, a script will be generated into the "Command Line interface" section. The GUI assumes that it writes start at page 0. It is a good idea to add lines to the GUI preset script for a software reset and write to the page register to ensure initial conditions (i.e. w 30 00 00).

     

    Using the preset script is a good starting point, you can tailor the registers to the exact use case if needed. Also note that any change to the GUI will be automatically updated in the Command line script.

    Let me know if you have any more questions.

    I hope this helps,
    Best

  • Hello Andrew, 

    This GUI tool is much better than the other one I've used. It's very nice, thank you. 

    The first question I have is the address for the 3105. It's odd that the GUI tool is trying to call 0x30 because I see it on 0x18 and the datasheet says"The TLV320AIC3105 responds to the I2C address of 001 1000" which is 0b0011000 / 0x18 / or just 24 as a decimal. That's a bit confusing, do you know why?

    I've put together this code where wires is a select to specify the I2c wire, dev is set to 0x18 for address, and Page is just 0x00. 

    //PRESET: 
    // DAC to Stereo Speakers
    
    // Digital audio setup for operation with AC-MODEVM
    
    // Input:
    // DAC
    //     - Left data to LDAC and right data to RDAC
    //     - Volume control = 0dB
    //     - Connected to outputs via mixer mode
    
    // Ouput:
    
    // High Power Outputs
    //     - Differential speaker outputs
    //     - LDAC to HPLOUT/COM
    //     - RDAC to HPROUT/COM
    //     - Mixer gain = 0dB
    //     - Output amplifier gain = 0dB
    
    writeRegister(wires, dev, Page_00, 0x07, 0x8A);// w 30 07 8A
    writeRegister(wires, dev, Page_00, 0x66, 0xA0);// w 30 66 A0
    writeRegister(wires, dev, Page_00, 0x25, 0xC0);// w 30 25 C0
    writeRegister(wires, dev, Page_00, 0x2B, 0x00);// w 30 2B 00
    writeRegister(wires, dev, Page_00, 0x29, 0x02);// w 30 29 02
    writeRegister(wires, dev, Page_00, 0x0E, 0xC0);// w 30 0E C0
    writeRegister(wires, dev, Page_00, 0x2F, 0x80);// w 30 2F 80
    writeRegister(wires, dev, Page_00, 0x40, 0x80);// w 30 40 80
    writeRegister(wires, dev, Page_00, 0x41, 0x0D);// w 30 41 0D
    writeRegister(wires, dev, Page_00, 0x33, 0x0D);// w 30 33 0D

    Everything runs fine with confirmations as viewed below... BESIDES page 0 register 37 which is "Table 42. Page 0/Register 37: DAC Power and Output Driver Control Register". This is an important register to power up Left and Right DACs... 

    -----Hardware reset complete-----
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R1	 P0x00_R0x1	 0x0	 0	 0b0
    Write:	 Wire:0	 TLV320AIC3105:24	 P0_R1	 P0x00_R0x1	 0x1	 1	 0b1
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R1	 P0x00_R0x1	 0x1	 1	 0b1
    
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R1	 P0x00_R0x1	 0x1	 1	 0b1
    Write:	 Wire:0	 TLV320AIC3105:24	 P0_R1	 P0x00_R0x1	 0x0	 0	 0b0
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R1	 P0x00_R0x1	 0x0	 0	 0b0
    
    -- Software Reset Complete ---
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R7	 P0x00_R0x7	 0x0	 0	 0b0
    Write:	 Wire:0	 TLV320AIC3105:24	 P0_R7	 P0x00_R0x7	 0x8A	 138	 0b10001010
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R7	 P0x00_R0x7	 0x82	 130	 0b10000010
    
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R102	 P0x00_R0x66	 0x0	 0	 0b0
    Write:	 Wire:0	 TLV320AIC3105:24	 P0_R102	 P0x00_R0x66	 0xA0	 160	 0b10100000
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R102	 P0x00_R0x66	 0xA0	 160	 0b10100000
    
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R37	 P0x00_R0x25	 0x0	 0	 0b0
    Write:	 Wire:0	 TLV320AIC3105:24	 P0_R37	 P0x00_R0x25	 0xC0	 192	 0b11000000
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R37	 P0x00_R0x25	 0x0	 0	 0b0
    
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R43	 P0x00_R0x2B	 0x80	 128	 0b10000000
    Write:	 Wire:0	 TLV320AIC3105:24	 P0_R43	 P0x00_R0x2B	 0x0	 0	 0b0
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R43	 P0x00_R0x2B	 0x0	 0	 0b0
    
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R41	 P0x00_R0x29	 0x0	 0	 0b0
    Write:	 Wire:0	 TLV320AIC3105:24	 P0_R41	 P0x00_R0x29	 0x2	 2	 0b10
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R41	 P0x00_R0x29	 0x2	 2	 0b10
    
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R14	 P0x00_R0xE	 0x80	 128	 0b10000000
    Write:	 Wire:0	 TLV320AIC3105:24	 P0_R14	 P0x00_R0xE	 0xC0	 192	 0b11000000
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R14	 P0x00_R0xE	 0xC0	 192	 0b11000000
    
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R47	 P0x00_R0x2F	 0x0	 0	 0b0
    Write:	 Wire:0	 TLV320AIC3105:24	 P0_R47	 P0x00_R0x2F	 0x80	 128	 0b10000000
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R47	 P0x00_R0x2F	 0x80	 128	 0b10000000
    
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R64	 P0x00_R0x40	 0x4	 4	 0b100
    Write:	 Wire:0	 TLV320AIC3105:24	 P0_R64	 P0x00_R0x40	 0x80	 128	 0b10000000
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R64	 P0x00_R0x40	 0x80	 128	 0b10000000
    
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R65	 P0x00_R0x41	 0x0	 0	 0b0
    Write:	 Wire:0	 TLV320AIC3105:24	 P0_R65	 P0x00_R0x41	 0xD	 13	 0b1101
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R65	 P0x00_R0x41	 0xD	 13	 0b1101
    
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R51	 P0x00_R0x33	 0x0	 0	 0b0
    Write:	 Wire:0	 TLV320AIC3105:24	 P0_R51	 P0x00_R0x33	 0xD	 13	 0b1101
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R51	 P0x00_R0x33	 0xD	 13	 0b1101
    
    Table 96. Page 0/Register 96: Sticky Interrupt Flags Register
    Read:	 Wire:0	 TLV320AIC3105:24	 P0_R96	 P0x00_R0x60	 0x0	 0	 0b0
    AudioControlTLV320AIC3105::enableTLV320AIC3105
    
    ---Starting Audio Library----
    

    Do you have any clues where I can look to find out why I can not power up the DAC on P0R37? Is there a flag somewhere that I should view to see if everything is well? Is there some configuration I might be missing before I can enable the DAC?

    Thanks again,

    Jay

  • Hi Joey,

    It's odd that the GUI tool is trying to call 0x30 because I see it on 0x18

    I'm sorry I should have specified this in the previous post. You are correct the default value for just the device itself is 0x18. The EVM and GUI uses an USB to I2C interface, this device has an address of 0x30. 

    Do you have any clues where I can look to find out why I can not power up the DAC on P0R37?

    I would recommend probing the I2C bus while trying to write to P0_R37. If the command is not acknowledged (NACK) then there is an issue with the I2 command. If it is acknowledged (and still not configuring the register) we will look into further detail on the device itself. You can also configure the Table 105. Page 0/Register 107: New Programmable ADC Digital Path and I2C Bus Condition Register to see if a flag is raised there.

    Status registers Page 0/Register 94 and Page 0/Register 95 will also be helpful to check as well. This will show the power on conditions of the device.

    Is there some configuration I might be missing before I can enable the DAC?

    In general, this configuration and process looks fine. It will take some debugging to find the root cause here.

    Let me know the results.

    -Andrew

  • Hello Andrew, 

    Thank you for your help. I've hooked the device up to the scope and configured the decode. It appears that I'm getting a clean signal for that command. 

    // Table 42. Page 0/Register 37: DAC Power and Output Driver Control Register
    writeRegister(wires, dev, Page_00, 0x25, 0xC0);// w 30 25 C0

    But it appears that I'm not getting and ACK?

    Last Bit

    You can also configure the Table 105. Page 0/Register 107: New Programmable ADC Digital Path and I2C Bus Condition Register to see if a flag is raised there.

    I ran that flag after running the command and received no flag (0x00).

    Read:	 Wire:1	 TLV320AIC3105:24	 P0_R107	 P0x00_R0x6B	 Value: 0x0	 0	 0b0

    I ran the other flags and the only notable result is that the DAC is not powered up (register 94 should show 1101100).

    Table 94. Page 0/Register 94: Module Power Status Register
    Read:	 Wire:1	 TLV320AIC3105:24	 P0_R94	 P0x00_R0x5E	 Value: 0xC	 12	 0b1100
    Table 95. Page 0/Register 95: Output Driver Short-Circuit Detection Status Register
    Read:	 Wire:1	 TLV320AIC3105:24	 P0_R95	 P0x00_R0x5F	 Value: 0x0	 0	 0b0
    Table 96. Page 0/Register 96: Sticky Interrupt Flags Register
    Read:	 Wire:1	 TLV320AIC3105:24	 P0_R96	 P0x00_R0x60	 Value: 0x0	 0	 0b0

    I'm a little curious why it seems like many of the commands are successful - even if not acknowledged - besides the DAC configuration.

    The address is showing 0x30. Maybe that part has to do with the 7 bit vs 8 bit address thing, I'm not sure. But the device is clearly responding to the commands, just not ACK.... 

    I'm a bit baffled. The signal looks OK to me, do you see something I'm missing?

    Jay

  • I also recorded the steps with a logic analyzer and it appears that I do in fact get an ACK. It looks right, just the P0R37 write doesn't stick. 

    Time[s],Packet ID,Address,Read/Write,Data
    0.0000000000,1,0x30,Write,0x00 0x00
    0.0302882900,2,0x30,Write,0x01 0x01
    1.2305965200,3,0x30,Write,0x00 0x00
    1.2608848200,4,0x30,Write,0x01 0x00
    2.5111936700,5,0x30,Write,0x00 0x00
    2.5414812300,6,0x30,Write,0x07 0x8A
    2.7417776800,7,0x30,Write,0x00 0x00
    2.7720650700,8,0x30,Write,0x66 0xA0
    2.9723606900,9,0x30,Write,0x00 0x00
    3.0026489900,10,0x30,Write,0x25 0xC0
    3.2029445300,11,0x30,Write,0x00 0x00
    3.2332318300,12,0x30,Write,0x2B 0x00
    3.4335275300,13,0x30,Write,0x00 0x00
    3.4638157600,14,0x30,Write,0x29 0x02
    3.6641113800,15,0x30,Write,0x00 0x00
    3.6943996800,16,0x30,Write,0x0E 0xC0
    3.8946953900,17,0x30,Write,0x00 0x00
    3.9249836800,18,0x30,Write,0x2F 0x80
    4.1252792200,19,0x30,Write,0x00 0x00
    4.1555666100,20,0x30,Write,0x40 0x80
    4.3558620700,21,0x30,Write,0x00 0x00
    4.3861504500,22,0x30,Write,0x41 0x0D
    4.5864460700,23,0x30,Write,0x00 0x00
    4.6167343800,24,0x30,Write,0x33 0x0D
    4.8170300800,25,0x30,Write,0x00 0x00
    4.8473183800,26,0x30,Write,0x25 0xC0
    5.1476101100,27,0x30,Write,0x00 0x00
    5.3478996400,28,0x30,Write,0x6B
    5.4480980000,29,0x31,Read,0x00
    5.8483059900,30,0x30,Write,0x00 0x00
    6.0485957000,31,0x30,Write,0x5E
    6.1487948900,32,0x31,Read,0x0C
    6.5490029600,33,0x30,Write,0x00 0x00
    6.7492935000,34,0x30,Write,0x5F
    6.8494928500,35,0x31,Read,0x00
    7.2497008400,36,0x30,Write,0x00 0x00
    7.4499903000,37,0x30,Write,0x60
    7.5501886500,38,0x31,Read,0x00

    Update: I have headphones plugged in, and I heard something come out of the speakers! This happened during a program upload for a split second - so that's good news. I just need to figure out why it's unreliable. I'm getting there apparently. 

  • Hello Jay, 

    I agree this is a strange issue. It seems like you are taking all the right steps.

    A few questions (see below):

    1. Are you using the TLV320AIC3105EVM or are these I2C writes on a custom PCB?
      1. If using the EVM, which mother board are you using? (USB MOD Interface or the AC-MODEVM). A picture of your test setup may be helpful at this point.
    2. I noticed your last script writes to 0x30 and reads from 0x31. What is the purpose of this? At face value, this indicates you are reading a different device's registers. I don't think this was the case in your previous posts. 
    3. Are there any writes that two register 0x25 after the driver power on?

    Best,
    Andrew

  • Hello Andrew, 

    • Are you using the TLV320AIC3105EVM or are these I2C writes on a custom PCB?
      1. If using the EVM, which mother board are you using? (USB MOD Interface or the AC-MODEVM). A picture of your test setup may be helpful at this point.

    This is a custom PCB. I can share the photos in PM if it helps. For now, I want to keep it a surprise. :-)

    • I noticed your last script writes to 0x30 and reads from 0x31. What is the purpose of this? At face value, this indicates you are reading a different device's registers. I don't think this was the case in your previous posts. 

    The analyzer is showing 0x30 for a write and 0x31 for a read... !? I think this has to do with the 7 vs 8 bit addressing. In fact, that might be what the USB EVM expects, a full 8 bit address. I'm sorry I don't have much other thoughts about this right now, as I'm still learning. But I will say that I 100% have communication with the device and I can read and write reliably now. 

    I was able to get everything working, including playback and record paths. I still have other work to do but as far as basic operation, I got it working with your help. Thank you!

  • Hi Jay,

    I am happy to hear your application is working now. Thank you for giving an explanation of what fixed the issue for you (and marking the post as resolved). It makes sense to me that the EVM needs a full 8-bit address since the EVM and GUI uses an external USB to I2C interface. So this was a good catch. 

    Feel free to open another thread if you have other questions.

    Best,
    Andrew