UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Adventurer
Adventurer
6,801 Views
Registered: ‎07-25-2014

I2S audio Codec problem

Hello

 

I'm trying to generate a sinewave with 1khz of frequency and send it to output audio line.

 

DAC is configurated to 48 kHz, so the sample rate i am using is 48kHz. I create LUT with that samples and i'm sending the samples to the output line.

 

I already tried sending from my PC to line in a 1khz sine wave and then directing it to line out and all went good. The values are more or less similar to the samples that I have but when i try to generate the sine samples in a C program and then output them to line out the sound is completely wrong.

 

The function that i used is this one:

 

void audio_stream(){
//u32 in_left, in_right;
int i,j=0;
int size=96000; // 96000 amostras para ter 2 segundos de som
u32 audio,aux[48];//,audio2;

printf("Inicializando a LUT \n");
for(i=0;i<48;i++){
aux[i]=((sin(((2*M_PI)/(48))*(i))*pow(2,24))+pow(2,24)-1)/2;
//printf("Iteracao= %d AUX= %d \n",i,aux[i]);
}
printf("-------------------- \n");
printf("LUT Criada!\n");


while (!XUartPs_IsReceiveData(UART_BASEADDR)){
// Read audio input from codec
//in_left = Xil_In32(I2S_DATA_RX_L_REG);
//in_right = Xil_In32(I2S_DATA_RX_R_REG);

// Write audio output to codec
audio=(u32)aux[j%48];
Xil_Out32(I2S_DATA_TX_L_REG, audio);
j++;
//2880000
if(j>=size){
//printf("j= %d\n",j);
menu();

}
//printf("audio= %lx aux= %d \n",audio,aux);
//printf("right= %d",in_right);
//Xil_Out32(I2S_DATA_TX_L_REG, audio);
//Xil_Out32(I2S_DATA_TX_R_REG, (u32)audio);//
}


/* If input from the terminal is 'q', then return to menu.
* Else, continue streaming. */
if(XUartPs_ReadReg(UART_BASEADDR, XUARTPS_FIFO_OFFSET) == 'q') menu();
else audio_stream();

} // audio_stream()

 

What i'm doing wrong? Is this method impossible to implement? Or i'm forgoting something?

 

Thanks for the help

Joao

0 Kudos
5 Replies
Xilinx Employee
Xilinx Employee
6,786 Views
Registered: ‎08-02-2011

Re: I2S audio Codec problem

Hi Joao,

 

"The sound is completely wrong" quite an ambiguous description of the issue.

 

Does it sound like a sine wave of the wrong frequency? Is it complete white noise? Is it a distorted sine wave? etc.

 

Is this a zedboard, I assume?

 

A lot of things need to happen between here:

 Xil_Out32(I2S_DATA_TX_L_REG, audio);

 and the final analog output coming from the codec.

 

Of particular note would be your AXI-to-I2S transceiver and how it is clocked.

www.xilinx.com
0 Kudos
Adventurer
Adventurer
6,778 Views
Registered: ‎07-25-2014

Re: I2S audio Codec problem

I think it  sounds like noise since it is not clearly a sinewave and yes it is a Zedboard.

 

Can you explain what you are saying better? 

 

I thought that since i was able to input a sound to the line in and output it through the lineout it was already prepared to do it what i'm doing. That is not input anything in the line in, and just output directly through the lineout.

 

Sorry i'm just starting with zedboard and this is complicated to me.

 

But thanks for the help

0 Kudos
Xilinx Employee
Xilinx Employee
6,761 Views
Registered: ‎08-02-2011

Re: I2S audio Codec problem

Ah okay.

 

I thought that since i was able to input a sound to the line in and output it through the lineout it was already prepared to do it what i'm doing. That is not input anything in the line in, and just output directly through the lineout.

Do you mean that your software is in the datapath for this test? In other words, you did this:

 

Line In -> Software read via i2s -> software write via i2s -> Line Out

 

And not simply:

Line In -> Loopback in PL -> Line Out.

 

If you did the former, that will be helpful.

 

What I am getting at is that you need to keep in mind what rate you're sending data around. You're trying to generate a 1KHz sine wave with 48KHz sample rate using a processor running hundreds of MHz. You'll need some mechanism to handle this translation. Most likely, you'll have some sort of flag indicating a new sample is ready to be sent to a buffer every 1/48e3.

 

Looking at just the software, it is a little difficult to tell how the design works. If you post the hardware datapath, we can probably help more.

www.xilinx.com
0 Kudos
Adventurer
Adventurer
6,756 Views
Registered: ‎07-25-2014

Re: I2S audio Codec problem

 

Line In -> Software read via i2s -> software write via i2s -> Line Out

 


The project from where i started do that. And now what I'm trying to do is:

 

Generate sin samples of 1khz  -> then software write via i2s -> Line Out

 

The current DAC sample rate is 48 kHz so tha's why i'm using that sample rate. So the problem essentialy is that my processor is working if I'm not wrong at 667 MHZ and I need to input date via I2S at 48Khz. That is the current problem?

 

WHat do you mean by my datapath?  Sorry for my bad English and for the problems understanding what you are trying to say, i'm starting to learn this now.

 

Thanks for the patience

0 Kudos
Adventurer
Adventurer
6,700 Views
Registered: ‎07-25-2014

Re: I2S audio Codec problem

No clue?

0 Kudos