hi people!
I am working with pics and i have a problem.
I want to know the calculating time of a pic24, for a 256 points FFT . I cant find this!
Anybody can help me?
Thanks in advance for your time,
Best Regards
Eduardo
calculating time of a pic24 for a 256 points FFT
-
- Posts: 46
- Joined: 05 Aug 2007 07:15
- Location: Shizuoka JAPAN
Hi mingas.
Unfortunately I don't have experience of writing nor reading FFT cpde on pic24.
But you can find FFT code for PC at here .
And you prefer PASCAL code, I have translated above code to DELPHI code
here
--This code needs a COMPLEX lib(Complexes.pas Types.pas) that you can get here.
If you calculate only fixed 256point FFT, you should remove "bit reversal sort algorithm" from above code and add some (sorted) array constant to them for speed up.
But I can't understand why pic24? If you use DSPIC, MP for DSPIC supports FFT function. So you only needs to write FFT(8, ***,***).
Sorry for my bad English.
As you know, how match time spend is depends on what code you write.I want to know the calculating time of a pic24, for a 256 points FFT . I cant find this!
Unfortunately I don't have experience of writing nor reading FFT cpde on pic24.
But you can find FFT code for PC at here .
And you prefer PASCAL code, I have translated above code to DELPHI code
here
Code: Select all
procedure CFFT(const InArray: array of TComplex; var OutArray: array of TComplex);
var
i, ip, j, k, Le, Le2, N, ND2: integer;
L, M: byte;
Tmp, U, S: TComplex;
begin
N := Length(InArray);
M := Round(Ln(N)/Ln(2));// Math.LOG2(N) is more fast
{ code like - M := 0; while N > 1 do begin N := N shr 1; inc(M); end may match faster. but needs some error trap}
ND2 := N shr 1; // N div 2
{if inplace translation, bellow code not be needed.}
for i := 0 to N -1 do
OutArray[i] := InArray[i];
{Bit reversal sorting}
j := ND2; // i = 1 and j=ND2 are obviously bit reversal pair. (N = 2^n)
{ ie. %0001 & % 1000 for N=16 }
for i := 1 to N -2 do
begin
if i < j then // To avoid exchange twice.
begin // Here we exchange bit-reversal pair.
Tmp := OutArray[j];
OutArray[j] := OutArray[i];
OutArray[i] := Tmp;
end;
k := ND2; // These code may complicated.
while k <= j do // But think that,
begin // If i and j are bit-reversal pair,
j := j - k; // then i + 1 and j +(but bit reversal addition) 1
k := k shr 1 ; // are also pair. ie %0010 & %0100
end; // These code realize bit reversal addition to j.
j := j + k;
end;
{FFT}
Le2 := 1;
for L := 1 to M do // Loop for each stage
begin
Le := Le2 shl 1; // Le = 2^L; Le2 = 2^(n-1)
U := Complex(1.0, 0);
S.Re := cos(pi / Le2);
S.Im := -sin(pi / Le2);
for j := 1 to Le2 do // Loop for sub DFT
begin
i := j - 1;
while i <= (N - 1) do //Butterfly
begin
ip := i + Le2;
Tmp := ComplexMul(OutArray[ip], U);
OutArray[ip] := ComplexSub(OutArray[i], Tmp);
OutArray[i] := ComplexAdd(OutArray[i], Tmp);
i := i + Le;
end;
U := ComplexMul(U, S);
end;
Le2 := Le2 shl 1;
end;
end;
If you calculate only fixed 256point FFT, you should remove "bit reversal sort algorithm" from above code and add some (sorted) array constant to them for speed up.
But I can't understand why pic24? If you use DSPIC, MP for DSPIC supports FFT function. So you only needs to write FFT(8, ***,***).
Sorry for my bad English.