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.

Processing sound: using the I2S interface to comunicate between codec and Dsp...

Other Parts Discussed in Thread: TMS320VC5505

I'm trying to create a simple projectwith my TMS320VC5505 ezDsp USB Stick that can simulate the behavior of a distorsion effect by clipping the data obtained from the codec when greater than a certain quantity. To do that I'm tryng to follow the aic3204 example but I can understand what happens after the "Play Tone" comment in the aic3204_loop_linein function. It seems to sent the data through the i2s intarface but if I completly cut off these lines it works in the same way....I know this question may seem a bit stupid but I'm really new in Dsp world...!

Thank for your help

Andrea

  • Hi Andrea,

     

    The aic3204 project calls two different codec routines:

    • First, the program calls the aic3204_tone_headphone( ) function that is located in “aic3204_tone_headphone.c”. aic3204_tone_headphone( ) reads a 1KHz Sine wave from the sinetable[] array and transmits the samples to the aic3204 codec over I2S – you should hear a 1KHz tone from the headphone jack.
    • After 5 seconds of transmitting the 1KHz tone, the program calls the aic3204_loop_linein( ) function that is located in “aic3204_loop_linein.c”. aic3204_loop_linein( ) reads Left and Right samples from the aic3204 codec over I2S and then transmits the samples back to the codec over I2S

     

    If you remove (or comment) the lines after the /* Play Tone */ comment for either of these two functions, that function will no longer output anything to the codec.

     

    For example, if I comment out the three for-loops in the aic3204_loop_linein( ) function, it will not copy the samples from the codec to the DSP and back to the codec.

     

    /* Play Tone */

    //  for ( i = 0 ; i < 5 ; i++ )

    //  {

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

    //    {

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

    //      {

    //        /* Read Digital audio input */

    //        while((RcvR & I2S0_IR) == 0);  // Wait for receive interrupt to be pending

    //        data3 = I2S0_W0_MSW_R;  // 16 bit left channel received audio data

    //        data4 = I2S0_W1_MSW_R;  // 16 bit right channel received audio data

    //

    //        /* Write Digital audio input */

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

    //        I2S0_W0_MSW_W = data3;  // 16 bit left channel transmit audio data

    //        I2S0_W1_MSW_W = data4;  // 16 bit right channel transmit audio data

    //

    //      }

    //    }

    //  }

     

    Hope this helps,
    Mark

  • That's is the code modified:

    for ( i = 0 ; i < 400 ; i++ )
        {
            for ( j = 0 ; j < 1000 ; j++ )
            {
                for ( sample = 0 ; sample < 48 ; sample++ )
                {
                    /* Read Digital audio input */
                    //data3 = I2S0_W0_MSW_R;
                      //data1 = I2S0_W0_LSW_R;
                      //while((RcvR & I2S0_IR) == RcvR)
                      //data4 = I2S0_W1_MSW_R;
                      //data2 = I2S0_W1_LSW_R;
                   
                    /* Write Digital audio input */
                    //I2S0_W0_MSW_W = data3;
                      //I2S0_W0_LSW_W = 0;
                      //while((XmitR & I2S0_IR) == XmitR)
                      //I2S0_W1_MSW_W = data4;
                      //I2S0_W1_LSW_W = 0;
                   
                }
            }
        }

    In this way if I send a tone to the input jack I can hear it back in the headphones even if nothing sholud be sent to the codec and I can't understand why....

    thank you

    Andrea

  • The same things happens while playing the tone at 1 KHz. If I send a signal through the audio input I can hear it back on the headphone....How can I eliminate this loop?

    Thanks for your help

    Andrea

  • Hi Andrea,

    I am sorry to hear you are having difficulty with the Codec.

    I was unable to reproduce the audio loop you have described. The code seems to work fine on my device - I do not hear any input signal on the headphone output except when the aic3204_loop_linein function is called.

    Can you hear the input audio at the headphone output right after you connect to the device with Code Composer, but before you load your program to it?

    What about when the device is powered off or when running some other program?

    Hopefully, we can get you up and running soon.

    Regards,
    Mark

  • Hi,

    I have download the test code from http://support.spectrumdigital.com/boards/usbstk5505/revb/  for audio application. I met some problem

    <-> Audio Loopback from Stereo IN --> to HP/Lineout application. I can not hear any sound my device' lineout.

    I test my device' line out and it is OK. I think that problem is either my device stereo line input or code bug. 

    Let me know If you have any idea.

    Regards

    Kuzlu

  • I'm trying it now, while it is just connected or while it is running a different program I can't here the sound from stereo in in the hp out but I here it during the calling of both functions in aic3204 project. I post the entire code so you can say me if there are any other changes:

     

    /*
     *  Copyright 2009 by Spectrum Digital Incorporated.
     *  All rights reserved. Property of Spectrum Digital Incorporated.
     */

    /*
     *  AIC3204 Tone
     *
     */
    #include "stdio.h"
    #include "usbstk5505.h"
    extern Int16 AIC3204_rset( Uint16 regnum, Uint16 regval);
    #define XmitL 0x10
    #define XmitR 0x20
    #define RcvR 0x08
    #define RcvL 0x04
    /* ------------------------------------------------------------------------ *
     *                                                                          *
     *  AIC3204 Tone                                                            *
     *      Output a 1 kHz tone through the HEADPHONE jack                      *
     *                                                                          *
     * ------------------------------------------------------------------------ */
    Int16 aic3204_loop_linein( )
    {
        Int16 i, j;
        Int16 sample, data1, data2, data3, data4;
        
        /* Configure Serial Bus */
        SYS_EXBUSSEL |= 0x0100;  // Configure Serial bus 0 for I2S0
     
        
        /* Configure AIC3204 */

        AIC3204_rset( 0, 0 );      // Select page 1
        AIC3204_rset( 1, 1 );      // Reset codec
        AIC3204_rset( 0, 1 );      // Point to page 1
        AIC3204_rset( 1, 8 );      // Disable crude AVDD generation from DVDD
        AIC3204_rset( 2, 1 );      // Enable Analog Blocks, use LDO power
        AIC3204_rset( 0, 0 );
        /* PLL and Clocks config and Power Up  */
        AIC3204_rset( 27, 0x1d );  // BCLK and WCLK is set as o/p to AIC3204(Master)
        AIC3204_rset( 28, 0x00 );  // Data ofset = 0
        AIC3204_rset( 4, 3 );      // PLL setting: PLLCLK <- MCLK, CODEC_CLKIN <-PLL CLK
        AIC3204_rset( 6, 8 );      // PLL setting: J=8
        AIC3204_rset( 7, 15 );     // PLL setting: HI_BYTE(D)
        AIC3204_rset( 8, 0xdc );   // PLL setting: LO_BYTE(D)
        AIC3204_rset( 30, 0x88 );  // For 32 bit clocks per frame in Master mode ONLY
                                   // BCLK=DAC_CLK/N =(12288000/8) = 1.536MHz = 32*fs
        AIC3204_rset( 5, 0x91 );   //PLL setting: Power up PLL, P=1 and R=1
        AIC3204_rset( 13, 0 );     // Hi_Byte(DOSR) for DOSR = 128 decimal or 0x0080 DAC oversamppling
        AIC3204_rset( 14, 0x80 );  // Lo_Byte(DOSR) for DOSR = 128 decimal or 0x0080
        AIC3204_rset( 20, 0x80 );  // AOSR for AOSR = 128 decimal or 0x0080 for decimation filters 1 to 6
        AIC3204_rset( 11, 0x88 );  // Power up NDAC and set NDAC value to 8
        AIC3204_rset( 12, 0x82 );  // Power up MDAC and set MDAC value to 2
        AIC3204_rset( 18, 0x88 );  // Power up NADC and set NADC value to 8
        AIC3204_rset( 19, 0x82 );  // Power up MADC and set MADC value to 2
        /* DAC ROUTING and Power Up */
        AIC3204_rset( 0, 1 );      // Select page 1
        AIC3204_rset( 0x0c, 8 );   // LDAC AFIR routed to HPL
        AIC3204_rset( 0x0d, 8 );   // RDAC AFIR routed to HPR
        AIC3204_rset( 0, 0 );      // Select page 0
        AIC3204_rset( 64, 2 );     // Left vol=right vol
        AIC3204_rset( 65, 0 );     // Left DAC gain to 0dB VOL; Right tracks Left
        AIC3204_rset( 63, 0xd4 );  // Power up left,right data paths and set channel
        AIC3204_rset( 0, 1 );      // Select page 1
        AIC3204_rset( 0x10, 10 );  // Unmute HPL , 10dB gain
        AIC3204_rset( 0x11, 10 );  // Unmute HPR , 10dB gain
        AIC3204_rset( 9, 0x30 );   // Power up HPL,HPR
        AIC3204_rset( 0, 0 );      // Select page 0
        USBSTK5505_wait( 100 );    // wait
        /* ADC ROUTING and Power Up */
        AIC3204_rset( 0, 1 );      // Select page 1
        AIC3204_rset( 0x34, 0x30 );// STEREO 1 Jack
                                   // IN2_L to LADC_P through 40 kohm
        AIC3204_rset( 0x37, 0x30 );// IN2_R to RADC_P through 40 kohmm
        AIC3204_rset( 0x36, 3 );   // CM_1 (common mode) to LADC_M through 40 kohm
        AIC3204_rset( 0x39, 0xc0 );// CM_1 (common mode) to RADC_M through 40 kohm
        AIC3204_rset( 0x3b, 0 );   // MIC_PGA_L unmute
        AIC3204_rset( 0x3c, 0 );   // MIC_PGA_R unmute
        AIC3204_rset( 0, 0 );      // Select page 0
        AIC3204_rset( 0x51, 0xc0 );// Powerup Left and Right ADC
        AIC3204_rset( 0x52, 0 );   // Unmute Left and Right ADC
       
        AIC3204_rset( 0, 0 );   
        USBSTK5505_wait( 100 );  // Wait
        /* I2S settings */
        I2S0_SRGR = 0x0;    
        I2S0_CR = 0x8010;    // 16-bit word, slave, enable I2C
        I2S0_ICMR = 0x3f;    // Enable interrupts
        /* Play Tone */
        for ( i = 0 ; i < 400 ; i++ )
        {
            for ( j = 0 ; j < 1000 ; j++ )
            {
                for ( sample = 0 ; sample < 48 ; sample++ )
                {
                    /* Read Digital audio input */
                    /*data3 = I2S0_W0_MSW_R;
                      data1 = I2S0_W0_LSW_R;
                      while((RcvR & I2S0_IR) == RcvR)
                      data4 = I2S0_W1_MSW_R;
                      data2 = I2S0_W1_LSW_R;*/
                   
                    /* Write Digital audio input */
                    /*I2S0_W0_MSW_W = data3;
                      I2S0_W0_LSW_W = 0;
                      //while((XmitR & I2S0_IR) == XmitR)
                      I2S0_W1_MSW_W = data4;
                      I2S0_W1_LSW_W = 0;*/
                   
                }
            }
        }
        /* Disble I2S */
        I2S0_CR = 0x00;
        AIC3204_rset( 1, 1 );      // Reset codec
        return 0;
    }

     

    The other .c files weren't be modified.

    Thanks for your help

    Andrea