Board: Arduino Nano 33 BLE Sense
I'm pulling PCM data from an onboard microphone and running it through the arduinoFFT library (version 1.5.6) to obtain a spectrogram. Since the arduinoFFT library requires the data be an array of doubles, I've converted the data from short to double, and started the FFT process. The FFT.Windowing() function worked fine, but I get the error at the FFT.Compute() function call (line 77). The error goes away when I remove the function call. The error:
Found 25 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <arduinoFFT> 1.5.6
|-- <PDM> 1.0
Building in release mode
Linking .pio\build\nano33ble\firmware.elf
c:/users/benlu/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-
eabi/8.2.1/../../../../arm-none-eabi/bin/ld.exe:linker_script.ld:138 cannot move location counter
backwards (from 000000002004a470 t
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\nano33ble\firmware.elf] Error 1
And the code:
#include "Mic.h"
#include <arduinoFFT.h>
// FFT
arduinoFFT FFT = arduinoFFT(); /* Create FFT object /
/
These values can be changed in order to evaluate the functions
/
const uint16_t samples = 16128; //This value MUST ALWAYS be a power of 2
const double signalFrequency = 16000;
const double samplingFrequency = 16000;
const uint8_t amplitude = 100;
/
These are the input and output vectors
Input vectors receive computed results from FFT
*/
double vImag[samples] = {0};
// buffer to read samples into, each sample is 16-bits
short* sample_buffer;
// number of samples read, read from Mic class on loop
volatile int samples_read;
// The length of the buffer to use. Currently set to 4 seconds.
int buffer_size = 16000;
double double_buffer[16384] = {};
// Instantiate
Mic mic;
// DO NOT PRINT INSIDE THIS FUNCTION - Causes it to hang.
void onPDMdata() {
mic.sample();
}
void setup() {
Serial.begin(115200);
while (!Serial);
PDM.onReceive(onPDMdata);
PDM.setBufferSize(16128);
Serial.println("3...");
delay(1000);
Serial.println("2...");
delay(1000);
Serial.println("1...");
delay(1000);
Serial.println("Listening!");
mic.begin();
}
void loop() {
// wait for samples to be read
samples_read = mic.samples_read();
// If desired buffer size is reached.
if (samples_read >= buffer_size) {
// Retrieves audio buffer
sample_buffer = mic.sample_buffer();
// print samples to the serial monitor or plotter
for (int i = 0; i < samples_read; i++) {
double_buffer[i] = (double)(sample_buffer[i]);
Serial.println(double_buffer[i]);
}
Serial.println("---------- SAMPLE BREAK ----------");
FFT.Windowing(double_buffer, samples, FFT_WIN_TYP_HAMMING, FFT_FORWARD);
FFT.Compute(double_buffer, vImag, samples, FFT_FORWARD); /* Compute FFT <--------------------- THIS LINE */
// FFT.ComplexToMagnitude(double_buffer, vImag, samples); /* Compute magnitudes */
// delay for data collection only, comment when not collecting
delay(1000);
Serial.println("Listening!");
// clear the read count and resume recording
mic.clear_buffer();
}
}
Where can I start to troubleshoot this issue? I've not had to deal with linker errors before, so any pointers would be greatly appreciated. Thanks in advanced!