typedef struct {
Frac16 z0; /* z[0] (real 16-bit fractional) */
Frac16 zNDiv2; /* z[n/2] (real 16-bit fractional) */
CFrac16 cz[1]; /* z[1] .. z[n/2 - 1] (complex 16-bit fractional)*/
} dfr16_sInplaceCRFFT;
how could it place z[1] .. z[n/2 - 1] to 2 short CFrac16 variable?
i want to print the result with the command "printf".
for (i=0;i<n/2;i++)
printf("z[%d]= %f",i,????);
Hello,
it seems to be a problem of memory allocation.
On the line:
dfr16_sInplaceCRFFT *pZ=malloc(sizeof(dfr16_sInplaceCRFFT));
It is not possible to use the sizeof operator, since the structure dfr16_sInplaceCRFFT represents only a beginning of the array of the values (if contains only a first and last element - both real valus(z0 and zNDIv2) and only a beginning of the complex results array CZ that is array of CFrac16 types.
The actual size of the cz[] array differs according to the length of the input.
It should be done the following way:
dfr16_sInplaceCRFFT *pZ=malloc(2*sizeof(Frac16) + (N/2-1) * sizeof(CFrac16));
The second thing is that the malloc function won't work placed before the
PE_low_level_init(); call, because it uses the DSP_MEM bean.
Do you have DSP_MEM bean correctly configured?
The DSP_MEM bean has to be correctly configured for the proper function of
the dynamic memory allocation. There has to be at least one memory area with
the quialifier INTERNAL_DYNAMIC or EXTERNAL_DYNAMIC.
Please see the applicaiton notes page in the help pages for the DSP_MEM bean.
This may be the reason why the statement
pRFFT = dfr16RFFTCreate (8, options); /* N = 8 point RFFT */
doesn't properly allocate the memory and consequently the dfr16RFFT function
results with -1. Please see the pRFFT value if it is not null.
Regarding the displaying of the values, you can use the following way:
/* first */
printf("z[0]= %f", ((short) (pZ->z0)) / (float)32768);
/* complex values */
for (i=0;i<N/2;i++) {
printf("z[%d] real = %f",i,((short) (pZ->z[i].real)) / (float)32768));
printf("z[%d] imag = %f",i,((short) (pZ->z[i].imag)) / (float)32768));
}
/* last */
printf("z[N/2]= %f", ((short) (pZ->zNDiv2)) / (float)32768 );
I hope that this will help.
best regards
Petr Hradsky
Processor Expert Support Team
UNIS