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.