Hi, I'm using CMSIS DSP Libraries with a microcontroller STM32F4 to compute FFT. Here is my function code to compute the FFT: void fftProcess(float32_t *parSignalInput_f32, float32_t *parfftOutput_f32) { uint16_t i = 0, n = 0;
for (i=0; i<2048; i++) { hamming_signal_real_img_f32[2*i] = 0;//*(parSignalInput_f32+i); hamming_signal_real_img_f32[2*i+1] = 0; }
// // Calculate RFFT on samples // arm_cfft_f32(&arm_cfft_sR_f32_len2048, hamming_signal_real_img_f32, INVERT_FFT, BIT_ORDER_FFT);
// // Calculate complex power of FFT results // arm_cmplx_mag_f32(hamming_signal_real_img_f32, g_fFFTResult_f32, NUM_SAMPLES);
for(i=0; i< (NUM_SAMPLES/2); i++) { *(parfftOutput_f32 + i) = g_fFFTResult_f32[i]; }
} I'm wondering why the next variables: parfftOutput_f32, parSignalInput_f32, g_fFFTResult_f32, hamming_signal_real_img_f32 must be defined as global variables. If there are not, my program goes in the hardfault handler. Thanks for your answer, PH
So whatever it is that you're doing instead must be wrong!
Since you haven't shown what you're doing, it's impossible to be more specific.
www.catb.org/.../smart-questions.html
Please pay attention to the instructions for posting code - it's not exactly rocket science: www.danlhenry.com/.../keil_code.png
It's difficult to be more precise but I can try :). arm_cfft_f32() and arm_cmplx_mag_f32() are two functions from the CMSIS DSP Libraries provided by ARM. I can understand that global variables have to used for these functions because DMA is perhaps used during their execution. My question is why the two arguments of the "fftProcess" function must be declared in global too. In my opinion, they are not used in the DMA process. Waiting for your advices, Thanks,
it's not exactly rocket science
The evidence suggests otherwise :(
I can understand that global variables have to used for these functions because DMA is perhaps used during their execution. You should not be able to understand that, because that reasoning is incorrect. DMA has nothing to do with whether a variable is global or not. DMA may pose restrictions on a variable's storage duration, alignment, or even which memory space it's in. But certainly not on its global visibility (a.k.a. "linkage").
What, exactly, makes you think that?
DMA is used to transfer data from a buffer to another without using the processor. To do that, variables must be global because, the transfer is done independently from the execution of the program. Do you have other ideas to understand my problem? Do you try to execute my program code? Thanks for your help
Sorry - your summary about DMA isn't correct.
You are mixing scope with lifetime. And even auto variables with limited lifetime can be used with DMA as long as the function doesn't return before the transfer ends.
But remember that 'static' allows file-local or function-local variables with full lifetime.
Two important things here for DMA: - the variable must be alive for the full duration of the transfer (doesn't mean global) - the variable must be located in a memory region that supports DMA.
Thanks for your correction, you are right :) I try to test my function by putting all my variables in local static to understand if the scope or the lifetime was important. I have no error. It seems that the parameter "parfftOutput_f32" of the function must be declared as local but not static. The three other variables must be declared as static.
"It seems that the parameter "parfftOutput_f32" of the function must be declared as local but not static. The three other variables must be declared as static."
Ho? I think there is something else going wrong...