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.

Issues with TLV320AIC3204.

Other Parts Discussed in Thread: TLV320AIC3204

Within the scope of my project i am trying to control the audio codec TLV320AIC3204 with an ATMega 16 microcontroller (TW-Interface).
Therefore i am using the circuit you recommended.  (see codec Datasheet site 21).
For the inputs LDOIN, IOVDD and LDO_SELECT is 3,24 Volt requiered, and at the pins AVDD and DVDD I measure 1,68 V (REF-Pin=0V).
After the microcontroller has sent the START condtition and the I²C Adress(0x30)+write instruction (0), i do not receive any
ACKNOWLEDGE from the codec.
So my questions are: is there a hardware issue or a software issue? How is it possible to check if the code is working correctly?
Here you find my code which i am using: TWI Hardware from Atmel.

/* I²C (TWI) Bus

#include <avr/io.h>

#include <util/delay.h>

 

#define BASEADR                 0x30        // Basis Adress codec tlv320aic3204

#define TW_WRITE               0                            

void delay_ms(uint16_t);

void i2c_start(void);

void i2c_stop(void);

void i2c_send(uint8_t) ;

void Codec_ByteWrite(uint16_t, uint8_t);

int main(void);

void delay_ms(uint16_t ms)

{

                for(uint16_t t=0; t<=ms; t++)

                               _delay_ms(1);

}

void i2c_start(void)

{

                TWCR = _BV(TWINT) | _BV(TWSTA) | _BV(TWEN);         // send start condition

                while ((TWCR & _BV(TWINT)) == 0) ;                                                                // wait for transmission

}

void i2c_stop(void)

{

                TWCR = _BV(TWINT) | _BV(TWSTO) | _BV(TWEN);                         // send stop condition

}

void i2c_send(uint8_t DataByte)

{

                TWDR = DataByte;

                TWCR = _BV(TWINT) | _BV(TWEN);                                  // clear interrupt to start transmission

                while ((TWCR & _BV(TWINT)) == 0) ;                                // wait for transmission

}

void Codec_ByteWrite(uint16_t addr, uint8_t wert)

{

again:

                i2c_start();

                i2c_send(BASEADR | TW_WRITE);

                if ((TWSR & 0xF8) != 0x18)  //wait for ACK

                {

                               i2c_stop();

                               goto again;

                }

                i2c_send(addr);

                i2c_send(wert);

                i2c_stop();

                _delay_ms(5);                                       

}

int main(void)

{              

                TWBR = (F_CPU / 100000UL - 16) / 2;                 // TWI Baudrate 100KHz

                Codec_ByteWrite(0x00,0x00);                               // initiali

                return 0;

}

PS:The circuits SDA and SCL have been connected with pull-up resistors (4.7K) and also to a 5 V circuit.

  • Hi ouassim

    The issue seems to be a software issue. Please double check on the code by inserting break points.

    The way to diagnose if the codec is working or not is to supply some input, change the volume/gain settings and observe waveform at the output. How are you observing the ACK bit sent by Codec? The slave Codec pulls the SDA pin low for 1 clock cycle to acknowledge the master.

  • Hi Vikas,

    thanks for your fast reply, this support is really good!!
    In my first mail I forgot to mention, that i am using TWI hardware, so only register will be set at the microcontroller... 
    and the confirmation from codec (if the codec set the sda circuit at low) i can control the twsr register, the first 3 bits (bit0 till bit 2) are not needed. Therefore I am setting them on "0" (& 0b1111 1000).
    In ATmega16 Database the value is 0x18 for SLA+W with ACK. Cause the led is permanently turning on / off i know the program hangs in "gain" loop and doesn't get out from the loop. 
    I compared the TWSR value with  the 0x20 and the value stand for SLA+W without ACK, the program is leaving the gain loop, but i don't think that the register in the codec will be inscribed. 

    again:

                   DDRC |=  0x20;       //PORTD OUTPUT

                   PORTD |=  0x20;    //LED = 1

                    i2c_start();

                    i2c_send(BASEADR | TW_WRITE);

                    if ((TWSR & 0xF8) != 0x18)  //    wait for ACK

                    {

                                   i2c_stop();

                                   PORTD &=~0x20;   //LED = 0

                                   goto again;

                    }

                    i2c_send(addr);    //register adresse

                    i2c_send(wert);   //register Value

                    i2c_stop();         //stop condition

                    _delay_ms(5); 

    PS: Today I set the voltage lower to 2V LDOIN, IOVDD und LDO_select but at AVDD und DVDD stayed constant at 1,68 volt. 
    Is it normal? might be, that the codec needs a clock? Is it possible to control the codec with a microcontroller?