Hi, I am a new programer on the DSP F2812, i trying to use the library sprc081 to implement FFT for detect frequency. I did what the sample says but i don´t have success. I can see that only acq.input and the flags are working but nothing on the fft. I apreciate any advice to how perform the FFT over F2812 or an example. Thanks in advance.
#include "DSP281x_Device.h"
#include "IQmathLib.h"
#include "fft.h"
#define N 128 //FFT Length
#pragma DATA_SECTION(ipcb, "FFTipcb");
#pragma DATA_SECTION(mag,"FFTmag");
RFFT32 fft=RFFT32_128P_DEFAULTS;
long ipcb[N+2]; //In place computation buffer
long mag[N/2+1]; //Magnitude buffer
const long win[N/2]=HAMMING128; //Window coefficient array
RFFT32_ACQ acq=FFTRACQ_DEFAULTS; //Instance the module
void main(void)
{
//....................
/* Initialize acquisition module */
acq.buffptr=ipcb;
acq.tempptr=ipcb;
acq.size=N;
acq.count=N;
acq.acqflag=1;
/* Initialize FFT module */
fft.ipcbptr=ipcb;
fft.magptr=mag;
fft.winptr=(long *)win;
fft.init(&fft);
while(1)
{
static Uint16 i=0;
EALLOW;
SysCtrlRegs.WDKEY = 0xAA; // and serve watchdog #2
EDIS;
if (acq.acqflag==0) // If the samples are acquired
{
RFFT32_brev(ipcb,ipcb,N); // Input after windowing
fft.calc(&fft);
fft.split(&fft);
fft.mag(&fft);
for(i=0;i<N;i++)
{
mag[i]=sqrt(mag[i]);
}
acq.acqflag=1; // Enable the next acquisition
}
}
}
interrupt void ADC_FIR_INT_ISR(void)
{
acq.input=AdcBuf[ibuf];
acq.update(&acq);
ibuf++; // Increment the index
if(ibuf == AdcBufLen) ibuf = 0; // Rewind the pointer to beginning
}
aleaguir@gmail.com
thanks