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.

Test tone from aic3204 example distorted - what is wrong?



I tried the examples on the eZdsp USB Stick installation DVD. The aic3204 example should produce a 1 kHz sine tone but this is not the case. What I can hear is a distorted tone with a frequency of about 740 Hz. In contrast to this, the built-in test program clearly produces sine tones with 1000 Hz and 2000 Hz.

I tried to understand the aic3204 program and found the code in aic3204_tone_headphone.c which is in a loop for the 48 sinewave samples:

I2S0_W0_MSW_W = (sinetable[sample]) ;
I2S0_W0_LSW_W = 0;
while((XmitR & I2S0_IR) != 0)
I2S0_W1_MSW_W = (sinetable[sample]) ;
I2S0_W1_LSW_W = 0;

In the first two lines, the sine value is written to the ports 0x2809 and 0x2808, i. e. the left output channel, in the last two lines it is the ports 0x280d and 0x280c, i. e. the right output channel. The third line seems to wait for a flag that transmission is ready. But there isn't a semicolon at the end of the line, so line 4 is part of the while loop, and the sample is continuously written to I2S0_W1_MSW_W.

I added a semicolon at the end of the while loop. The result is that the frequency is double (1480 Hz) and the tone is still distorted.

The second test, aic3204_loop_linein.c, runs perfectly although a similar while loop is in this routine. I can't figure out what is wrong with the tone generation function and would need some help.

Thank you,

Geza Anders

  • The code in my example that I downloaded off the Spectrum Digital website, I think, looks like this.

     /* Play Tone */
    for ( i = 0 ; i < 5 ; i++ )
    {

    for ( j = 0 ; j < 1000 ; j++ )
    {

    for ( sample = 0 ; sample < 48 ; sample++ )
    {

    I2S0_W0_MSW_W = (sinetable[sample]) ;

    // 16 bit left channel transmit audio data

    I2S0_W1_MSW_W = (sinetable[sample]) ;

    // 16 bit right channel transmit audio data

     

     

     

     

    while((XmitR & I2S0_IR) == 0); // Wait for transmit interrupt to be pending

     

    }

    }

    }

     

    And the tone sounds just fine no problems.

     

  • Bjorn, you are right. The downloaded code is a newer release than the code on the DVD.

    Just to understand what happens in the faulty DVD version: In the loop

      while((XmitR & I2S0_IR) != 0)
      I2S0_W1_MSW_W = (sinetable[sample]) ;

    the interrupt flag is read and the sinetable value is written to the TX register. Since the interrupt flag is reset by the read operation the loop will never wait for anything. The tone that I heard was an undersampled sine wave - the samples were written at a much higher frequency than they could be transmitted over the I2S interface. Changing the while loop fixed the problem.

    Thank you,

    Geza