This example demonstrates how to use the msp_fft_fixed_q15 API to transform a real input data array to the frequency domain using the Q15 fast fourier transform (FFT) with fixed scaling. The real FFT function is identical to running a complex FFT with imaginary components set to zero. The result of the real FFT is a complex vector with half the samples but identical byte length.
#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();
status =
msp_mpy_q15(&mpyParams, input, window, input);
__no_operation();
}
void initSignal(void)
{
}
void initHamming(void)
{
sinParams.
length = 3*SAMPLES/2;
status =
msp_copy_q15(©Params, &temp[SAMPLES/4], &temp[0]);
status =
msp_sub_q15(&subParams, window, temp, window);
}