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.

fftg coprocessor

Other Parts Discussed in Thread: TMS320C5515

hai

i am using the ezdsp5505 usbstick when i run the audio filter demo on the stick  the fft works fine when i try to use the fft in the csl and i put  the function  in rom and i run i found that the data is not the same as the one using the example

  • The two algorithms are different, so their results may not bit-exact match. However, they would produce the "same" results in DSP sense.

  • hai cong van nguyen

    i want to design the digital filter in c5505 dsp of low pass filter with cutoff frequency of 10 hz . i has taken the time domain samples of 1024 using adc  with the sampling frequency of 500 hz and i computed this  data with fft and i want to get the filter coefiecients of fc 10hz i dont know how to obtain the filter coefiecients explain me on this .

    with regards

    seeni

     

  • hi Cong Van Nguyen

    my full name Le Van Pho. i guess you are vietnames. i have a problem with FFT use TMS320C5515 , i not good english and programer

    can you help me please? it is important with me,  you explain codes:

     

    #include "stdio.h"
    #include "usbstk5515.h"
    #include "usbstk5515_led.h"
    #include "aic3204.h"
    #include "PLL.h"
    #include "bargraph.h"
    #include "oled.h"
    #include "pushbuttons.h"
    #include "stereo.h"
    #include "dsplib.h"

    Int16 left_input;
    Int16 right_input;
    Int16 left_output;
    Int16 right_output;
    Int16 mono_input;


    #define SAMPLES_PER_SECOND 8000

    /* Use 20 for guitar */
    #define GAIN_IN_dB 0
    unsigned long int i = 0;

    unsigned int Step = 0;
    unsigned int LastStep = 99;

    int j = 0;
    int k = 0;
    int m = 0;
    int display_counter = 0;
    int waveform_counter;
    long delay;

    DATA input_buffer[1024]; /* Must be declared as DATA for dsplib compatibility */

    DATA buffer2[1024];
    int display_buffer[96];
    int buffer1[96];

     
    /*****************************************************************************/
    /* calculate_power()                                                         */
    /*---------------------------------------------------------------------------*/
    /*                                                                           */
    /* Parameter 1: Real term a.                                                 */
    /* Parameter 2: Immaginary term jb.                                          */
    /*                                                                           */
    /* RETURNS: a*a + b*b. Result will always be positive.                       */
    /*                                                                           */
    /*****************************************************************************/

    int calculate_power (int a, int b)
    {

     return ( (int) ( ( (long)a * a + (long) b * b) >> 14) );
    }

    /*****************************************************************************/
    /* calculate_FFT()                                                           */
    /*---------------------------------------------------------------------------*/
    /*                                                                           */
    /* Parameter 1: Latest audio input (real value).                             */
    /* Parameter 2: size of FFT e.g. 128, 512 and 1024 elements.                 */
    /*                                                                           */
    /* RETURNS: None.                                                            */
    /*                                                                           */
    /*****************************************************************************/

    void calculate_FFT(int input, int size)
    {
     static int i = 0;
     static int counter = 0;

     buffer2[i] = input; /* Store as a real value */
     i++;
     buffer2[i] = 0;     /* Store with an imaginary value of 0 */
     i++;
     
     if ( i >= size-1)
     {
       i = 0;
       
       /* Perform complex FFT using N real and N imaginary values */
         
       cfft (&buffer2[0], size/2, SCALE);           

       cbrev(&buffer2[0], &buffer2[0], size/2);     

        for ( j = 0 ; j < 96 ; j ++)
         {
          display_buffer[j] = calculate_power((int) buffer2[2*j], (int)buffer2[2*j+1]);
         }
         
        counter++;
        if ( counter >= 1)
        {
          /* Slow down the number of updates to make display easier to see */    
          counter = 0;    
          oled_display_bargraph( &display_buffer[0]);
        }     
     }
    }


    /* ------------------------------------------------------------------------ *
     *                                                                          *
     *  main( )                                                                 *
     *                                                                          *
     * ------------------------------------------------------------------------ */
    void main( void )
    {
        /* Initialize BSL */
        USBSTK5515_init( );
        
        /* Initialize PLL */
        pll_frequency_setup(120);

        /* Initialise hardware interface and I2C for code */
        aic3204_hardware_init();
        
        /* Initialise the AIC3204 codec */
        aic3204_init();
        
        /* Turn off the 4 coloured LEDs */
        USBSTK5515_ULED_init();
        
        /* Initialise the OLED LCD display */
        oled_init();
        SAR_init();
        /* Flush display buffer */
        oled_display_message("                 ", "                   ");
        
        printf("\n\nRunning Project Spectrum Analyser\n");
        printf( "<-> Audio Loopback from Microphone In --> to Headphones/Lineout\n\n" );

        /* Setup sampling frequency and 30dB gain for microphone */
        set_sampling_frequency_and_gain(SAMPLES_PER_SECOND, GAIN_IN_dB);

        oled_display_message("Application 20     ", "Spectrum Analyser  ");

        /* New. Add descriptive text */
        puts("\n Bargraph at 6dB intervals");
        puts("\n Press SW1 for DOWN, SW2 for UP, SW1 + SW2 for reset\n");
        puts(" Step 1   = Straight through, no signal processing. Set levels");
        puts(" Step 2   = Waveform view");
        puts(" Step 3   = FFT 1024 Display. Calculate power and display as bargraph");
        puts(" Step 4   = FFT 512 Display. Calculate power and display as bargraph");

          
        /* Default to XF LED off */
        asm(" bclr XF");
        
         for ( i = 0  ; i < SAMPLES_PER_SECOND * 600L  ;i++  )
         {

         aic3204_codec_read(&left_input, &right_input); // Configured for one interrupt per two channels.
       
         mono_input = stereo_to_mono(left_input, right_input);
         
         Step = pushbuttons_read(4);
             
          if ( Step == 1 )
            {
             if ( Step != LastStep )
              {
               oled_display_message("STEP1 No Processing", "Set Levels         ");
               LastStep = Step;

              }    
             left_output = left_input;      // Straight trough. No processing.
             right_output = right_input;

            }
          else if ( Step == 2)
            {
              if ( Step != LastStep)
              {
               oled_display_message("STEP2              ", "      Waveform View");
               LastStep = Step;
               display_counter = 0;
               waveform_counter = 0;
              }

             if ( display_counter < 8000)
               {
                display_counter++;
               }
             
             if (display_counter >= 8000)
               {
                   buffer1[k] = mono_input;
                k++;
            
                if ( k >= 96)
                 {
                   k = 0;    
                   waveform_counter++;
                   if ( waveform_counter >= 6)
                     {
                       waveform_counter = 0;    
                       oled_display_waveform(&buffer1[0]);
                       delay = 0xFFFFFF;
                       while ( delay--)
                        {
                         /* Wait */    
                        }   
                     }  
                 }
     
               }
     
            }
          else if ( Step == 3)
            {
              if ( Step != LastStep)
              {
               oled_display_message("STEP3              ", "   FFT 1024 Display");
               LastStep = Step;
               display_counter = 0;
              }    
             
             if ( display_counter < 8000)
               {
                display_counter++;
               }
             
             if (display_counter >= 8000)
               {  
                  calculate_FFT(mono_input, 1024);
               }
            }  
          else if ( Step == 4)
            {
              if ( Step != LastStep)
              {
               oled_display_message("STEP4              ", "    FFT 512 Display");
               LastStep = Step;
               display_counter = 0;
              }    

             if ( display_counter < 8000)
               {
                display_counter++;
               }
             
             if (display_counter >= 8000)
               {  
                  calculate_FFT(mono_input, 512);
               }                 

            }    
                  
            
         aic3204_codec_write(left_output, right_output);

         if ( Step == 1)
          {
           /* Only display bargraph when setting up. Distracting otherwise */    
           bargraph_6dB(left_output, right_output);
          }
         }

       /* Disable I2S and put codec into reset */
        aic3204_disable();

        printf( "\n***Program has Terminated***\n" );
        
        oled_display_message("PROGRAM HAS        ", "TERMINATED        ");
        
        SW_BREAKPOINT;
    }