Hey there,

I'm having a problem with the results comming from the rmsf and rfft functions. Basically, I've written all my signal processing code using input samples with the float data type, with values between -325 and 325. E.g. the samples are aquired through an ADC and those words are processed to turn them into a value between those mentioned and then stored in external memory, where the buffers are big enough to have a rather long history of samples. Everything works fine when the samples are between those values.

But now, I wanted to normalize the samples, as diving them by 230. I thought it was as simple as changing 3 lines of code, but I couldn't be more wrong. When I do this, my RMS and THD calculations return -1.#QNAN. To be able to use the rmsf and rfft functions, the first thing I do is to get the data from external memory to internal memory, because if I just point the rmsf or rfft functions to buffers stored in external memory, I just get the -1.#QNAN result. So, the first thing I do is to create an auxiliary buffer, copy the contents from the external buffer to this auxiliary buffer, stored in internal memory, and then apply it to the rmsf and rfft functions. Like so:

float CALC_THD(float* src_addr)

{

int i;

float thd,aux = 0;

Store_Data_Int(src_addr, fft_input, 4000);

for(i=4000;i<FFTSIZE;i++){

fft_input[i] = 0;

}

rfft4096(fft_input,fft_output);

/*for(i=0;i<FFTSIZE/2;i++){

FFT_OP1_buff[i]=sqrt((fft_output[i].re)*(fft_output[i].re)+(fft_output[i].im)*(fft_output[i].im));

}*/

for(i=0;i<FFTSIZE/4;i++){

FFT_OP_buff[i]=(2*(sqrt((fft_output[2*i].re)*(fft_output[2*i].re)+(fft_output[2*i].im)*(fft_output[2*i].im)))/FFTSIZE);

}

for(i=2;i<FFTSIZE/4;i++){

aux = (FFT_OP_buff[i]*FFT_OP_buff[i])+aux;

}

thd = 100*sqrt(aux/(FFT_OP_buff[1]*FFT_OP_buff[1]));

return thd;

}

float CALC_RMS(float* buff)

{

//printf("endereco %06x\n",buff);

float val,aux_buffer[2000];

Store_Data_Int(buff,aux_buffer,RMSSIZE);

val = rmsf(aux_buffer, RMSSIZE);

//printf("val %f\n",val);

return val;

}

Now, as I said previously, while the samples had values between -325 and 325, the results were correct. I'm attaching a picture showing this. When the sample values changed to a range between -1.41 and 1.41 the results of these routines have changed to -1.#QNAN and I don't understand why! One thing I've noticed though, with a breakpoint in the line val = rmsf(...) is that the auxiliary buffer doesn't have all the correct values. The buffer from which it's getting the data is correct but the aux_buffer is only right until the position 1143 or so. After that it assumes ridiculous values of 4e+36 and things like that. Other times, the auxiliary buffer is correct but still doesn't give a correct value, and, on rare ocasions, the value is actually correct and given.

I have a custom board with the ADSP-21489 but I'm using the same SDRAM as the EZ-KIT, with the same setup, with everything being the same. And yes, I've tested it with the Primes example, where it calculates the first 20 prime numbers, or something like that, with it being in external memory and the saving and fecthing data from the SDRAM is also working, because I'm getting the correct values when the sample values in the wider range.

Thanks,

Luis

Hi Luis,

As this issue is being handled through private support channel I am closing this thread to avoid duplication of effort. Let's continue the discussion there and post the outcome here, if appropriate.

Thanks & Regards,

Jithul