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)
float thd,aux = 0;
Store_Data_Int(src_addr, fft_input, 4000);
fft_input[i] = 0;
aux = (FFT_OP_buff[i]*FFT_OP_buff[i])+aux;
thd = 100*sqrt(aux/(FFT_OP_buff*FFT_OP_buff));
float CALC_RMS(float* buff)
val = rmsf(aux_buffer, RMSSIZE);
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.