D
DeletedUser
Guest
Hello
I already posted this but don't see it on the new post so I'll post again. I am trying to compile some code . I have the error msg:
c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: address 0x200842c0 of C:\Users\chris\AppData\Local\Temp\arduino_build_881826/evdist.ino.elf section `.bss' is not within region `DTCM'
c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: address 0x200842c0 of C:\Users\chris\AppData\Local\Temp\arduino_build_881826/evdist.ino.elf section `.bss' is not within region `DTCM'
collect2.exe: error: ld returned 1 exit status
I don't know what this means.
This code is a homemade FFT with an order (ORD=32768). When I use ORD <= 16384 it works. Any ideas? Thanks.
Below is my code:
I already posted this but don't see it on the new post so I'll post again. I am trying to compile some code . I have the error msg:
c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: address 0x200842c0 of C:\Users\chris\AppData\Local\Temp\arduino_build_881826/evdist.ino.elf section `.bss' is not within region `DTCM'
c:/program files (x86)/arduino/hardware/tools/arm/bin/../lib/gcc/arm-none-eabi/5.4.1/../../../../arm-none-eabi/bin/ld.exe: address 0x200842c0 of C:\Users\chris\AppData\Local\Temp\arduino_build_881826/evdist.ino.elf section `.bss' is not within region `DTCM'
collect2.exe: error: ld returned 1 exit status
I don't know what this means.
This code is a homemade FFT with an order (ORD=32768). When I use ORD <= 16384 it works. Any ideas? Thanks.
Below is my code:
Code:
evdist.ino
-----------
//#define DEBUG
#include <LiquidCrystal_I2C.h>
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>
// GUItool: begin automatically generated code
AudioPlaySdWav playSdWav1; //xy=317.74999618530273,462.77778816223145
AudioRecordQueue queue1; //xy=565.75,439
AudioRecordQueue queue2; //xy=569.75,494
AudioPlayQueue queue3; //xy=760.25,442.7500305175781
AudioPlayQueue queue4; //xy=760.25,500.2500305175781
AudioOutputI2S i2s1; //xy=1067.7500190734863,459.27777194976807
AudioConnection patchCord1(playSdWav1, 0, queue1, 0);
AudioConnection patchCord2(playSdWav1, 1, queue2, 0);
AudioConnection patchCord3(queue3, 0, i2s1, 0);
AudioConnection patchCord4(queue4, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=313.75,572
// GUItool: end automatically generated code
#define SDCARD_CS_PIN 10
#define SDCARD_MOSI_PIN 7
#define SDCARD_SCK_PIN 14
//-------------Button-----------------------------
int buttonPin=4;
int buttonNew=1;
int buttonOld=0;
unsigned long BounceStart=millis();
unsigned long BounceDelay=100UL;
//----------- Stream parameters ---
unsigned long startstream;
unsigned long startstreamdelay=1000UL;
unsigned long stopstream;
unsigned long stopstreamdelay=1000UL;
int streamstate=5;//idle
int iterL=0,iterR=0;
//----------Algorithm-----------------------------
#define ORD 32768
#define pi 3.14159265358979
#define Epsilon 1.e-10
#define fs 44100
#define sigthresh .1 //need at least -20dB THD
#define NUMFREQ 6
#include "windowcoefs.h" //chebwin
float fftinL[2*ORD];
float fftinR[2*ORD];
float *fftoutL;
float *fftoutR;
float ThdL,ThdR;
int NumfreqL,NumfreqR;
//------LCD------------
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup(void)
{
Serial.begin(115200);
pinMode(buttonPin, INPUT_PULLUP);
AudioMemory(64);
sgtl5000_1.enable();
sgtl5000_1.volume(0.5);
SPI.setMOSI(SDCARD_MOSI_PIN);
SPI.setSCK(SDCARD_SCK_PIN);
if (!(SD.begin(SDCARD_CS_PIN))) {
while (1) {
Serial.println("Unable to access the SD card");
delay(500);
}
}
lcd.init(); // initialize the lcd
// Print a message to the LCD.
lcd.backlight();
delay(500);
lcd.home();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Push Button for");
lcd.setCursor(0,1);
lcd.print("thd analysis");
}
void loop(void)
{
if (chkButton())
{
playSdWav1.play("sine.wav");
streamstate=0;
startstream=millis();
}
stateAudio();
if (streamstate==1)
{
queue1.begin();
queue2.begin();
}
if (streamstate==2)
{
if (queue1.available() >= 1) //Left Channel
{
passthru(queue1.readBuffer(),queue3.getBuffer(),&iterL,fftinL);
queue1.freeBuffer();
queue3.playBuffer();
}
if (queue2.available() >= 1) //Right Channel
{
passthru(queue2.readBuffer(),queue4.getBuffer(),&iterR,fftinR);
queue2.freeBuffer();
queue4.playBuffer();
}
}
if (streamstate==3)
{
playSdWav1.stop();
iterL=0;
iterR=0;
}
if (streamstate==4)
{
#ifdef DEBUG
Serial.println("----------- Left Channel Spectrum ---------------");
#endif
lcd.clear();
lcd.setCursor(0,0);
FFTCALC(fftinL, fftoutL);
if (FINDSPECTRUMS(fftinL,&NumfreqL,&ThdL))
{
lcd.print("NfL=");
lcd.print(NumfreqL);
lcd.print(" ThdL=");
lcd.print(round(ThdL));
}
else lcd.print("FAIL ThdLcalc");
#ifdef DEBUG
Serial.println("----------- Right Channel Spectrum ---------------");
#endif
lcd.setCursor(0,1);
FFTCALC(fftinR, fftoutR);
if (FINDSPECTRUMS(fftinR,&NumfreqR,&ThdR))
{
lcd.print("NfR=");
lcd.print(NumfreqR);
lcd.print(" ThdR=");
lcd.print(round(ThdR));
}
else lcd.print("FAIL ThdRcalc");
streamstate=5;
}
}
void passthru(int16_t *inbuf,int16_t *outbuf,int *iter,float *fftin)
{
int16_t *bp1,*bp2;
int indx=*iter;
bp1=inbuf;
bp2=outbuf;
for(int i = 0;i < AUDIO_BLOCK_SAMPLES;i++)
{
if (indx<ORD) fftin[indx++]=(float)*bp1/32768.;
*bp2++ = *bp1++;
}
*iter=indx;
}
int fftcalc(float *in,float *out,int ord)
{
int NPASS,inptr,outptr,tempin,i,nset,nbut,pass,setno,butter,indxa,indxb;
float theta,Wr,Wi,*inr,*ini,*outr,*outi,tempra,tempia,temprb,tempib;
inr=in;ini=in+ord;outr=out;outi=out+ord;
//---------------- Bit Reverse -----------------------
NPASS=(int)(log10((float)ord)/log10(2.));
for (inptr=0;inptr<ord;inptr++)
{
tempin=inptr;
outptr=0;
for (i=0;i<NPASS;i++)
{
outptr=(2*outptr)+tempin%2;
tempin/=2;
}
inr[outptr+ord]=inr[inptr];
}
for (i=0;i<ord;i++)
{
inr[i]=inr[i+ord];
ini[i]=0.0;
}
//-------------- Radix 2 FFT -----------------------
nset=ord/2;
nbut=1;
for (pass=1;pass<=NPASS;pass++)
{
for (setno=1;setno<=nset;setno++)
{
for (butter=0;butter<nbut;butter++)
{
theta=((float)(nset*butter))*pi/((float)(ord/2));
Wr=cos(theta);Wi=-sin(theta);
indxa=butter+((setno-1)*2*nbut);indxb=indxa+nbut;
tempra=inr[indxa]+Wr*inr[indxb]-Wi*ini[indxb];
tempia=ini[indxa]+Wr*ini[indxb]+Wi*inr[indxb];
temprb=inr[indxa]-Wr*inr[indxb]+Wi*ini[indxb];
tempib=ini[indxa]-Wr*ini[indxb]-Wi*inr[indxb];
outr[indxa]=tempra;
outi[indxa]=tempia;
outr[indxb]=temprb;
outi[indxb]=tempib;
}
}
nbut*=2;nset/=2;
for (i=0;i<ord;i++)
{
inr[i]=outr[i];
ini[i]=outi[i];
}
}
return(1);
}
void FFTCALC(float *fftin, float *fftout)
{
for (int i=0;i<ORD-1;i++)
{
fftin[i]=fftin[i]*Chebycoefs[i];
}
fftin[ORD-1]=0.0;
fftout=fftin;
fftcalc(fftin,fftout,ORD);
for (int i=0;i<ORD/2;i++)
{
fftout[i]=(4./ORD)*sqrt((fftout[i]*fftout[i])+(fftout[i+ORD]*fftout[i+ORD]));
#ifdef DEBUG
Serial.print((float)i*(float)fs/(float)ORD);
Serial.print(" ");
Serial.println(20.*log10(fftout[i]+1e-10));
#endif
}
}
int FINDSPECTRUMS(float *fftout,int *Numfreq,float *Thd)
{
float maxres=0.0,thresh=sigthresh,ampl,maxlvl;
float sigNRG,noiseNRG;
int i,existval,numfreq,startindx,endindx=0,indx=0;
long iter;
float fsig[NUMFREQ];
int sigindx[NUMFREQ];
//------- compute total signal NRG --------
sigNRG=0.0;
for (i=0;i<ORD/2;i++)
{
sigNRG+=fftout[i]*fftout[i];
}
//----- calculate threshold ----
for (i=0;i<ORD/2;i++)
{
if (fftout[i]>maxres) maxres=fftout[i];
}
maxres*=thresh;
existval=0;
for (i=0;i<ORD/2;i++)
{
if (fftout[i]>maxres) existval=1;
}
if (existval==0)
{
Serial.println("********** NO SIGNAL FOUND ********");
return 0;
}
iter=0;
//-------- find signal frequencies -------------
while (existval>0)
{
numfreq=iter+1;
if (numfreq>NUMFREQ)
{
Serial.println("******* SIGNAL TOO NOISY FOR FURTHER ANALYSIS *******");
return 0;
}
i=0;
//---- look for indx rising lvl of first spectral line ----
while (i<ORD/2)
{
if (fftout[i]>maxres)
{
indx=i;
maxlvl=fftout[i];
break;
}
i++;
}
i++;
//find indx of maxlvl of this spectral line
while (i<ORD/2)
{
if (fftout[i]>maxlvl)
{
indx=i;
maxlvl=fftout[i];
i++;
}
else break;
}
//---------for display------------
sigindx[iter]=indx;
fsig[iter]=((float)((float)(sigindx[iter])/ORD))*fs;
//----- remove this set of spectral lines from the total ----
endindx=indx+5;
startindx=indx-5;
ampl=0.0;
for (i=startindx;i<=endindx;i++)
{
if (fftout[i]>ampl)
ampl=fftout[i];
fftout[i]=0;
}
Serial.print("signal no: ");
Serial.print((int)iter+1);
Serial.print(" freq: ");
Serial.print(fsig[iter]);
Serial.print(" Hz magnitudedB: ");
Serial.println(20.*log10(ampl));
//----- continue if there are any remaining spectral lines ------
iter++;
existval=0;
for (i=0;i<ORD/2;i++)
{
if (fftout[i]>maxres) existval=1;
}
}
//------- compute total noise NRG --------
noiseNRG=0.0;
for (i=0;i<ORD/2;i++)
{
noiseNRG+=fftout[i]*fftout[i];
}
//------- compute spectral thd --------
*Thd=-10.*log10((sigNRG/noiseNRG)+1.0e-10);
Serial.print("spectral thd=");
Serial.println(*Thd);
*Numfreq=numfreq;
return 1;
}
int chkButton()
{
int retval=0;
if ((millis()-BounceStart)>BounceDelay)
{
BounceStart=millis();
buttonNew=digitalRead(buttonPin);
if(buttonOld==1 && buttonNew==0) retval=1;
buttonOld=buttonNew;
}
return retval;
}
void stateAudio()
{
if (streamstate==0)
{
if (millis()-startstream>startstreamdelay) //waiting to start stream
{
streamstate=1;
}
}
else if (streamstate==1) //start stream
{
//audioOn();
stopstream=millis();
streamstate=2;
}
else if (streamstate==2) //run stream
{
if (millis()-stopstream>stopstreamdelay) streamstate=3;
}
else if (streamstate==3) //stop stream
{
//audioOff();
streamstate=4;
}
else if (streamstate==4) //calculate spectrum
{
//calculate spectrum
}
else if (streamstate==5) //idle
{
//idle
}
}
windowcoefs.h
----------------
const double PROGMEM Chebycoefs[]={
//there are 32768 values here but I can't show them as I depass the message text size
};