Hello Community Members
I am currently using CMSIS DSP library in Code Composer Studio. I followed Amit's CMSIS DSP library integration to Code Composer Studio for Tiva C series document and I can use these functions.
But I have a problem that after CMSIS DSP FFT functions, I can not execute any command and code after these functions. My code does not enter While(1) loop. When ı change to Optimization level from 2) Global Optimization to off, It works fine. I wonder why it happens with this optimization settings.
#include <stdint.h>
#include <stdbool.h>
#include <math.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "driverlib/fpu.h"
#include "driverlib/sysctl.h"
#include "driverlib/rom.h"
#include "arm_math.h"
#include "arm_const_structs.h"
#define TEST_LENGTH_SAMPLES 2048
extern float32_t testInput_f32_10khz[TEST_LENGTH_SAMPLES];
static float32_t testOutput2[128];
uint32_t fftSize = 1024;
uint32_t ifftFlag = 0;
uint32_t doBitReverse = 1;
uint32_t refIndex = 213, testIndex = 0,testIndex2 = 0;
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
#define SERIES_LENGTH 256
#define Sampling_Freq 3200.0f
#define Line_Freq 50.0
float32_t gSeriesData[SERIES_LENGTH];
float fRadians;
int32_t i32DataCount = 0,success;
float32_t Fundamental_Freq;
void main()
{
FPULazyStackingEnable();
FPUEnable();
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ | SYSCTL_OSC_MAIN);
while(i32DataCount < SERIES_LENGTH)
{
gSeriesData[i32DataCount] = 2 * sinf( Line_Freq * (i32DataCount / Sampling_Freq) * 2 * M_PI);
i32DataCount++;
gSeriesData[i32DataCount] = 0;
i32DataCount++;
}
float32_t maxValue,maxValue2;
arm_cfft_f32(&arm_cfft_sR_f32_len128, gSeriesData, ifftFlag, doBitReverse);
arm_cmplx_mag_f32(gSeriesData, testOutput2, 128);
arm_max_f32(gSeriesData, 256, &maxValue2, &testIndex2);
arm_max_f32(testOutput2, 128, &maxValue, &testIndex);
// Any instruction is not working after this line and code stucks in 60th line
while(1)
{
Fundamental_Freq = testIndex * Sampling_Freq/SERIES_LENGTH;
}
}
Regards