AnsweredAssumed Answered

FFT Analyser

Question asked by ADS88 on Aug 25, 2011
Latest reply on Sep 19, 2011 by Nabeel

Hello,
I try to  generate the FFT of any signal in the range of [100Hz to KHz] and calculate the magnitude of each frequency.
I use rfft_fr16 function, As a prelimnary test I tried to generate the fft of a simple sine wave witch i gnerate with a
generator waveform then i convert them to digital signal with an ADC (AD7982).

the result of ADC is stocked in a table of short values. in[N]

I use the SPI link between ADC and DSP Blackfin 533.

 

The problem is that when I run the same code with different input sine frequencies the ouput peak has different amplitudes.


DSP => MASTER
ADC => SLAVE

 

 

/****ISR.C*************/
#include "BF533 Flags.h"
#include "filter.h"
#include "complex.h"
#include "uart.h"
#include "isrs.h"

#define N 2048

short mag[N],in[N];

complex_fract16 out[N];

complex_fract16 twl[N];       /* twiddle sequence*/


    twidfftrad2_fr16(twl,N);

   rfft_fr16(in,out,twl,1,N,0,0); /*Compute FFT*/


   for (i=0;i<N;i++)
   {
       mag[i]=cabs_fr16(out[i]);   //abs of FFT
   }

   SetUp_SPI_DMA_Rx();

/*****UART.C************/
#include <defBF532.h>
#include "BF533 Flags.h"
#include "UART.h"

short in[2048];

void Setup_SPI(void)
{

       *pSPI_BAUD=0x0004;  //
       *pSPI_CTL=0x110a; //Master, Byte of 16 bits, DMA in read  mode et mode "Get more Data"
       *pSPI_FLG=4;            //slave select enable 2
}


void SetUp_SPI_DMA_Rx()
{
       //Starting the transfer through DMA using UART

   *pDMA5_PERIPHERAL_MAP=0x5000;//setting up the UART TX DMA regsiter
   *pDMA5_CONFIG=0x0086;//STOP activate interrupt +DMA read write 16 bits

   *pDMA5_START_ADDR=&in[0];   //setting the pointer to the file as the starting address of the DMA


   *pDMA5_X_COUNT=2048;        //setting the count

   *pDMA5_X_MODIFY=0x2;                        //modifying register
   *pDMA5_Y_COUNT=0;                           //setting the count
   *pDMA5_Y_MODIFY=0x2;                        //modifying register

   *pDMA5_CONFIG|=0x0001;                      //starting the DMA

 

   *pSIC_IMASK |= 0xa000;
   *pSPI_CTL=0x510a;   //activate SPI


}
/***********main.c**************/

#include "BF533 Flags.h"
#include "ccblkfn.h"
#include "sysreg.h"
#include "uart.h"
#include "isrs.h"

void main(void)
{

  *pSYSCR = 0x0002;   // boot mode (load for flash memory)
   sysreg_write(reg_SYSCFG, 0x32);             //Initialize System Configuration Register

  *pSIC_IWR|=0x00000001;
  *pPLL_CTL=0x0400; // SCLKL=100MHz
  *pPLL_DIV=6;
   ssync();

   Init_Interrupts();
   Setup_SPI();
   while(1);

}
/*********************************/
I tried different solutions but not work: 1-apply window before compute the FFT, 2-give full arguments of function rfft : rfft_fr16 (in,out, twiddle, 1, N_FFT, &be, 1);
Is this a problem  of sampling frequency value ?
Which registers do I put this value?
What is the values of registers SPI_BAUD, PLL_DIV?
how to calculate it?

 

PS:

dsp_using            : ADSP-BF533
Emulator             : ADDS-HPUSB-ICE
Software             : VisualDSP++ 5.0
Operating_system     : Windows XP

Outcomes