This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

STM32F4- FFT : why global variables?

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

Parents
  • 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.

Reply
  • 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.

Children