FFT output changes depending how buffers are declared

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
JaRe_3339291
Level 1
Level 1
Welcome! 5 replies posted First question asked

I have been experimenting with fixed point vs floating point and DIT vs single block FFTs on the M4 of a Psoc 6. I have come across some behavior that looks strange to me, but hopefully the symptom points to something obvious to someone with more experience. Any response would be greatly appreciated.

With the fixed point version I can get a good output, but only if I declare the input and output buffers locally within my FIR/FFT function along with another buffer of the same size that isn't even used. This function just casts my 16 bit TWF into the q31 input buffer, applies a low pass FIR filter, computes FFT, complex to magnitude, and lastly casts q31 FFT into a 16 bit output. The third buffer was normally commented out when I was trying the fixed point version, but I accidentally left it in and was surprised when I saw the good output.

I am using the arm_math library, specifically the 8192 block size arm_rfft_q31. Here is the good output. I get this if I declare the q31 input and output buffers locally along with a float32 buffer that is only used superficially so it doesn't get optimized out. (Input is 60Hz sine wave @ .4g's)

pastedImage_1.png

Here is the output I get no matter how else I declare the buffers. I can declare them all globally or any combination of global and local that isn't the case above. (Input is 60Hz sine wave @ .4g's). The output is half band and has what look like harmonics, but they are 113Hz apart, so they don't appear to be harmonics of the input signal.

pastedImage_2.png

I tried modifying the linker file to create a section in memory specifically for the input and output buffers. I have also tried increasing the size of the input and output buffers and this actually slightly changes the result (moves around the "harmonics"), but no matter how much I increase the size I still get what looks like a half band with some harmonics.

I can get a good output with the global buffers if I do DIT on two 4096 FFTs, but it crushes my efficiency and the output looks more noisy so I'd rather not do that. Declaring these large buffers locally means they are assigned each time the function is called. This is ~100KB of memory that is reassigned over and over. Is this a problem? Does this point to what might be happening?

I have limited experience working with microprocessors, so please let me know what info I can provide to help solve this. Thank you for reading.

0 Likes
1 Solution
JaRe_3339291
Level 1
Level 1
Welcome! 5 replies posted First question asked

Quick update:

I just tried doubling the size of the FFT output buffer and I am getting a good output. I hadn't tried increasing the output buffer only yet. So I have both input and output buffers declared globally without that 3rd unused buffer and I need the output buffer set to 16384 elements for a 8192 block size FFT to avoid the corrupted output.

View solution in original post

0 Likes
1 Reply
JaRe_3339291
Level 1
Level 1
Welcome! 5 replies posted First question asked

Quick update:

I just tried doubling the size of the FFT output buffer and I am getting a good output. I hadn't tried increasing the output buffer only yet. So I have both input and output buffers declared globally without that 3rd unused buffer and I need the output buffer set to 16384 elements for a 8192 block size FFT to avoid the corrupted output.

0 Likes