This example demonstrates how to use the msp_fft_iq31 API to transform a 32-bit real input data array to the frequency domain using the fast fourier transform (FFT) with fixed scaling.
#include "msp430.h"
#include <math.h>
#include <stdint.h>
#include <stdbool.h>
#include "DSPLib.h"
#define FS 8192
#define SAMPLES 256
#define SIGNAL_FREQUENCY1 200
#define SIGNAL_AMPLITUDE1 0.6
#define SIGNAL_FREQUENCY2 2100
#define SIGNAL_AMPLITUDE2 0.15
#define HAMMING_ALPHA 0.53836
#define HAMMING_BETA 0.46164
#define PI 3.1415926536
volatile uint32_t cycleCount;
extern void initSignal(void);
extern void initHamming(void);
void main(void)
{
WDTCTL = WDTPW + WDTHOLD;
#ifdef __MSP430_HAS_PMM__
PM5CTL0 &= ~LOCKLPM5;
#endif
initSignal();
initHamming();
__no_operation();
}
void initSignal(void)
{
convertParams.
length = SAMPLES;
}
void initHamming(void)
{
sinParams.
length = 3*SAMPLES/2;
status =
msp_copy_q15(©Params, &temp[SAMPLES/4], &temp[0]);
convertParams.
length = SAMPLES;
}