Hi Everyone,
I connected the TLV320aic3204 with a microcontroller made by Atmel (atmega64) using the circuit recommended in the data sheet, the codec runs on a MCLK of 4 MHz and I randomly connected the two pins for Bclk and Wclk to the UC. My target is playback Fs=8 khz. All registers have successfully been allocated using l2C.
CODEC_ByteWrite(0x00,0x00); //software reset CODEC_ByteWrite(0x01,0x01); CODEC_ByteWrite(0x00,0x00); //clock and interface settings CODEC_ByteWrite(0x04,0x03); CODEC_ByteWrite(0x05,0x93); CODEC_ByteWrite(0x06,0x09); // P=1, R=3, J=9 CODEC_ByteWrite(0x0b,0x82); //NDAC=2 CODEC_ByteWrite(0x0c,0x87); //MDAC=7 CODEC_ByteWrite(0x12,0x07); //NADC=7 CODEC_ByteWrite(0x13,0x02); //MADC=2 CODEC_ByteWrite(0x1d,0x00); //BCLK frequency is generated from DAC_CLK CODEC_ByteWrite(0x1e,0x84); //and N = 4 CODEC_ByteWrite(0x1b,0x06); // Set BCLK and WCLK as outputs CODEC_ByteWrite(0x00,0x2c); //High-pass first order butterworth Filter CODEC_ByteWrite(0x0c,0x7c); //Fc=40 Hz CODEC_ByteWrite(0x0d,0x73); CODEC_ByteWrite(0x0e,0xe4); CODEC_ByteWrite(0x0f,0x00); CODEC_ByteWrite(0x10,0xc1); CODEC_ByteWrite(0x11,0xc6); CODEC_ByteWrite(0x12,0x0f); CODEC_ByteWrite(0x13,0x00); CODEC_ByteWrite(0x14,0x00); CODEC_ByteWrite(0x15,0x00); CODEC_ByteWrite(0x16,0x00); CODEC_ByteWrite(0x17,0x00); CODEC_ByteWrite(0x18,0x3c); CODEC_ByteWrite(0x19,0x73); CODEC_ByteWrite(0x1a,0xe6); CODEC_ByteWrite(0x1b,0x00); CODEC_ByteWrite(0x1c,0x00); CODEC_ByteWrite(0x1d,0x00); CODEC_ByteWrite(0x1e,0x00); CODEC_ByteWrite(0x1f,0x00); CODEC_ByteWrite(0x00,0x2d); CODEC_ByteWrite(0x14,0x7c); CODEC_ByteWrite(0x15,0x73); CODEC_ByteWrite(0x16,0xe4); CODEC_ByteWrite(0x17,0x00); CODEC_ByteWrite(0x18,0xc1); CODEC_ByteWrite(0x19,0xc6); CODEC_ByteWrite(0x1a,0x0f); CODEC_ByteWrite(0x1b,0x00); CODEC_ByteWrite(0x1c,0x00); CODEC_ByteWrite(0x1d,0x00); CODEC_ByteWrite(0x1e,0x00); CODEC_ByteWrite(0x1f,0x00); CODEC_ByteWrite(0x20,0x3c); CODEC_ByteWrite(0x21,0x73); CODEC_ByteWrite(0x22,0xe6); CODEC_ByteWrite(0x23,0x00); CODEC_ByteWrite(0x24,0x00); CODEC_ByteWrite(0x25,0x00); CODEC_ByteWrite(0x26,0x00); CODEC_ByteWrite(0x27,0x00); CODEC_ByteWrite(0x00,0x2c); CODEC_ByteWrite(0x01,0x05); CODEC_ByteWrite(0x00,0x01); //configure power supplies CODEC_ByteWrite(0x02,0x09); CODEC_ByteWrite(0x01,0x08); CODEC_ByteWrite(0x02,0x01); CODEC_ByteWrite(0x0a,0x3b); CODEC_ByteWrite(0x3d,0x00); CODEC_ByteWrite(0x03,0x00); CODEC_ByteWrite(0x04,0x00); CODEC_ByteWrite(0x47,0x32); CODEC_ByteWrite(0x7b,0x01); CODEC_ByteWrite(0x00,0x01); //config ADC channel CODEC_ByteWrite(0x34,0x80); CODEC_ByteWrite(0x36,0x80); CODEC_ByteWrite(0x37,0x80); CODEC_ByteWrite(0x39,0x80); CODEC_ByteWrite(0x3b,0x0c); CODEC_ByteWrite(0x3c,0x0c); CODEC_ByteWrite(0x00,0x00); CODEC_ByteWrite(0x51,0xc0); CODEC_ByteWrite(0x52,0x00); CODEC_ByteWrite(0x00,0x01); //config DAC channel CODEC_ByteWrite(0x14,0x25); CODEC_ByteWrite(0x0c,0x08); CODEC_ByteWrite(0x0d,0x08); CODEC_ByteWrite(0x0e,0x08); CODEC_ByteWrite(0x0f,0x08); CODEC_ByteWrite(0x09,0x3c); CODEC_ByteWrite(0x10,0x00); CODEC_ByteWrite(0x11,0x00); CODEC_ByteWrite(0x12,0x00); CODEC_ByteWrite(0x13,0x00); CODEC_ByteWrite(0x00,0x00); CODEC_ByteWrite(0x41,0x00); CODEC_ByteWrite(0x42,0x00); CODEC_ByteWrite(0x3f,0xd6); CODEC_ByteWrite(0x40,0x00);
Now I’m wondering why it doesn’t work. The outputs of HPL and HPR is only noise, no matter what input signal is applied. I’ve started out by trying to hear or measure an audio output signal using a microphone as input.
Is it possible, providing playback works, to use I2s even though I’m using a microcontroller instead of DSP? How can I generate BClk and WCLK when the dataflow direction is from the UC to the Codec? Where can I find an example code in C for I2S?
Thanks a lot, Ouassim.
Ouassim,
To send data from ADC to DAC you can use the ADC to DAC loopback found in Page 0 / Register 29. For this to work, BCLK, MCLK and WCLK must be present. This can be accomplished by providing BCLK/WCLK externally, or configuring them as outputs (as in your code). This would be a good starting point to determine if the whole signal path is working.
For communicating with a uC without an I2S bus, I would recommend setting the AIC in master mode (BCLK/WCLK are outputs) and setting interrupts in the uC based on WCLK edges. Then, the uC can count BCLK cycles and store the data in a buffer, or clock the data with the edges.
Regards,
J-
Hello J
I use 3204 in mono, data sheet shows, using right ADC and left DAC in mono gets lower power cost, how to set register to route left ADC output to right DAC input , I have not find that. Or it must works left ADC to right DAC and right ADC to right DAC?
thanks
Bo Li
Bo,
You can select LDAC input as right channel data by programming Page 0 / Register 63.
Hi Gajanan
Thank you for reply and give me information.
I use aic3204 since analog mic or digit mic is part of the system as well.
"SLOS602A–SEPTEMBER2008–REVISEDOCTOBER2008" . this is TI aic3204 data sheet. I don't understand "Table5-20.DACGain vs.PowerTuneModes", it is in cheapt 5.13.1 PowerTuneModes.
Can you explain for me?
Best regard