Hi. The attached code never gets beyond the line:
Serial.println(853.0);
Comment it out and the rest of the code should run just fine. Can anyone tell me why? Frankly, I'm starting to get really tired of the limitations and idiosyncrasies of this lobotomized 'c' called an 'Arduino sketch'.
Thanks.
#define LOG_OUT 1 // use the log output function
#define FHT_N 128 // set to 256 point fht
#include <FHT.h> // include the library
void setup() {
Serial.begin(115200); // use the serial port
TIMSK0 = 0; // turn off timer0 for lower jitter
ADCSRA = 0xe5; // set the adc to free running mode
ADMUX = 0x40; // use adc0
DIDR0 = 0x01; // turn off the digital input for adc0
}
void loop() {
while(1) { // reduces jitter
Serial.println(854.0);
cli(); // UDRE interrupt slows this way down on arduino1.0
int i;
int g;
for (i = 0 ; i < FHT_N ; i++) { // save 256 samples
while(!(ADCSRA & 0x10)); // wait for adc to be ready
ADCSRA = 0xf5; // restart adc
byte m = ADCL; // fetch adc data
byte j = ADCH;
int k = (j << 8) | m; // form into an int
k -= 0x0200; // form into a signed int
k <<= 6; // form into a 16b signed int
fht_input[i] = k; // put real data into bins
Serial.println(853.0);
}
Serial.println(855.0);
fht_window(); // window the data for better frequency response
fht_reorder(); // reorder the data before doing the fht
fht_run(); // process the data in the fht
fht_mag_log(); // take the output of the fht
sei();
// Serial.write(255); // send a start byte
// Serial.write(fht_log_out, FHT_N/2); // send out the data
for(int g=0; g<FHT_N/2; i++) {
Serial.print(i+g);
Serial.print('\t');
Serial.println(fht_log_out[g]); // send out the data
}
}
}
Moderator edit: Frankly, I'm starting to get really tired of people who can't be bothered to read the guidelines and use CODE TAGS.
fht_adc.ino (1.73 KB)