I'm getting a weird interaction between FastLED and ArduinoFHT.

I’m getting a weird interaction between FastLED and ArduinoFHT.

I used the simplest example (fht_adc.pde) added a single strand of ws2812’s and I’m getting an r28 and r29 cannot be used in asm here error when I use the CHSV() or CRGB() calls.

Full code in http://pastebin.com/0i4XmY11, but the offending bit is below

void loop() {
static byte hue = 0;

while(1) { // reduces jitter
cli(); // UDRE interrupt slows this way down on arduino1.0
for (int 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
}
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();

/*
// this causes an r28 and r29 cannot be used in asm here error
for(int i = 0;i<numLeds;i++)
{
  leds[i] = CHSV(fht_log_out[i],255,255);
  LEDS.show();
}

// this causes an r28 and r29 cannot be used in asm here error
for(int i = 0;i<numLeds;i++)
{
  leds[i] = CHSV(hue++,255,255);
  LEDS.show();
}
*/

// this seems to work fine.
for(int i = 0;i<numLeds;i++)
{
  leds[i] = CRGB::Red;
  LEDS.show();
}

// this seems to work fine.
for(int i = 0;i<numLeds;i++)
{
  Serial.print(fht_log_out[i]);
  Serial.print(".");
}
Serial.println();

 // send out the data

}
}

i ran into this before, i think what i did was put all the led code in a seperate function and called that in main- doLeds(); or similar and for some reason it fixed it! i have no idea why and didn’t want to spend hours working it out since it’s presumably something obscure but it went ok. can double check if you’re still having problems but i’ve definitely seen and resolved it before now.

I’ve got something working:

http://pastebin.com/cM2hJfQv

Am using a Sparkfun MEMS microphone, which requires AREF to be connected to 3.3V, which is what supplies the microphone.

Oh man pete you solved my problem. Thank you so much!

Andrew, I think yours works because the led stuff and the fht stuff are in different functions.

@Zeke_Koch Maybe. I did have a tough time getting it going.